thminco Posted November 1, 2011 Share Posted November 1, 2011 Can someone please tell me what I am doing wrong here? For some reason, the variable doess not seem to be getting passed to the "action" php script this input is in my html form (action=post)... <input type="hidden" name="httpreferer" value="<?php echo $_SERVER['HTTP_REFERER'] ?>" /> this is in the action script... $httpreferer=$_POST['httpreferer']; echo $httpreferer; Quote Link to comment https://forums.phpfreaks.com/topic/250203-passing-hidden-php-variable-in-html-form/ Share on other sites More sharing options...
QuickOldCar Posted November 1, 2011 Share Posted November 1, 2011 <input type="hidden" name="httpreferer" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" /> Was missing a semicolon Quote Link to comment https://forums.phpfreaks.com/topic/250203-passing-hidden-php-variable-in-html-form/#findComment-1283851 Share on other sites More sharing options...
thminco Posted November 1, 2011 Author Share Posted November 1, 2011 Did you mean as below? (I tried that) <input type="hidden" name="httpreferer" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" /> Quote Link to comment https://forums.phpfreaks.com/topic/250203-passing-hidden-php-variable-in-html-form/#findComment-1283854 Share on other sites More sharing options...
trq Posted November 1, 2011 Share Posted November 1, 2011 Are you sure $_SERVER['HTTP_REFERER'] is even populated? Can you see nay data in the hidden field when your view source? Quote Link to comment https://forums.phpfreaks.com/topic/250203-passing-hidden-php-variable-in-html-form/#findComment-1283856 Share on other sites More sharing options...
QuickOldCar Posted November 1, 2011 Share Posted November 1, 2011 Try this, it works for me. <html> <body> <form action="" method="post"> <input type="hidden" name="httpreferer" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" /> <input type="submit" /> </form> </body> <?php $httpreferer=$_POST['httpreferer']; echo $httpreferer; ?> </html> Quote Link to comment https://forums.phpfreaks.com/topic/250203-passing-hidden-php-variable-in-html-form/#findComment-1283859 Share on other sites More sharing options...
QuickOldCar Posted November 1, 2011 Share Posted November 1, 2011 Make sure the files are saved as .php, and not as .html or another. Quote Link to comment https://forums.phpfreaks.com/topic/250203-passing-hidden-php-variable-in-html-form/#findComment-1283861 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.