| View previous topic :: View next topic |
| Author |
Message |
deleted user 111213 Grandmaster Cheater
Reputation: 0
Joined: 09 Nov 2007 Posts: 714
|
Posted: Fri Jan 23, 2009 3:46 am Post subject: anything wrong with this script? |
|
|
| Code: | <html>
<head>
<link rel="stylesheet" href="style3.css" type="text/css" />
<center><h1><font color="#CC0000">Login</font></h1></center>
<?php
include'./global.php';
session_start();
echo "<title>Login</title>\n";
echo "</head>";
if($_SESSION['uid']){
echo "<font color=\"#CC0000\">You are already logged in, if you wish to log out, please <a href='logout2.php'>click here</a></font>";
}else{
echo "<center>";
echo "<div id=\"holder\" align=\"left\">";
if(!$_POST['submit']){
echo "<table border='0' cellspacing='3'>\n";
echo "<form method='post' action='login2.php'>\n";
echo "<tr><td><font color=\"#CC0000\">Username: </font> </td><td><input type='text' name='username'></td></tr>\n";
echo "<tr><td><font color=\"#CC0000\">Password: </font></td><td><input type='password' name='password'></td></tr>\n";
echo "<tr><td colspan='2' align='right'><input type='submit' name='submit' value='Login!'></td></tr>\n";
echo "</form></table>\n";
echo "</div>";
echo "</center>";
}else{
$user = mss($_POST['username']);
$pass = $_POST['password'];
if($user && $pass){
$sql = "SELECT id FROM users WHERE username = '".$user."'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) > 0){
$sql2 = "SELECT id FROM users WHERE username='".$user."' AND password='".$pass."'";
$res2 = mysql_query($sql2);
if(mysql_num_rows($res2) > 0){
$row = mysql_fetch_assoc($res2);
$_SESSION['uid'] = $row['id'];
echo "<font color=\"CC0000\">You have successfully logged in as " . $user . "</font><br><br><a href='index.php'>Proceed to the forum's index page<a>\n";
}else{
echo "<font color=\"CC0000\">Username and password combination are incorrect!</font>\n";
}
}else{
echo "<font color=\"CC0000\">The username you supplied does not exist!</font>\n";
}
}else{
echo "<font color=\"CC0000\">You must supply both the username and the password in order to login!</font>\n";
}
}
}
?>
</html> |
cause i get the error
| Code: |
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /usr/home/matt/public_html/forum/login2.php:8) in /usr/home/matt/public_html/forum/login2.php on line 10 | and it will still let me login and stuff but i want to get rid of the error. |
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Fri Jan 23, 2009 2:57 pm Post subject: |
|
|
U have to get all the session set stuff before in <head> cause when it reaches body, the header is sent and u cant change it.
call session start before your html codes. |
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Fri Jan 23, 2009 3:41 pm Post subject: |
|
|
it's just like ,dnsi0, said. You cant modify a header after html is sent.
Allways start a session at the top of the page or before any html is sent.
Flushing the code might work too but even if it does it's not recomended. _________________
Intel over amd yes. |
|
| Back to top |
|
 |
deleted user 111213 Grandmaster Cheater
Reputation: 0
Joined: 09 Nov 2007 Posts: 714
|
Posted: Sat Jan 24, 2009 6:19 am Post subject: |
|
|
| thanks, no more errors now. |
|
| Back to top |
|
 |
|