php registraiton form/confirmation pg
Hello:
I am really new to PHP and having trouble passing data from a registration page to a confirmation page. I have a registration page that inserts records into a MySQL database. When the new registrant presses submit (and after the username has been verified) I want them to be directed to a confirmation page that will list the data they just entered in the registration form.
I am using DMX and it's server behaviors panel to check username and insert record.
This is what is at the top of my registration page:
<?php require_once('../Connections/mhs2.php'); ?>
<?php
session_start();
// *** Redirect if username exists
$FF_flag="MM_insert";
if (isset($HTTP_POST_VARS[$FF_flag])) {
$FF_dupKeyRedirect="regfail.php";
$FF_dupKeyUsernameValue = $HTTP_POST_VARS["username"];
$FF_dupKeySQL = "SELECT username FROM tbl_users WHERE username='" . $FF_dupKeyUsernameValue . "'";
mysql_select_db($database_mhs2, $mhs2);
$FF_rsKey=mysql_query($FF_dupKeySQL, $mhs2) or die(mysql_error());
if(mysql_num_rows($FF_rsKey) > 0) {
// the username was found - can not add the requested username
$FF_qsChar = "?";
if (strpos($FF_dupKeyRedirect, "?")) $FF_qsChar = "&";
$FF_dupKeyRedirect = $FF_dupKeyRedirect . $FF_qsChar . "requsername=" . $FF_dupKeyUsernameValue;
header ("Location: $FF_dupKeyRedirect");
exit;
}
mysql_free_result($FF_rsKey);
}
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tbl_users (firstName, lastName, spouseName, email, username, password, address, city, `state`, zip, phone, childorself, childName, chddiag, other, surgprocandnotes, otherchildren) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['firstname'], "text"),
GetSQLValueString($HTTP_POST_VARS['lastname'], "text"),
GetSQLValueString($HTTP_POST_VARS['spouseName'], "text"),
GetSQLValueString($HTTP_POST_VARS['email'], "text"),
GetSQLValueString($HTTP_POST_VARS['username'], "text"),
GetSQLValueString($HTTP_POST_VARS['password'], "text"),
GetSQLValueString($HTTP_POST_VARS['address'], "text"),
GetSQLValueString($HTTP_POST_VARS['city'], "text"),
GetSQLValueString($HTTP_POST_VARS['state'], "text"),
GetSQLValueString($HTTP_POST_VARS['zip'], "text"),
GetSQLValueString($HTTP_POST_VARS['phone'], "text"),
GetSQLValueString($HTTP_POST_VARS['childorself'], "text"),
GetSQLValueString($HTTP_POST_VARS['childName'], "text"),
GetSQLValueString($HTTP_POST_VARS['chddiag'], "text"),
GetSQLValueString($HTTP_POST_VARS['other'], "text"),
GetSQLValueString($HTTP_POST_VARS['surgprocandnotes'], "text"),
GetSQLValueString($HTTP_POST_VARS['otherChildren'], "text"));
mysql_select_db($database_mhs2, $mhs2);
$Result1 = mysql_query($insertSQL, $mhs2) or die(mysql_error());
$insertGoTo = "confirm.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
And this is in my form attributes:
<form action="<?php echo $editFormAction; ?>" METHOD="POST" name="form1">
On the confirm page:
<?php
session_start();
$username = $_POST['username'];
$_SESSION['username'] = $username;
?>
And in the body:
Name: <?php echo $_SESSION['username']; ?>
Sorry for the long post. And if I am in the wrong place just move the post. Can anyone help?
Thanks a bunch,
Marci
|