Dynadot โ€” .com Registration $8.99

Driving me bonkers (simple PHP)

Spaceship Spaceship
Watch

noswad

Established Member
Impact
1
Hello.

Is it possible to take the end of a link e.g. .com/?id=123 and insert the '123' into the into a field of a registration page using PHP so I can log which users have referred others.

Thanks.
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
It is both possible and easy. If you had x.com/page.php?id=xx and

PHP:
echo '<input type=hidden name=id value=' . $_GET['id'] . '>';

somewhere on page.php then you would have a hidden form element containing the id of the referer.
 
0
•••
Thanks v much! :hehe:
 
0
•••
Hi

I got this working at first by changing the code a little bit but for some reason I can't get it to work any more.

Could anyone help me please? Its driving me nuts.

David :'(

P.S. The field doesn't have to be hidden although I would prefer it to be :hehe:
 
Last edited:
0
•••
Merged your threads ;)

Really isn't that hard either.. and would suggest the same as xemiterx.

PHP:
<?php

$id = intval($_GET['id']);

echo '<input type="hidden" name="id" value="' . $id . '">';  

?>

What did you change? ^^ Should work just fine.
 
0
•••
Excellent thanks. One little problem though -

If register.php?id=[text] the form is submitting '0' but if the id=[numbers] it's submitting correctly.

Any clues?

Thanks again
 
Last edited:
0
•••
Ok, I was assuming the 'id' was just numerical, well, you could do the following:

PHP:
<?php

$id = trim($_GET['id']);

if(preg_match("/([^a-z0-9]+)/i", $id))
{
    die('Invalid ID');
}

echo '<input type="hidden" name="id" value="' . $id . '">';  

?>
 
0
•••
Thanks v much. V grateful.
 
0
•••
Unstoppable Domains
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back