Hello!
I'm Zazzycat. I'm extremely new at PHP, but I am not a complete n00b. I do understand mostly how it works and how to write simple things.
I am currently trying to get a register script for a virtual pet site to work. I copied the structure from a tutorial book and changed the fields to my needs. It is supposedly a single-page registration script, where once you click the register button it changes the page content, telling you either if you forgot something or if the registration worked.
The script isn't causing any errors but it's just not doing what I want. Instead of displaying results it just takes you back to the blank form when you click the register button.
Please note I am aware that the script is not doing anything with the server yet. I want to get the general frame working before I make it actually do something useful. For some reason either I or someone else popped the DBconnect include in there(can't quite remember), but I don't think it's supposed to do anything yet.
Here's the script:
<?
include 'dbconn.php' ;
if ($_POST) {
//empty error variable
$error = "" ;
//check for data in required fields
if (($username == "") ||
($email == "") ||
($password == "")) {
$error = "Please fill in all of the required fields." ;
}
// validate $email
if ((strpos($email, "@") === FALSE) ||
(strpos($email, ".") === FALSE) ||
(strpos($email, " ") != FALSE) ||
(strpos($email, "@") > strrpos($email, "."))) {
$error .= "Please enter a valid email address." ;
}
if ($error != "") {
echo "$error <p>Please click the back button and try again." ;
} else {
echo "<p><b>Username:</b> #username<br>" ;
echo "<b>Email:</b> #email<br>" ;
echo "<p><b>Password:</b> #password<br>" ;
}
} else {
?>
<form method="POST" action="<? echo $_SERVER['PHP_SELF'] ?>">
<table border="0" cellpadding="3" cellspacing="0">
<tr>
<td>Username:<br></td>
<td><input type="text" name"username" size="20" maxlength="12"></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name"email" size="20" maxlength="50"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name"password" size="20" maxlength="20"></td>
</tr>
<tr>
<td colspan="2">
<center><input type="SUBMIT" value="Register"></center>
</td>
</tr>
</table>
</form>
<?
}
?>
...and here's the output on the page:

It's probably something simple but like I said I am new at this.
If anyone could help me I would be extremely grateful!
~Zazzy