fabiez Posted December 14, 2014 Share Posted December 14, 2014 what am i doing wrong? I can't see it... I want to catch the rand variable but it doesn't. So I print an extra print at the bottom. So there should be two rand prints. Here's the code. <html> <head><title></title> </head> <body> <form action='random.php' method='post'> <?php if(isset($_REQUEST['rand'])){ $rand = $_REQUEST['rand']; print $rand . "<br /><br />"; } else { print "rand: empty<br /><br />"; } $rand = rand(1,1000); print $rand."<br /><br />"; print "<input type='hidden' value='$rand' />"; ?> <input type='submit' value='scramble' /> </form> </body> </html> I forgot to tell ya that the if statement returns rand: empty. Help... Quote Link to comment Share on other sites More sharing options...
Solution mac_gyver Posted December 14, 2014 Solution Share Posted December 14, 2014 <input type='hidden' value='$rand' /> ^^^ your form field doesn't have a name='rand' attribute, so, there is no $_POST['rand'] or in your case $_REQUEST['rand'] value. only form fields with name's are submitted, as that's the only way for the value to be identified. Quote Link to comment Share on other sites More sharing options...
fabiez Posted December 14, 2014 Author Share Posted December 14, 2014 thank you Quote Link to comment Share on other sites More sharing options...
hansford Posted December 14, 2014 Share Posted December 14, 2014 I would like to see some attempts at error reporting and some printed feedback as to just what exactly is getting returned from things such as forms, functions/methods. After your opening <?php tag you should have full error reporting turned on when in debug mode. <?php error_reporting(E_ALL); ini_set('display_errors', 1); Before you attempt to execute an query - echo it out to the screen or log the query to a file for viewing. $query = "SELECT Student_Id, Lname, Fname FROM Students WHERE Student_Id = '$id'"; echo $query; exit; When your form is submitted to the php page for processing - print the values of what the $_POST array contains. if (isset($_POST['some_value'])) { echo '<pre>'; print_r($_POST); echo '</pre>'; } Quote Link to comment 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.