Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-08-2004, 10:07 AM
WebProWorld New Member
 

Join Date: Mar 2004
Location: Grand Island, NE
Posts: 7
biff423 RepRank 0
Default 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
__________________
Marci Smith
President
Midwest Heart Connection
president@midwestheartconnection.com
www.midwestheartconnection.com
Reply With Quote
  #2 (permalink)  
Old 05-22-2004, 07:17 AM
WebProWorld New Member
 

Join Date: Apr 2004
Location: London, England
Posts: 14
virtual_odin RepRank 0
Default

Marci

Not sure if this will help, but here goes.

All the values passed by the form are available to the script in the page you set in the

<form action="..." METHOD="POST" name="...">

line. Whatever you name the fields, the variable is available without further ado. Just put a $ in front. You seem to be referring to an echo statement only in the action= part; I don't know why.

What I tend to do is make the form action line

<form action="thispage.php?action=save" METHOD="POST" name="...">

then on thispage.php do whatever $action needs either using if($action == "save"){blah bla} or using a switch statement. Of course the first time the page is called $action is NULL.

Hope that helps.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0