473,624 Members | 2,601 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 1751
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.sessio n-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.sessio n-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
3158
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 /home/krecik/public_html/silnik.php on line 251 Line 208: print ( "error: " . mysql_error()); Line 251: session_register("uprawnienia", "zalogowany"); I can understand that sth, is wrong in line 251 after line 208 and it is logical to
1
2952
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 "displaypreowned.php" that begins with "session_start()" and a few lines later have a line "include("databaseconnector.php")" and "include("stockdisplay.php")" which in themself also have "session_start()" in it. Don't know if
3
2859
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
3292
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: session_start(): read returned less bytes than requested in
8
1678
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 sent (output started at /www/html/app/includes/someincludescript.php:2) in /www/html/app/includes/session.php on line 3 The main script has
7
2024
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 site\adminlogin.php:3) in c:\program files\easyphp1-8\www\th site\access.inc.php on line Does anyone know what it means? I am trying to create a account logi and that warning comes up... Nothing bad happens. If anything doe anyone know how to suppress php from...
5
2171
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. Create a new C# ASP.NET web application named "demo" and modify Session_Start in Global.asax.cs as follows: protected void Session_Start(Object sender, EventArgs e) { Response.Write("Session_Start event fired at "+
2
1840
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 can not stop the error in my script. The session_start() is the first thing that happens before any Headers are created. Any one have any suggestions. Include the start of the code that uses the session var. Warning: session_start(): Cannot...
11
2305
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 password specified";}
3
1847
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 on line 104 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\Care2x\installer\Installer.php:104) in C:\Program Files\Apache...
0
8249
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8348
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7176
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4084
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1493
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.