When register.php finds an error, user input, it is displayed and the user is shown the form again.
I don't like how I am doing this and wanted to know if anyone has any suggestions on how to optimize this.
Code: Select all
<?php
include('config.php');
//Connect to database
if(user input is wrong){
$errormessage = $errormessage . "You did this wrong.<br>";
}
if(!(is_null($errormessage)))
{
?>
<html>
<body>
...
<p>
<?
echo $errormessage;
?>
</p>
<form>
<!-- TEXT BOXES AND STUFF -->
</form>
</body>
</html>
<?
exit();
}
$query = "INSERT FORM VALUES INTO TABLE";
mysql_query($query) or die(mysql_error());
mysql_close();
?>
<html>
<body>
...
<p>
THANK YOU FOR REGISTERING
</p>
<!-- No form needed, since registration was successful -->
</body>
</html>THANKS!