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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iCeR
Forum Newbie
Posts: 5
Joined: Tue Feb 08, 2011 9:29 am

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

Post 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!
Last edited by iCeR on Mon Mar 21, 2011 11:53 am, edited 1 time in total.
iCeR
Forum Newbie
Posts: 5
Joined: Tue Feb 08, 2011 9:29 am

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

Post 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?
Post Reply