Page 1 of 1

One drop of code bugging me during $_POST using $_GET var

Posted: Sun Mar 20, 2011 1:39 am
by iCeR
User clicks on a url, ie: example.com/AEQ438J

When I perform this in the code below:

Code: Select all

    $referrer = $_GET['_url'];
    // echo $referrer displays the referrer ID contents correctly as "AEQ438J"
    
    if ( ! empty($referrer))
    {
    $mysqli->query("UPDATE coming_soon_emails SET clicks = clicks + 1 WHERE code='" . $referrer ."'");
    }
    // this also updates the database correctly as it should

    if (!empty($_POST['email'])){

   // echo $referrer displays the referrer ID contents as BLANK. It should display "AEQ438J"!
    .....
$referrer displays correctly BEFORE if($_POST['form']), however during the if($_POST['form']) $referrer is empty.
How can I fix my code so that $referrer is not empty during the time the user posts their email address in the form?

Thank you!

Re: One drop of code bugging me during $_POST using $_GET va

Posted: Sun Mar 20, 2011 10:51 am
by iCeR
update is this..

In JS if I comment out the ajax call of

Code: Select all

,'json')
and in index.php comment out the line

Code: Select all

$ajax = ($_SERVER['HTTP_X_REQUESTED_WITH']  == 'XMLHttpRequest');
it then updates the DB correctly and all works well! :)

However, now ajax no longer hides and shows the divs.. so knowing what the issue is, what can I do to sort it?