Can anyone tell me what I am doing wrong? I have a php file called 'register.php' that I would like to use to pass a series of actions to it for creating entries in the database, login queries to the database, and for creating new accounts. There are a number of redirect pointers (i.e. for the signup, it should just redirect the user to the newacct.html page).
Currently when I test this, the browser just sits there turning away.
Form html for testing:
<form method=POST action=register.php?action=login>
<input name=user>
<br><input name=pass type=password>
<br><button type=submit value="Existing Accounts">
</form>
<form method=POST action=register.php?action=signup>
<br><button type=submit value="New Accounts">
</form>
register.php code follows...
<?php
if ($_POST['user'] == '') {
header("Location: register.php?action=signup");
} else {
$user = $_POST['user'];
}
if ($_POST['pass'] == '') {
header("Location: register.php?action=signup");
} else {
if ($POST['pass'] == $POST['retypedpass']) {
$pass = $_POST['pass'];
} else {
header("Location: register.php?action=signup");
}
if ($pass = '') { $pass = $_POST['pass']; }
}
require_once('dbaccess.php');
$action = $_REQUEST['action'];
if ($action == '') { $action = "login"; }
if ($action == 'login') {
$user = $POST['email'];
$pass = $POST['password'];
$result = mysql_query("SELECT * FROM accounts WHERE email='$user' AND password='$pass'");
$nor = @mysql_num_rows($result);
if ($nor == 0) {
echo "<script>window.url.href='newacct.html'</script>";
} else {
echo "<script>window.url.href='member.php'</script>";
}
} else if ($action == 'signup') {
echo "<script>window.url.href='newacct.html'</script>";
} else if ($action == 'create') {
$user = $POST['email'];
$pass = $POST['password'];
$country = $_POST['country'];
$res = mysql_query("SELECT * FROM table WHERE user='$user'");
$nor = @mysql_num_rows($res);
if ($nor != 0) {
echo "Username already exists";
} else {
mysql_query("INSERT INTO table(user, pass, country) VALUES('$user', '$pass', '$country')");
$_SESSION['user'] = $user;
echo "<script>window.url.href='member.php'</script>";
}
}
?>