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:
- user clicks link.
- that link directs them form.
- the link carries identification activates php code
- 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
Post a Comment