Snooble Posted February 1, 2007 Share Posted February 1, 2007 <?php $price = "£59.99"; $product = "Apple Ipod"; ?> <input type="hidden" name="product" value="$product"> how can i carry variables through a posted form? Like that? Snooble Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted February 1, 2007 Share Posted February 1, 2007 On the next page they will be available in $_GET or $_POST depending on how you send it. Quote Link to comment Share on other sites More sharing options...
Snooble Posted February 1, 2007 Author Share Posted February 1, 2007 i send it to a php page via POST looking like this: <?php include 'sessionstartandsql.php'; include 'expire.php'; $_SESSION['price'] = $_POST['price']; $_SESSION['product'] = $_POST['product']; $_SESSION['quantity'] = $_POST['quantity']; if(isset($_SESSION['myemail'])){ header("Location:purchase.php"); } else{ header("Location:login.php"); } ?> Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted February 1, 2007 Share Posted February 1, 2007 I'm not sure what you are trying to do... Quote Link to comment Share on other sites More sharing options...
Snooble Posted February 1, 2007 Author Share Posted February 1, 2007 Ok. Im trying to set variables on page 1. Post them in hidden fields to page 2 which then lets me use them on page 3. Page 1 is: <form action="checkpurchase.php" method="post"> <input type="hidden" name="product" value="$product"><?php $price = £59.99; $product = Apple Ipod; ?> <input type="hidden" name="price" value="$price"> <input type="hidden" name="product" value="$product"> <input name="quantity" type="text" value="1" size="2" maxlength="2" /> <input type="submit" name="submit" value="Buy" /> Page 2 is: <?php include 'sessionstartandsql.php'; include 'expire.php'; $_SESSION['price'] = $_POST['price']; $_SESSION['product'] = $_POST['product']; $_SESSION['quantity'] = $_POST['quantity']; if(isset($_SESSION['myemail'])){ header("Location:purchase.php"); } else{ header("Location:login.php"); } ?> I just need code to echo out the variable on page 3. So my goal: Assign "£59.99" and "Apple Ipod" to seperate variables that i can echo out on page 3. Snooble Quote Link to comment Share on other sites More sharing options...
corbin Posted February 1, 2007 Share Posted February 1, 2007 Just use the $_SESSION['price'] ['product'] and ['quantity'] instead of putting them in another hidden field... That's just creating an extra step. Quote Link to comment Share on other sites More sharing options...
Snooble Posted February 1, 2007 Author Share Posted February 1, 2007 your right. duh. god. Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 2, 2007 Share Posted February 2, 2007 To correct the actual problem: <input type="hidden" name="price" value="$price"> <input type="hidden" name="price" value="<?=$price?>"> or <input type="hidden" name="price" value="<?php print $price; ?>"> 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.