sql - Having trouble passing variables between pages through php -
so here's code on first page:
<?php $db = mysql_connect( ':/applications/mamp/tmp/mysql/mysql.sock', 'root', 'root' ); if(!$db) die("error connecting mysql database."); mysql_select_db('onlineform', $db); $newquery1 = mysql_query("select newcampsessions onlineformdata order id desc limit 1") or die('error ' . mysql_error()); $newfoo = mysql_fetch_array($newquery1); $newquery2 = mysql_query("select priceperweek onlineformdata order id desc limit 1") or die('error ' . mysql_error()); $newfoo1 = mysql_fetch_array($newquery2); $newoldstring = $newfoo['newcampsessions']; $newoldstring2 = $newfoo1['priceperweek']; $newchangedstring = unserialize($newoldstring); $newchangedstring2 = unserialize($newoldstring2); sql_close(); ?> <html> <head> (all tags in here) </head> <body> <form id="paymentform" action="amd8.php" method="post"> <input type="hidden" name="priceperweek" value="<?php echo $newchangedstring2 ?>"/> <input type="hidden" name="specificweek" value="<?php echo $newchangedstring ?>"/> </form> </body> </html>
there's more first page, provided codes relevant. working php-wise on first page.
when try , pass onto 2nd page, i'm getting value of null specific arrays i'm trying pass over.
amd8.php:
<?php if ($_post['formsubmit'] == "submit") { $newstring = $_post['priceperweek']; $newstring2 = $_post['specificweek']; } $db = mysql_connect( ':/applications/mamp/tmp/mysql/mysql.sock', 'root', 'root' ); if(!$db) die("error connecting mysql database."); mysql_select_db('onlineform', $db); $newquery = mysql_query("select newprice,numberofweeks onlineformdata order id desc limit 1"); $newrow = mysql_fetch_row($newquery); $limit = $newrow[1]; $totalprice = 0; if (isset($_session['campsessions'])) { ($count == 0; $count < $limit; $count=$count+1) { foreach ($_session['campsessions'] $campsessions) { if ($campsessions == ($newstring[$count])) { $totalprice = $totalprice + $newstring2[$count]; } } } } ?> <html> <head>(header info)</head> <body> <p> <?php echo gettype($newstring2); echo gettype($newstring); ?> </p> </body> </html>
as can see, gettypes()
i'm trying echo ones giving me value of null
you need name submit button formsubmit
make if statement return true. change form , should work:
<form id="paymentform" action="amd8.php" method="post"> <input type="hidden" name="priceperweek" value="<?php echo $newchangedstring2 ?>"/> <input type="hidden" name="specificweek" value="<?php echo $newchangedstring ?>"/> <input type="submit" value="submit" name="formsubmit"> </form>
Comments
Post a Comment