Fatal error
Posted: Wed Aug 12, 2009 7:55 am
Hello friends,
I am sure you will be fine.
Todays i am learning php and have made a simple login system:
here it is:
I have use a header in it which can redirect a user to guestbook.php but whenever user clear a cookies it send an error:
here it is:
I am sure you will be fine.
Todays i am learning php and have made a simple login system:
here it is:
Code: Select all
<?php
ob_start();
session_start();
include "./inc/functions.php";
include "./inc/connection.php";
echo css();
if ($_SESSION['logged'] == "yes") { //If session is true then redirect to guestbook.
header("Location: guestbook.php");
exit();
} else {
echo "<center>";
echo "<table border='1' width='50%'>";
echo "<form method='POST' action='login.php'>";
echo "<tr><td width='50%'><b>Username:</b></td><td width='50%'><input type='text' name='username' /></td></tr>";
echo "<tr><td width='50%'><b>Password:</b></td><td width='50%'><input type='password' name='password'></td></tr>";
echo "<tr><td width='50%'> </td><td width='50%'><b>Remember Me:</b><input type='checkbox' name='remember_me' value='on' /></td></tr>";
echo "<input type='hidden' name='post' value='true' />";
echo "<tr><td width='50%'> </td><td><input type='submit' value='Login' /></td></tr>";
echo "</form>";
echo "</table>";
echo "</center>";
//Now getting form values
if (isset($_POST['post'])) {
$username = cleanString($_POST['username']); //Getting username
$password = cleanString(md5($_POST['password'])); //Getting Password
$remember_me = $_POST['remember_me']; //Getting to create cookies
$query = "SELECT * FROM member WHERE username = '$username' AND password = '$password'";
$result = mysql_query($query);
if($remember_me == "on"){
setcookie("username",$username,time()+3600);
setcookie("password",$password,time()+3600);
}
$check_user = mysql_num_rows($result);
if ($check_user > 0) {
$_SESSION['logged'] = "yes";
$_SESSION['user'] = $username;
header("Location: guestbook.php");
exit();
}
else {
echo "<center><b>Wrong Username OR Password</b></center>";
exit();
}
}
}
ob_end_flush();
?>here it is:
Code: Select all
Fatal error: Cannot redeclare cleanstring() (previously declared in C:\xampp\htdocs\php\inc\functions.php:2) in C:\xampp\htdocs\php\inc\functions.php on line 7