I have a form which sends it's output to a page.The user agrees with what has been sent, and the data is sent to a third page to add a new line to MySQL.
The first and second pages work, but the new line is empty.
Can anyone tell me why??
Form:
<form action="reg_proc.php" method="post" enctype="application/x-www-form-urlencoded" name="register">
<table width="97%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td bordercolor="#6699CC"><div align="left">Your FIRST name</div></td>
<td><input name="fname" type="text" maxlength="25"/></td>
</tr>
<tr>
<td bordercolor="#6699CC"><div align="left">Your SECOND name</div></td>
<td><input name="sname" type="text" maxlength="25"/></td>
</tr>
<tr>
<td bordercolor="#6699CC"><div align="left">Your EMAIL</div></td>
<td><input name="email" type="text" /></td>
</tr>
<tr>
<td bordercolor="#6699CC"><div align="left">MOBILE</div></td>
<td><input name="mobile" type="text" value="07" /></td>
</tr>
<tr>
<td bordercolor="#6699CC"><div align="left">I am a </div></td>
<td><input name="gender" type="radio" value="m" />boy
<input name="gender" type="radio" value="f" />girl </td>
</tr>
<tr>
<td bordercolor="#6699CC"><div align="left">POSTCODE</div></td>
<td><input name="pcode" type="text" /></td>
</tr>
<tr>
<td bordercolor="#6699CC"><div align="left">I am...</div>
</td>
<td><input name="user_level" type="radio" value="1" />Staff/screener <br />
<input name="user_level" type="radio" value="2" />a Coordinator <br />
<input name="user_level" type="radio" value="0" />just passing by <br />
</td>
</tr>
<tr>
<td>
<input type="submit" value="Register" />
</td>
<td>
<input type="reset" value="Start again"/>
</td>
</tr>
</table>
</form>
Confirmation...
<div id="positioned-element24">
<?php include("connect.php");
$db_name="tht"; // Database name
$tbl_name="users"; // Table name
// username and password sent from form
$fname=$_POST['fname'];
$sname=$_POST['sname'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$gender=$_POST['gender'];
$pcode=$_POST['pcode'];
$user_level=$_POST['usr_level'];
?>
<br />
<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Your name is
</td>
<td><strong><?php
echo ($fname);
echo($sname);
?></strong></td>
</tr>
<tr>
<td>Your mobile</td>
<td><strong><?php
echo ($mobile);
?></strong>
</td>
</tr>
<tr>
<td>Your email</td>
<td><strong><?php
echo ($email);
?></strong>
</td>
</tr>
</table>
You are (m/f): <?php echo ($gender)?>, and live in <?php echo ($pcode)?>.
<br />
<form action="reg_proc2.php">
<input name="reg_submit" id="reg_submit" value="Register me!" type="submit"/>
<input type="button" value="No, start again" ONCLICK="history.go(-1)"/>
</form>
</div>
and the actual doings...
<div id="positioned-element24">
<?php include("connect.php");
// username and password sent from form
$fname=$_POST['fname'];
$sname=$_POST['sname'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$gender=$_POST['gender'];
$pcode=$_POST['pcode'];
$user_level=$_POST['usr_level'];
$sql = "INSERT INTO users (fname, sname, email, mobile, gender, pcode, acs_lvl) VALUES ('$fname','$sname','$email','$mobile', '$gender', '$pcode', '$user_level')";
#execute SQL statement
$result = mysql_query($sql, $db);
# check for error
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
$to = $email;
$subject = "THT Registration";
$header = "From: ". $fname . $sname." <" . $email . ">\r\n";
$body = "Hi there.<br>Someone entered this address to register at THT's site. If it wasn't you, please accept our apologies. Your data will be removed within seven days. <br>Otherwise, please follow the link below. <hr> For more info on the trust, please visit http://www.tht.org ";
echo 'Thank-you'.$fname.'. Your message has been sent to '.$email;
mail($to, $subject, $body, $header);
?>
<br />
An email has been sent to the address you entered. <br />
This contains a link, and when you click this the registration is complete.
<p>
You should follow this link within <strong>seven days</strong>, or <a href="#">request</a> a new email.
</div>