Use PHP to track links -


i have various links in website point specific form.

whenever fills out form, want able know link led them form.

i want without having create individual line of php code every link create in the. instead, want have php code picks link, , maybe inserts hidden text box gets value or text tag in link.

for example:

  1. user clicks link.
  2. that link directs them form.
  3. the link carries identification activates php code
  4. when recieve form, know link clicked form.

i want work links in emails send out well.

based on information in post, sounds want send token/ id.

<a href="form.php?token=xxx">goto form</a> 

now on form can grab token:

$token = $_get['token']; // use proper testing first 

then use switch or if statements run whichever code need.

<input type="hidden" value="<?php echo $token; ?>"> 

additional:

as //use proper testing first comment indicates, should make sure token being passed valid , sanitized in case of attack. 1 option have tokens stored in database when generated , compared when validating. htmlspecialchars() , strip_tags() sanitizing.

if token fails validate, should not output , should have warning message/redirect there error.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -