![Picture of ZZorro Picture of ZZorro](/graphics/unknown.gif)
ZZorro - 2010-06-11 23:49:19 -
In reply to message 1 from Charles deRees
Do not pass information via the http headers. Use the built-in variable handling in PHP.
Here is a snippet of get the value from a form and saving them to a database:
*** this code is part of an html input form
<form id="registerForm" method="post" action="/register/save_new.php">
<label for="FName">First Name:<span class="red">*</span></label>
<input type="text" id="FName" class="required" name="FName" size="30" maxlength="30" tabindex="2" />
<br>
<label for="LName">Last Name:<span class="red">*</span></label>
<input type="text" id="LName" class="required" name="LName" size="30" maxlength="30" tabindex="3" />
<div id="submit">
<input class="submit" type="submit" value="Submit"/>
</div>
<br />
</form>
*** end of input form ****
save_new.php sample code
<?php>
$link = mysql_connect('mydb.myhostingprovider.com', 'login name', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
// Connected successfully';
mysql_select_db(registrations);
$Salutation = Trim(stripslashes($_POST['Salutation']));
$FName = TitleCase(mysql_real_escape_string(Trim(stripslashes($_POST['FName']))));
$LName = TitleCase(mysql_real_escape_string(Trim(stripslashes($_POST['LName']))));
// save the information to the database
$query="INSERT INTO registration (Salutation, First_Name, Last_Name)
VALUES('$Salutation', '$FName', '$LName')";
mysql_query($query) or die ("Error in query: $query");
mysql_close();
// Send confirming e-mail
include ("send_email.php");
// or use the following
// print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
?>