- Jan 21, 2005
- 17,722
- 6
- 81
Hopefully someone can help out with this. I've tried most of the solutions posted throughout the internet, but to no avail.
Error message returned:
Code:
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="funktrek"; // Database name
$tbl_name="users"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name");
// username and password sent from form
$myusername=$_POST['username'];
$mypassword=$_POST['password'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
// Register $myusername, $mypassword and redirect to file "login_success.php"
//session_register("myusername");
//session_register("mypassword");
header("location:login_success.php");
}
else { echo '<div align="center">Wrong Username or Password</div><br><div style="font-size: 10px;" align="center"><a href="login.php">Retry</a></div>'; }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Funk Trek</title>
</head>
<body>
</body>
</html>
I got rid of all the whitespace in it, because apparently that causes the scripts to break that call header(). No idea how to fix this though...any help appreciated, thanks!Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\funktrek\logincheck.php:1) in C:\wamp\www\funktrek\logincheck.php on line 28
Last edited:
