Upon opening the page nothing happens, its just blank the form does not get displayed.
Before we go any were lets address that. Put
error_reporting(E_ALL);
at the very top of any page you are working on it will ensure all errors are reported so you can more easily find the problem.
Next this
$value = mysql_real_escape_string(value);
need the "$" in friont of the "value"
Then in this line
$day = $_POST['gender'];
"$day" should be "$gender"
Then in this
$action = $_REQUEST['act'];
protect($action);
the second line does nothing. Try this
$action = protect($_REQUEST['act']);
also note that "act" is not set anywhere in your form. And really I suspect the above lines are not needed (see last code example).
The "$echoconf" in this line is not set anywhere in your code
if($email != $echoconf){
The
$sql = "SELECT * FROM 'users' WHERE 'ip' ='$_SERVER[REMOTE_ADDR]'";
should be
$sql = "SELECT * FROM `users` WHERE `ip` ='" . $_SERVER['REMOTE_ADDR'] . "'";
I will note here that the IP address check may cause you trouble. Most ISP's will have a limited block of IP address to assign their customer, usually less IP's than they have customers. They regular have to reassign an IP address so that check may cause all sorts of issues.
Beyond all that your HTML is missing a ton of closing tags. It is a good habit to close ALL HTML tags. Good readability formatting helps find missing closing tags
Also there are several other things that could be done. Below is a rework of your code that does the same thing you had but with most of the errors fixed. If you study it you may find a lot of helpful tips.
<?php
error_reporting(E_ALL);
require("db_connect.php");
function protect($value) {
$value = stripslashes($value);
$value = strip_tags($value);
$value = mysql_real_escape_string($value);
return $value;
}
if (!isset($_POST['act'])) {
?>
<table border="0" cellspacing="3" cellpadding="3">
<form name="register" method="post" action="register.php?act=register">
<tr>
<td>Username:</td>
<td><input type="text" name="username" maxlength="32" />
</td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" maxlength="64" /></td>
</tr>
<tr>
<td>Confirm:</td>
<td><input type="password" name="passconf" maxlength="64" /></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Confirm:</td>
<td><input type="text" name="econf"></td>
</tr>
<tr>
<td>Gender</td>
<td>
<select name="gender">
<option value="male">Male</option>
<option value="female">Female</option>
</select>
</td>
</tr>
<td>Your Name</td>
<td><input type="text" name="name" maxlength="32" />
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="act" value="Register" /></td>
</tr>
</form>
</table>
<?php
}
else {
$username = protect($_POST['username']);
$password = protect($_POST['password']);
$passconf = protect($_POST['passconf']);
$email = protect($_POST['email']);
$econf = protect($_POST['econf']);
$gender = protect($_POST['gender']);
$name = protect($_POST['name']);
$error = '';
if (!isset($username) || strlen($username) < 3 || strlen($username) > 32) {
$error .= 'Username is either too short or too long<br/>';
}
if (!isset($password) || strlen($password) < 3 || strlen($password) > 64) {
$error .= 'Password is either too short ot too long<br/>';
}
if ($password != $passconf) {
$error .= 'Your password do not match<br/>';
}
if (!isset($email) || strlen($email) < 3 || strlen($email) > 64) {
$error .= 'Email is either too short ot too long<br/>';
}
if ($email != $econf) {
$error .= 'Your emails do not match<br />';
}
$checkemail = "/*[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]-)+\\.(a-z)(2;)$/";
if(!preg_match($checkemail,$email)) {
$error .= 'The email you entered is incorrect<br/>';
}
if (!isset($name) || strlen($name) < 2 || strlen($name) > 64) {
$error .= 'Your name is either too short or too long<br/>';
}
$sql = "
SELECT *
FROM `users`
WHERE `username` = '$username' OR `email` = '$email'
";
$res = mysql_query($sql) or $error .= 'Query Failed' . mysql_error();
if (mysql_num_rows($res) != 0) {
while ($row = mysql_fetch_array($res)) {
if ($row['username'] == $username) {
$error .= 'This username already exists<br/>';
}
if ($row['email'] == $email) {
$error .= 'The email you supplied is already in use<br/>';
}
}
}
if ($error == '') {
$password = mds($password);
$date = date('f j, Y @ g:i:s a');
$sql = "
INSTER INTO `users` (`username`, `password`, `email`, `ip`, `name`, `gender`, `date`)
VALUES('$username', '$password, '$email', '" . $_SERVER['REMOTE_ADDR'] . "', '$gender', '$date')
";
if (mysql_query($sql)) {
echo 'Thank you for registering, you may now log in<br/>';
}
else {
echo 'Insert Query Failed' . mysql_error();
}
}
else {
echo $error;
}
}
?>
I can't say for certain if it will work as there may be other factors not present in your original code but I hope it helps