problem with login script, one line, full code
Posted: Sun Jan 18, 2004 5:37 am
mysql_fetch_array problems
i am having serious problems, i believe the script i am writing is correct but it keeps on coming up with a mysql error regarding mysql_fetch_array
problem with if/else regarding header redirection
this is the error message i get
single header
This is the error message i get
i am having serious problems, i believe the script i am writing is correct but it keeps on coming up with a mysql error regarding mysql_fetch_array
problem with if/else regarding header redirection
Code: Select all
<?php
$host = localhost;
$username = malcolmboston;
$password = xxxxx;
$database = malcolmbostonDB;
$table = login;
$connection = mysql_connect($host, $username, $password)
or die ();
$db = mysql_select_db("$database")
or die ();
$username = $_POST['username'];
$password = $_POST['password'];
$db_result = mysql_query("SELECT password FROM users WHERE username='$username'");
$db_password = mysql_fetch_array($db_result);
$db_password = $db_password['password'];
if (md5($password) == $db_password)
{
header("logged_in/index.html");
}
else
{
header("login_failed.html");
}
exit();
?>this is my preferred method of doing it however it wont let me due to the fact there are 2 'headers' is there anyway around this?Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\FoxServ\www\TDN-New\Scripts\check_login.php on line 7
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at PHPDocument1:16) in <b>PHPDocument1</b> on line <b>24</b><br />
single header
Code: Select all
<?php
$host = localhost;
$username = malcolmboston;
$password = xxxxxx;
$database = malcolmbostonDB;
$table = login;
$connection = mysql_connect($host, $username, $password)
or die ();
$db = mysql_select_db("$database")
or die ();
$username = $_POST['username'];
$password = $_POST['password'];
$db_result = mysql_query("SELECT password FROM users WHERE username='$username'");
$db_password = mysql_fetch_array($db_result);
$db_password = $db_password['password'];
if (md5($password) == $db_password)
{
header("logged_in/index.html");
}
else
{
print 'Unfortunately that username and password doesnt exist';
}
exit();
?>i would prefer not to use thisWarning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\FoxServ\www\TDN-New\Scripts\check_login.php on line 7