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; 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 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']; ?>" /> 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? 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> 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. 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
Archived
This topic is now archived and is closed to further replies.