473,499 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error on Session_Start()

4 New Member
I am kind of new on PHP. I could not figure out what went wrong on my ph.

Here is code:
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.  
  3. include 'dbc.php';
  4.  
  5. $user_email = mysql_real_escape_string($_POST['email']);
  6.  
  7. if ($_POST['Submit']=='Login')
  8. {
  9. $pass = $_POST['pwd'];
  10. $sql = "SELECT id,user_email FROM rmusers WHERE 
  11.             user_email = '$user_email' AND 
  12.             user_pwd = '$pass' AND user_activated='1'"; 
  13.  
  14. $result = mysql_query($sql) or die (mysql_error()); 
  15. $num = mysql_num_rows($result);
  16.  
  17. if ( $num != 0 ) { 
  18.  
  19.         // A matching row was found - the user is authenticated. 
  20.  
  21.        session_start(); 
  22.  
  23.        list($user_id, $user_email) = mysql_fetch_row($result);
  24.         // this sets variables in the session 
  25.         $_SESSION['user']= $user_email;  
  26.  
  27.  
  28.         if (isset($_GET['ret']) && !empty($_GET['ret']))
  29.         {
  30.         header("Location: $_GET[ret]");
  31.         } else
  32.         {
  33.         header("Location: myaccount.php");
  34.         }
  35.         //echo "Logged in...";
  36.         exit();
  37.  
  38.         header("Location: myaccount.php"); 
  39.         } 
  40.  
  41.  
  42. header("Location: login.php?msg=Invalid Login");
  43. echo "Error:";
  44. exit();        
  45. }
  46.  
  47. ?>
  48.  
  49. <link href="styles.css" rel="stylesheet" type="text/css">
  50.  
  51. <?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?>
  52.  
  53.  
  54. <p>&nbsp;</p><table width="40%" border="0" align="center" cellpadding="0" cellspacing="0">
  55.   <tr> 
  56.     <td bgcolor="#d5e8f9" class="mnuheader" >
  57. <div align="center"><font size="5"><strong>Login 
  58.         Members</strong></font></div></td>
  59.   </tr>
  60.   <tr> 
  61.     <td bgcolor="#e5ecf9" class="mnubody"><form name="form1" method="post" action="">
  62.         <p>&nbsp;</p>
  63.         <p align="center">Your Email 
  64.           <input name="email" type="text" id="email">
  65.         </p>
  66.         <p align="center"> Password: 
  67.           <input name="pwd" type="password" id="pwd">
  68.         </p>
  69.         <p align="center"> 
  70.           <input type="submit" name="Submit" value="Login">
  71.         </p>
  72.         <p align="center"><a href="register.php">Register</a> | <a href="forgot.php">Forgot</a></p>
  73.       </form></td>
  74.   </tr>
  75. </table>

Hope you can tell me what did I do wrong.
Jan 7 '09 #1
6 1738
Markus
6,050 Recognized Expert Expert
Can you please let us know what error you receive?
Jan 7 '09 #2
microguy
4 New Member
Here are errors



Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/mysimon/public_html/deaflds/test2/dbc.php:20) in /home/mysimon/public_html/deaflds/test2/login.php on line 21

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/mysimon/public_html/deaflds/test2/dbc.php:20) in /home/mysimon/public_html/deaflds/test2/login.php on line 21

Warning: Cannot modify header information - headers already sent by (output started at /home/mysimon/public_html/deaflds/test2/dbc.php:20) in /home/mysimon/public_html/deaflds/test2/login.php on line 33
Jan 7 '09 #3
Dormilich
8,658 Recognized Expert Moderator Expert
have a look at dbc.php line 20, there must be some kind of output which causes the errors.
Jan 7 '09 #4
microguy
4 New Member
there is nothing on line 20

here is my code
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. //Database Information
  4.     $dbhost = "localhost";
  5.     $dbname = "xxxxxxx";
  6.     $dbuser = "xxxxxxxxx";
  7.     $dbpass = "xxxxxxxx";
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. // $link = mysql_connect("localhost","root","") or die("Couldn't make connection.");
  15. $link = mysql_connect ($dbhost, $dbuser, $dbpass)or die("Could not connection. ");
  16.  
  17. $db = mysql_select_db($dbname, $link) or die("Couldn't select database");
  18. ?>
Jan 7 '09 #5
microguy
4 New Member
I got it working now. There were space on line 20. Right now I have login page with two button for register and forgot. When we click on register or forgot it goes to another page. I did not want that. When click on forgot and I want email address box with subit box show up on same page. How do we do that? Like hide the address box and submit button till click on forgot then it will show up. Something like that. Can someone tell me the codes?
Jan 7 '09 #6
Atli
5,058 Recognized Expert Expert
Glad you got it working.
@microguy
That would be a job for JavaScript.
Try posting this question in a new thread in the JavaScript forum.
Jan 7 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

11
3133
by: Maciej Nadolski | last post by:
Hi! I can`t understand what php wants from me:( So: Cannot send session cache limiter - headers already sent (output started at /home/krecik/public_html/silnik.php:208) in...
1
2943
by: Titus | last post by:
Hi, Just received the following error upon running some scripts that utilize sessions. Don't know what it means by "cache limiter". Can someone please clarify? I have a script called...
3
2833
by: koolyio | last post by:
Hey, could you please tell me what is wrong with my login script. I just started learning php. CODE: login.php <? session_start(); header("Cache-Control: private"); ?>
4
3284
by: K. Choi | last post by:
I had installed php 4.3.7 on my system and test some php code. But there is a serious problem. On my system(using apache2) the code, <?php session_start(); ?> gets some warning, Warning:...
8
1673
by: STEPHEN GOODE | last post by:
I am getting the following error. I've changed the paths and file names here to protect my client's confidentiality. Warning: session_start(): Cannot send session cache limiter - headers already...
7
2013
by: y_oda2002 | last post by:
I keep getting an error that says this Warning: session_start(): Cannot send session cache limiter - header already sent (output started at c:\program files\easyphp1-8\www\th...
5
2158
by: Niklas Uhlin | last post by:
Someone please explain why Session_Start fires multiple times / retains SessionID values between sessions, when you open an ASP.NET page from MS Word. For details of the problem, see below: 1....
2
1833
by: IchBin | last post by:
I am getting the error message below when ever I try to start my script on two different servers. I am not getting any errors off of my PC. I have looked around and found the answer a simple one. I...
11
2294
by: mishrarajesh44 | last post by:
i am facing problem in php session.. my code is giving error.. i am giving my code and error message below.. my code:- <?php if(isset($_POST)) { if(empty($password)){echo "No...
3
1844
by: sudhakarsh | last post by:
Warning: session_start(): open(/tmp\sess_bd6e0da1ed76c6b86f102376e2efb508, O_RDWR) failed: No such file or directory (2) in C:\Program Files\Apache Group\Apache2\htdocs\Care2x\installer\Installer.php...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5467
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4917
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.