Re: [PHP] Function Problem
Is that your functions.php?
Does header.php have a login function?
Just to be safe, do any other files have the login functon?
Re: [PHP] Function Problem
You already made a function named 'login()'. Therefor you cannot make it again. So either rename the second function or delete it / merge both functions together.
Re: [PHP] Function Problem
Lucky for you I have experience with that in PHP working with multiple modules and such and duplicate functions came up sometimes.
Try this,
PHP Code:
if(!function_exists(login))
{
function login()
{
//Define variables
$username = $_POST['username'];
$password = sha1($_POST['password']); // Encrypts the password.
$q = mysql_query("SELECT * FROM `users` WHERE username = '$username' AND password = '$password'");
if($q)
{
$check = mysql_num_rows($q);
}
if($check == 1)
{
while ($row = mysql_fetch_assoc($q))
{
$_SESSION['id'] = $row['ID'];
$_SESSION['loggedin'] = true;
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
Header("Location: index.php");
}
}
else
{
die("Wrong username or password");
}
}
}
function_exists() is a life-saver!
Re: [PHP] Function Problem
:o, didn't knew that one existed lol :P