I made the changes that were suggested but still no luck, whenever i try to execute the login command, i am only presented with the login box again, without formatting, and no user is created. I have tried other scripts with no luck.
HELP i dont really know what to do or what is wrong!!
here is my code
<***************************************
index.php
<form method=post action='user_login.php'>
<table cellspacing=0 cellpadding=0 width=100%>
<tr>
<td class='menu_right_header'>
<b>Login</b>
</td>
</tr>
<tr>
<td class='menu_right'>
<table style='margin-bottom: 0px;'>
<tr>
<td class='form' width='65'>name:</td>
<td class='form'><input name=name_input type=text value='' size=16 maxlength=20>
</td>
</tr>
<tr>
<td class='form' width='65'>password:</td>
<td class='form'><input name=password_input type=password size=16 maxlength=20></td>
</tr>
<tr>
<td colspan=2 class='form'><input name=submit_login type=submit value=login></td>
</tr>
</table>
<br>
:<a href='index.php?user=register'>click here to register</a>:
</td>
</tr>
</table>
</form>
***************************************>
<***************************************
user_login.php
<?php
if (isset ($_POST["submit_login"])) {
include "connect.php";
$query = "SELECT id,password FROM users WHERE name='$name_input'";
$exec = mysql_query($query);
$name_check = mysql_num_rows($exec);
if ($name_check == '1') {
$result = mysql_fetch_array($exec);
$id = $result["id"];
$password_check = $result["password"];
if ($password_check == $password_input) {
setcookie("loggedin_id", $id, time() + 1512000);
session_unregister("lastvisit");
if (isset ($login_http_referer)) {
$url = $login_http_referer;
session_unregister("login_http_referer");
}
else {
$url = $HTTP_REFERER;
}
if (isset ($login_name_input)) {
session_unregister("login_name_input");
}
echo "<script>location.href='$url'</script>";
}
else {
session_start();
session_register("login_name_input");
$login_name_input = $name_input;
session_register("login_http_referer");
$login_http_referer = $HTTP_REFERER;
$url = 'index.php?error=2';
echo "<script>location.href='$url'</script>";
}
}
else {
session_start();
session_register("login_http_referer");
$login_http_referer = $HTTP_REFERER;
$url = 'index.php?error=1';
echo "<script>location.href='$url'</script>";
}
}
else {
if (isset ($login_name_input)) {
$login_name_input = $login_name_input;
session_unregister("login_name_input");
}
else {
$login_name_input = "";
}
echo "<form method=post action='user_login.php'>
<table cellspacing=0 cellpadding=0 width=100%>
<tr>
<td class='menu_right_header'>
<b>Login</b>
</td>
</tr>
<tr>
<td class='menu_right'>
<table style='margin-bottom: 0px;'>
<tr>
<td class='form' width='65'>name:</td>
<td class='form'><input name=name_input type=text value='$login_name_input' size=16 maxlength=20>
</td>
</tr>
<tr>
<td class='form' width='65'>password:</td>
<td class='form'><input name=password_input type=password size=16 maxlength=20></td>
</tr>
<tr>
<td colspan=2 class='form'><input name=submit_login type=submit value=login></td>
</tr>
</table>
<br>
:<a href='index.php?user=register'>click here to register</a>:
</td>
</tr>
</table>
</form>
";
}
?>
***************************************>
<*************************************
connect.php
<?php
mysql_connect ('127.0.0.1','','');
mysql_select_db ('test_db');
?>