Forums

PHP

This topic is locked

Update Form Destroys Session Variable

Posted 09 May 2007 19:57:59
1
has voted
09 May 2007 19:57:59 Matt Penn posted:
I've got a simple form where a user can update their contact info. The redirect takes them back to the homepage.

Session variables work fine on the update form page.

HOWEVER, after submitting the form, all session variables are wiped out and no personalized info is displayed on the homepage.

I am pasting in the PHP code used to update the record (standard Dreamweaver-generated code). Is there something here that would cause session variables to be wiped out?



<pre id=code><font face=courier size=2 id=code>
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "Edituser") {
$updateSQL = sprintf("UPDATE regusers SET UserFirstName=%s, UserLastName=%s, UserEmail=%s, UserCompany=%s, UserAddr1=%s, UserAddr2=%s, UserCity=%s, UserState=%s, UserZip=%s, UserPhone=%s, UserPhone2=%s WHERE UserID=%s",
GetSQLValueString($_POST['fname'], "text",
GetSQLValueString($_POST['lname'], "text",
GetSQLValueString($_POST['email1'], "text",
GetSQLValueString($_POST['company'], "text",
GetSQLValueString($_POST['Address1'], "text",
GetSQLValueString($_POST['Address2'], "text",
GetSQLValueString($_POST['City'], "text",
GetSQLValueString($_POST['State'], "text",
GetSQLValueString($_POST['zip'], "text",
GetSQLValueString($_POST['Phone1'], "text",
GetSQLValueString($_POST['phone2'], "text",
GetSQLValueString($_POST['hiddenField'], "int");

mysql_select_db($database_somo, $somo);
$Result1 = mysql_query($updateSQL, $somo) or die(mysql_error());
$updateGoTo = "index.php";
header(sprintf("Location: %s", $updateGoTo));
}
</font id=code></pre id=code>

Any ideas? Thanks!

Replies

Replied 11 May 2007 18:08:18
11 May 2007 18:08:18 Alan C replied:
Where does the session get started?

the reason I'm asking is that the first thing that comes to mind is that when the user is redirected to the homepage they pass through the code that sets up the session - that would initiate a new session so you would never see the old data.

Reply to this topic