I am new to PHP and borrowed a registration script from a PHP site. I've stripped all the SQL out in the snippet below and left enough to just recreate the issue. I've done a ton of searches to try and figure this out, but to no avail.
The issue that I'm having is that the form variables are being lost after the submit. I would think that $_GET or $_REQUEST would restore those variables so that the user doesn't have to re-enter them if they make a mistake in a field, they submit the form and the form regenerates. I've put the REQUEST and/or GET before and after the form tag, but nothing seems to work.
What on earth am I doing wrong?
Thanks,
Mike
<?php
session_start();
include ('dbc.php');
if ($_POST['Submit'] == 'Register')
{
if ( empty($_POST['full_name']) )
{
header("Location: testMe.php?msg=ERROR: Name is empty..");
exit();
}
if (strlen($_POST['email']) < 5)
{
header("Location: testMe.php?msg=ERROR: Incorrect email. Please enter valid email address..");
exit();
}
}
?>
<link href="styles.css" rel="stylesheet" type="text/css">
<?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?>
<table width="65%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="e5ecf9" class="forumposts">
<form name="form1" method="post" action="testMe.php" style="padding:5px;">
<p><br>
Name:
<?php $full_name=$_GET['full_name']; ?>
<input name="full_name" type="text" id="full_name">
Ex. John Wilson</p>
<p>Email:
<?php $email=$_REQUEST['email']; ?>
<input name="email" type="text" id="email">
Ex. john@domain.com</p>
<p align="center">
<input type="submit" name="Submit" value="Register">
</p>
</form>
</td>
</tr>
</table>