Hello,
Is it possible to put my php code in one file called process.php and the html code in a file called form.php if so can someone help me please.?
PHP Code:<?php
$button = null;
if (isset($_POST['button']))
{
$button = $_POST["button"];
}
if ($button)
{
//Get Data
$username = $_POST['username'];
$password = $_POST['password'];
$retypepassword = $_POST['retypepassword'];
$email = $_POST['email'];
if ($username && $password && $retypepassword && $email)
{
if ($password == $retypepassword)
{
if (strstr($email, ".") && strstr($email, "@"))
{
include ("connect.php");
$query = mysql_query ("SELECT * FROM users WHERE username='$username'");
$numrows = mysql_num_rows($query);
if ($numrows == 0)
{
$password = md5($password);
$insert = "INSERT INTO users VALUES('', '$username', '$password' , '$email')";
$register = mysql_query($insert) or die (mysql_error());
echo "You have been registered";
}
else
echo "That username is taken.";
}
else
echo "Not a vailid email address.";
}
else
echo "Passwords did not match";
}
else
echo "You did not fill in the entire form";
}
else
{
?>
<FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width='300'>
<tr>
<td align='right'>Username:</td>
<td align='left'><input type='text' name='username'></td>
</tr>
<tr>
<td align='right'>Password:</td>
<td align='left'><input type='password' name='password'></td>
</tr>
<tr>
<td align='right'>Retype Password:</td>
<td align='left'><input type='password' name='retypepassword'></td>
</tr>
<tr>
<td align='right'>Email</td>
<td align='left'><input type='text' name='email'></td>
</tr>
<tr>
<td align='right'></td>
<td align='left'><input type='submit' name='button' value='Register'></td>
</tr>
</table>
</form>
<?php
}
?>




Reply With Quote