I'm a PHP noob and i'm trying to make a login script for my site, I just added some session stuff in but its not working...
Heres my code:
and this is the error:
Any help greatly appreciated!
Heres my code:
Code:
1 <?
2 include("dbinfo.inc.php");
3
4 $email=$_POST['loginemail'];
5 $password=$_POST['loginpassword'];
6
7 mysql_connect($dbhost,$dbusername,$dbpassword);
8 @mysql_select_db($dbdatabase) or die( "Unable to select database");
9
10 $query = "SELECT * FROM users WHERE email='$email' AND password='$password'";
11 $result = mysql_query($query);
12
13 if (mysql_numrows($result) == 1) {
14 $loggedinuser = mysql_result($result,0,"id");
15 $userfirst = mysql_result($result,0,"first");
16 $userlast = mysql_result($result,0,"last");
17 $useremail = mysql_result($result,0,"email");
18 echo("Hi, $userfirst");
19
20 // create a new session
21 session_start();
22
23 $_SESSION['uid']=$loggedinuser;
24 $_SESSION['ufirst']=$userfirst;
25 $_SESSION['ulast']=$userlast;
26 $_SESSION['uemail']=$useremail;
27 }
28 else {
29 echo('error');
30 }
31
32 mysql_close();
33 ?>
and this is the error:
Code:
Hi, Andrew
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /Applications/xampp/xamppfiles/htdocs/calproject/login.php:18) in /Applications/xampp/xamppfiles/htdocs/calproject/login.php on line 21
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Applications/xampp/xamppfiles/htdocs/calproject/login.php:18) in /Applications/xampp/xamppfiles/htdocs/calproject/login.php on line 21
Any help greatly appreciated!