php - I am trying to pass variables between pages and i am failing -
i have been trying pass variable between pages tally score on quiz, reason variables aren't passing between pages want them to, want score 1 if first button hit, , 2 if second hit, of ever 1 hit result 0.
1st page - minus whole load of styling:
<?php $score=0; if ( isset( $_post['submit1'] ) ) { $score=$score+1; } if ( isset( $_post['submit2'] ) ) { $score=$score+2; } ?> <body> <center><img src="http://fc06.deviantart.net/fs70/f/2011/002/d/3/purple_blob_pet_by_bunni0222-d36aw4q.png" alt="" align="middle"/></center> <form name ="form1" method ="post" action ="test1.php"> <input type = "hidden" name = "h1" value = <?php echo $score; ?> > <center><input type = "submit" class=mybutton name = "submit1" value = "1"></center> <center><input type = "submit" class=mybutton name = "submit2" value = "2"></center> </form> </body>
this complete second page:
<html> <head> <title>test</title> </head> <body> <p> <?php $score = 0; //error_reporting(0); $score = $_post['h1']; echo $score; ?> </p> </body> </html>
i appreciate help, if stupid apologise learning how write html , php.
i think problem in line:
<input type = "hidden" name = "h1" value = <?php echo $score; ?> >
to
<input type = "hidden" name = "h1" value = "<?php echo $score; ?>" >
Comments
Post a Comment