1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[help] [php] how to null this?

Discussion in 'General Programming Chat' started by ZaynWantsMoney, Sep 30, 2016.

  1. ZaynWantsMoney

    ZaynWantsMoney Registered Member

    Joined:
    Feb 24, 2014
    Messages:
    66
    Likes Received:
    7
    app_verify.php
    PHP:
    <?php include("includes/header.php");

        require(
    "includes/function.php");
        
    $kwallpaper=new  k_wallpaper;
        include(
    'purchase.php');
        
        
        if(isset(
    $_POST['submit']))
        {
            
             if(
    verify_purchase($_POST['buyer'],$_POST['purchase_code']) == false)
             {
                
                
    $_SESSION['msg']="Sorry, we are unable to verify your purchase.";
                
    header"Location:app_verify.php");
                exit;
            }
            else
            {
                 
    $data = array(
                
    'buyer'  =>  $_POST['buyer'],
                
    'purchase_code' => $_POST['purchase_code'],
                
    'status' => '1'
                
    );
              
                
    $app_edit=Update('app_verify'$data"WHERE id = '1'");
                
                if (
    $app_edit 0){
                    
                    
    $_SESSION['msg']="Save successfully...";
                    
    header"Location:app_verify.php");
                    exit;
                }     
            }
            
            
            
        }
        
    //Get Data
        
    $app_qry="SELECT * FROM app_verify WHERE id='1'";
        
    $app_result=mysql_query($app_qry);
        
    $app_row=mysql_fetch_assoc($app_result);
        
    ?>
        
        
    <script src="js/category.js" type="text/javascript"></script> 
                    
                    <div id="main">
                    <h2><a href="home.php">Dashboard</a> &raquo; <a href="#" class="active"></a></h2>
                    <?php if(isset($_SESSION['msg'])!= '')
                    {
                    echo 
    '<p style="color:white">'.$_SESSION['msg'].'</p>';
                    
    $_SESSION['msg'] = '';   
                    }
                    
    ?>
                        <form action="" name="addeditcategory" method="post" class="jNice" onsubmit="return checkValidation(this);" enctype="multipart/form-data">
                        
                                                
                        <h3>App Verify</h3>
                            <fieldset>
                            
    <label>Buyer:</label>
                                    
          
                                    
                                 <input type="text" name="buyer" id="buyer" value="<?php echo $app_row['buyer'];?>" >
                                <label style="padding-top:20px;">Purchase Code</label>
                             <input type="text" name="purchase_code" id="purchase_code" value="<?php echo $app_row['purchase_code'];?>" > 
                             <p></p>
               <input type="submit" name="submit" value="Save" />
                            
                            </fieldset>
                        </form>
                    </div>
                    <!-- // #main -->
                    
                    <div class="clear"></div>
                </div>
                <!-- // #container -->
            </div>   
            <!-- // #containerHolder -->
            
    <?php include("includes/footer.php");?>       
    purchase.php

    PHP:
    <?php error_reporting(0);
    /*
         * Item purchase verification by envato api
         */
        
    function verify_purchase($buyer_name,$p_code)
        {
            
            
            
    $envato_username "viaviwebtech";
            
    $envato_api_key  "2uw51mxa55u4dsxh8m8a4i7bqp4ux1p0";
            
            
    $buyer                =    $buyer_name;
            
    $purchase_code        =    $p_code;
            
            
    $curl                 =    curl_init('http://marketplace.envato.com/api/edge/'.$envato_username.'/'.$envato_api_key.'/verify-purchase:'.$purchase_code.'.xml');
            
            
    curl_setopt($curlCURLOPT_USERAGENT$_SERVER['HTTP_USER_AGENT'] );
            
    curl_setopt($curlCURLOPT_RETURNTRANSFER1);
            
    curl_setopt($curlCURLOPT_TIMEOUT30);
            
    curl_setopt($curlCURLOPT_FOLLOWLOCATION1);
            
            
    $purchase_data        =    curl_exec($curl);
            
    curl_close($curl);
            
            
            
    $purchase_data        =    json_decode(json_encode((array) simplexml_load_string($purchase_data)),1);

            if ( isset(
    $purchase_data['verify-purchase']['buyer']) && $purchase_data['verify-purchase']['buyer'] == $buyer)
            {
                return 
    true;
            }
            else
            {
                return 
    false;
            }
        }
        
        function 
    purchase_status()
        {
            
    $app_qry="SELECT * FROM app_verify WHERE id='1'";
            
    $app_result=mysql_query($app_qry);
            
    $app_row=mysql_fetch_assoc($app_result);
            
            if(
    $app_row['status']=='1')
            {
                return 
    true;
            }
            else
            {
                return 
    false;
            }
        }
     
    ?>
     
  2. bartosimpsonio

    bartosimpsonio Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 21, 2013
    Messages:
    12,765
    Likes Received:
    11,422
    Occupation:
    COINZ
    Location:
    BUYAH
    Home Page:
    if(verify_purchase($_POST['buyer'],$_POST['purchase_code']) == false)

    BECOMES

    if(false)
     
  3. Aleksandrius

    Aleksandrius Junior Member

    Joined:
    Jul 26, 2013
    Messages:
    148
    Likes Received:
    132
    Occupation:
    Internet Marketing
    Location:
    Macedonia
    In the app_verify.php

    if(isset($_POST['submit']))
    {
    $data = array(
    'buyer' => $_POST['buyer'],
    'purchase_code' => $_POST['purchase_code'],
    'status' => '1'
    );

    $app_edit=Update('app_verify', $data, "WHERE id = '1'");

    if ($app_edit > 0){

    $_SESSION['msg']="Save successfully...";
    header( "Location:app_verify.php");
    exit;
    }



    }
     
  4. ZaynWantsMoney

    ZaynWantsMoney Registered Member

    Joined:
    Feb 24, 2014
    Messages:
    66
    Likes Received:
    7
    @Aleksandrius can i put any random buyer and purchase code then?
     
  5. Aleksandrius

    Aleksandrius Junior Member

    Joined:
    Jul 26, 2013
    Messages:
    148
    Likes Received:
    132
    Occupation:
    Internet Marketing
    Location:
    Macedonia
    Probably yes, if there isn't any other code that calls for the verify_purchase function.
     
  6. ZaynWantsMoney

    ZaynWantsMoney Registered Member

    Joined:
    Feb 24, 2014
    Messages:
    66
    Likes Received:
    7
    I used a random cuyer purchase code but it didn't worked
    it doesn;t says saved successfully
     
  7. Aleksandrius

    Aleksandrius Junior Member

    Joined:
    Jul 26, 2013
    Messages:
    148
    Likes Received:
    132
    Occupation:
    Internet Marketing
    Location:
    Macedonia
    Have you tried @bartosimpsonio's solution?
     
  8. ZaynWantsMoney

    ZaynWantsMoney Registered Member

    Joined:
    Feb 24, 2014
    Messages:
    66
    Likes Received:
    7
    That doesn't work either
    whenever i enter buyer, purchase code and save
    it shows this

    [​IMG]