assign form input to a session
Posted: Wed Dec 11, 2013 4:03 pm
i have a form that has a a few fields the are being sent to the database. one of the fields is an ID that is auto incremented i am trying to create a session for the ID to use on the next page once the form has been submitted but the session isn't showing on the next page
here is my code
page1.php
confirm.php
i did also try and use another post that has to be inputted
$_SESSION['orderID'] = $_POST['name'];
confirm.php
but neither are showing on the confirm.php
here is my code
page1.php
Code: Select all
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO wildOrchidRes (ID, name, address, town, county, postCode, country, email, telephone, checkIn, checkOut, amount) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ID'], "int"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['town'], "text"),
GetSQLValueString($_POST['county'], "text"),
GetSQLValueString($_POST['postCode'], "text"),
GetSQLValueString($_POST['country'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['telephone'], "text"),
GetSQLValueString($_POST['checkIn'], "text"),
GetSQLValueString($_POST['checkOut'], "text"),
GetSQLValueString($_POST['amount'], "double"));
mysql_select_db($database_WO, $WO);
$Result1 = mysql_query($insertSQL, $WO) or die(mysql_error());
$insertGoTo = "confirm.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
session_start();
$_SESSION['orderID'] = $_POST['ID'];
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<input type="hidden" name="MM_insert" value="form1" />
</form>
Code: Select all
<?php
session_start();
$_SESSION['orderID'];
?>$_SESSION['orderID'] = $_POST['name'];
confirm.php
Code: Select all
<?php
session_start();
$_SESSION['orderID'];
?>