Newbie - Code Optimization
Posted: Wed Aug 30, 2006 10:02 am
I have a html document, register.html, which has a form on it. The form calls register.php to insert the form values into my database.
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.
If you don't understand the code; I'll be more then glad to elaberate.
THANKS!
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!