Jump to content

Langstra

Members
  • Posts

    11
  • Joined

  • Last visited

Posts posted by Langstra

  1. You could also make a function queryBuilder

    /**
    * $select, array with elements you want to select, null for *
    * $from, table you want to get information from
    * $where, the array with values you want to check on
               WHERE key = value
    */
    
    function queryBuilder($select,$from,$where) {
       $query = "SELECT";
       if($select == null) { //If there are no specific things to select, select all
           $query .= " *";
       } else {
           foreach($select as $s) {
               $query .= " ".$s.","; //add every select with a trailing ,
           }
           $query = str_split($query, strlen($query)-1); //remove the last ,
           $query = $query[0];
       }
       $query .= " FROM ".$from;
       if($where != null) {
           $query .= " WHERE";
           foreach($where as $key => $value) {
               $query .= " ".$key."=".$value." OR";
           }
           $query = str_split($query, strlen($query)-3); //remove the last OR
           $query = $query[0];
       } // else no where statement and thus end of query
       return $query;
    }
    

  2. You forgot to start the session on the submitted-contact.php page, so just call session_start() and I think it might work. I have not looked through the rest of your code, because it was so much and I almost instantly had an idea what it might be.

    It might be a good idea to turn on errors and warnings in your PHP installation. You can do this in the php.ini file. Then it would have shown a warning I think, or maybe even an error, I am not sure, but I do know that it would have said something.

  3. The maximum allowed length of the URL is limited (by the http specification), so if you are submitting data such as this post here, using GET may result in the data being truncated (chopped-off) or the request failing entirely. (Note that the maximum size of POST data is also limited. But that limitation is a configuration setting on the server and may be modified.)

    The limitations of the url are most of the times, if not all of the times, a bottleneck. For instance take the jqueryui themeroller. When you edit a style download it there is always a link provided so you can edit your style later again. That link contains the styling of the whole theme.

    Look at this url, it is a jquiryui theme.

    http://jqueryui.com/themeroller/?ffDefault=Helvetica%2CArial%2Csans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=5px&bgColorHeader=888888&bgTextureHeader=04_highlight_hard.png&bgImgOpacityHeader=15&borderColorHeader=404040&fcHeader=ffffff&iconColorHeader=cccccc&bgColorContent=14141a&bgTextureContent=01_flat.png&bgImgOpacityContent=16&borderColorContent=404040&fcContent=f9f6f6&iconColorContent=bbbbbb&bgColorDefault=9e9e9e&bgTextureDefault=03_highlight_soft.png&bgImgOpacityDefault=100&borderColorDefault=cccccc&fcDefault=333333&iconColorDefault=666666&bgColorHover=adadad&bgTextureHover=05_inset_soft.png&bgImgOpacityHover=60&borderColorHover=dddddd&fcHover=000000&iconColorHover=c98000&bgColorActive=14141a&bgTextureActive=06_inset_hard.png&bgImgOpacityActive=35&borderColorActive=d4d4d4&fcActive=ffffff&iconColorActive=ffffff&bgColorHighlight=fbf9ee&bgTextureHighlight=04_highlight_hard.png&bgImgOpacityHighlight=55&borderColorHighlight=fcefa1&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=02_glass.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px
    

  4. $query = "UPDATE tablename t1 SET
    t1.username = '{$username}',
    t1.password = '{$password}'
    WHERE t1.id = '{$id}' AND !EXISTS(
    SELECT *
    FROM tablename t2
    WHERE t2.account = '{$account}' AND t2.id != '{$id}'
    )"
    
    

     

    This checks if there does not exist another row with that username that you want to set. But it does exclude the row you want to update, because that may be the same username.

  5. I successfully implemented paypal ipn on my website, I tested it on the paypal sandbox and everything worked. Then I changed the url from https://www.sandbox..../cgi-bin/webscr to https://www.paypal.com/cgi-bin/webscr. This should be standard procedure and everything should work fine.

    Once again, when using the sandbox provided by paypal, there are no problems.

     

    Now a few of my customers tried to buy things and nobody got there items. In my database I log everything and I logged this error:

    http error=Unknown SSL protocol error in connection to www.paypal.com:443
    

     

    I use paypal ipn for the payment, underneath will be the ipn.php (ipn call back script that paypal will post variables to when a payment has been done)

    //Original source: https://cms.paypal.com/cms_content/US/en_US/files/developer/IPN_PHP_41.txt
    //Modified sample code by Codex-m: http://www.php-developer.org
    //WORKING DEMO HERE: http://www.php-developer.org/paypal_ipn_demo/
    //Use your Paypal Sandbox buyer account to test.
    $req = 'cmd=' . urlencode('_notify-validate');
    foreach ($_POST as $key => $value) {
    $value = urlencode(stripslashes($value));
    $req .= "&$key=$value";
    }
    //NEW CODE: using Curl instead of fsockopen
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://www.paypal.com/cgi-bin/webscr');
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
    //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: www.sandbox.paypal.com'));
    $res = curl_exec($ch);
    //assign posted variables to PHP variables
    $payment_status = $_POST['payment_status'];
    $payment_amount = $_POST['mc_gross'];
    $payment_currency = $_POST['mc_currency'];
    $txn_id = $_POST['txn_id'];
    $receiver_email = $_POST['receiver_email'];
    $payer_email = $_POST['payer_email'];
    $account=$_POST['custom'];
    $productname=$_POST['item_name'];
    $txn_type=$_POST['txn_type'];
    $trans_id=$_POST['transaction[0].id'];
    $trans_id_2=$_POST['transaction[0].id_for_sender'];
    //Check if any error occured
    if(curl_errno($ch)) { //HTTP ERROR occurred
    //Log error to database for troubleshooting
    $log='http error='.curl_error($ch); //Here the error message gets build
    db_write($log); //Here it gets written to the database
    } else {
    //NO HTTP ERROR OCCURRED, CLEAN
    //CHECK IF VERIFIED
    if (strcmp ($res, "VERIFIED") == 0) {
    

     

    I hope somebody knows what the problem is. Additional information about my webserver:

    ###### ApacheFriends XAMPP version 1.7.1 ######
    + Apache 2.2.11
    + MySQL 5.1.33 (Community Server)
    + PHP 5.2.9 + PEAR (Support for PHP 4 has been discontinued)
    + XAMPP Control Version 2.5 from www.nat32.com
    + XAMPP CLI Bundle 1.3 from Carsten Wiedmann
    + XAMPP Security 1.0
    + SQLite 2.8.15
    + OpenSSL 0.9.8i
    + phpMyAdmin 3.1.3.1
    + ADOdb 5.06a
    + Mercury Mail Transport System v4.62
    + FileZilla FTP Server 0.9.31
    + Webalizer 2.01-10
    + Zend Optimizer 3.3.0
    + eAccelerator 0.9.5.3 for PHP 5.2.9 (but not activated in the php.ini)
    

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.