Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

Login problem

Question posted by: MissElegant (Newbie) on May 10th, 2008 04:51 PM
Hi everyBody,

Iam having a problem in the login..Tell me please what is the wrong. Is it in DB or PHP code?

DB:
Expand|Select|Wrap|Line Numbers
  1. -- Host: localhost
  2. -- Generation Time: May 10, 2008 at 08:50 PM
  3. -- Server version: 3.23.52
  4. -- PHP Version: 4.2.3
  5. -- 
  6. -- Database: `school`
  7. -- 
  8. -- --------------------------------------------------------
  9. -- 
  10. -- Table structure for table `users`
  11. -- 
  12. CREATE TABLE `users` (
  13.   `user` varchar(20) NOT NULL default '',
  14.   `password` varchar(30) NOT NULL default '',
  15.   PRIMARY KEY  (`user`)
  16. ) TYPE=MyISAM;
  17. --
  18. -- Dumping data for table `users`
  19. -- 
  20. INSERT INTO `users` VALUES ('sh', '123456');
  21. INSERT INTO `users` VALUES ('Fatima', '123456');

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <?
  4. $con = mysql_connect("localhost","", "");
  5. if (!$con) {
  6.     die('Could not connect ');
  7. }
  8. mysql_select_db("school", $con);
  9. $sql="SELECT  user,password FROM users WHERE user='$_POST[username]' AND password = '$_POST[password]'";
  10. $result = mysql_query($sql);
  11. $row=mysql_fetch_array($result);
  12. if($row[0] == "")   {
  13.        die('<h1>Wrong username  or password..Please insert the correct one..');
  14.  
  15. } else{
  16. session_start();
  17.     $_SESSION['username'] = $_POST['username'];
  18.     $_SESSION['passward'] = $row[0];
  19.     header("Location:Teacher buttons.htm");
  20. }
  21.  
  22. mysql_close($con);
  23. ?>
  24. </body>
  25. </html>
please Can you help me??
realin's Avatar
realin
Familiar Sight
249 Posts
May 10th, 2008
05:57 PM
#2

Re: Login problem
hiya MissElegant,

Welcome to bytes !!

what is the error this script is showing, and i believe your database has a default username and password which should be supplies while connecting and that should be more likely ::

Expand|Select|Wrap|Line Numbers
  1. mysql_connect("localhost","root","")


Rest if you can paste the error then it would be easier to help you out..
And please use proper tags (BBCODE) to enclose your code :)

thanks & Cheers !!

Reply
MissElegant's Avatar
MissElegant
Newbie
10 Posts
May 10th, 2008
08:27 PM
#3

Re: Login problem
Quote:
hiya MissElegant,

Welcome to bytes !!

what is the error this script is showing, and i believe your database has a default username and password which should be supplies while connecting and that should be more likely ::

Expand|Select|Wrap|Line Numbers
  1. mysql_connect("localhost","root","")


Rest if you can paste the error then it would be easier to help you out..
And please use proper tags (BBCODE) to enclose your code :)

thanks & Cheers !!

Thanks for welcoming :)
this is the error:

Warning: Cannot send session cookie - headers already sent by (output started at C:\www\e-school2\login.php:3) in C:\www\e-school2\login.php on line 25

Warning: Cannot send session cache limiter - headers already sent (output started at C:\www\e-school2\login.php:3) in C:\www\e-school2\login.php on line 25

Warning: open(/tmp\sess_98c6419df10071ce3f3d76284f45e79b, O_RDWR) failed: No such file or directory (2) in C:\www\e-school2\login.php on line 25

Warning: Cannot add header information - headers already sent by (output started at C:\www\e-school2\login.php:3) in C:\www\e-school2\login.php on line 28

Warning: open(/tmp\sess_98c6419df10071ce3f3d76284f45e79b, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

I don't know what is wrong about the code, I think the code is correct!!
What do you think..

Thanks

Reply
ronverdonk's Avatar
ronverdonk
Moderator
4,139 Posts
May 10th, 2008
10:26 PM
#4

Re: Login problem
WARNING:
Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR

Reply
realin's Avatar
realin
Familiar Sight
249 Posts
May 11th, 2008
07:51 AM
#5

Re: Login problem
Quote:
Thanks for welcoming :)
this is the error:

Warning: Cannot send session cookie - headers already sent by (output started at C:\www\e-school2\login.php:3) in C:\www\e-school2\login.php on line 25

Warning: Cannot send session cache limiter - headers already sent (output started at C:\www\e-school2\login.php:3) in C:\www\e-school2\login.php on line 25

Warning: open(/tmp\sess_98c6419df10071ce3f3d76284f45e79b, O_RDWR) failed: No such file or directory (2) in C:\www\e-school2\login.php on line 25

Warning: Cannot add header information - headers already sent by (output started at C:\www\e-school2\login.php:3) in C:\www\e-school2\login.php on line 28

Warning: open(/tmp\sess_98c6419df10071ce3f3d76284f45e79b, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

I don't know what is wrong about the code, I think the code is correct!!
What do you think..

Thanks


hi can you paste your code here..
Seems like you have given path to store session, also you can use output buffer to overcome the first error ..

Read more about ob_start here

Reply
MissElegant's Avatar
MissElegant
Newbie
10 Posts
May 11th, 2008
01:35 PM
#6

Re: Login problem
I am sorry I did not get the point!! Sorry again
....

Reply
Markus's Avatar
Markus
Moderator
2,214 Posts
May 11th, 2008
02:31 PM
#7

Re: Login problem
Quote:
I am sorry I did not get the point!! Sorry again
....


Have you rectified your problem then?

Reply
realin's Avatar
realin
Familiar Sight
249 Posts
May 11th, 2008
05:25 PM
#8

Re: Login problem
Quote:
I am sorry I did not get the point!! Sorry again
....


i meant, please post your code here ..
And dont forget to paste it into Php tags..

Reply
MissElegant's Avatar
MissElegant
Newbie
10 Posts
May 11th, 2008
06:23 PM
#9

Re: Login problem
I will next time..

regarding my login problem..,,, mmmm, I did not solve it yet, but iam trying

Reply
TheServant's Avatar
TheServant
Needs Regular Fix
462 Posts
May 11th, 2008
10:10 PM
#10

Re: Login problem
Quote:
I will next time..

regarding my login problem..,,, mmmm, I did not solve it yet, but iam trying


Well when you have tried what you can, and have a question, we need to see your code (in tags) and I'm sure we can help.

Reply
MissElegant's Avatar
MissElegant
Newbie
10 Posts
May 13th, 2008
02:42 PM
#11

Re: Login problem
you know guys, I solved the login problem ... FINALY..
but iam having another problem..:(

the login page is located in a frame, and when I login to the target page, this page doesn't appear in the same frame in frontpage.. I think the problem with secifing that in PHP code.. right?? i don't new

Reply
hsriat's Avatar
hsriat
Expert
1,470 Posts
May 13th, 2008
03:01 PM
#12

Re: Login problem
Quote:
you know guys, I solved the login problem ... FINALY..
but iam having another problem..:(

the login page is located in a frame, and when I login to the target page, this page doesn't appear in the same frame in frontpage.. I think the problem with secifing that in PHP code.. right?? i don't new


Use target attribute for that.

Reply
TheServant's Avatar
TheServant
Needs Regular Fix
462 Posts
May 13th, 2008
10:07 PM
#13

Re: Login problem
Quote:
you know guys, I solved the login problem ... FINALY..
but iam having another problem..:(

the login page is located in a frame, and when I login to the target page, this page doesn't appear in the same frame in frontpage.. I think the problem with secifing that in PHP code.. right?? i don't new


Can you post your solution so others can learn from this post. Cheers.

Reply
MissElegant's Avatar
MissElegant
Newbie
10 Posts
May 13th, 2008
10:58 PM
#14

Re: Login problem
This is the index page:
-------------------------------------------

Expand|Select|Wrap|Line Numbers
  1.  
  2. <html dir="rtl">
  3.  
  4. <head>
  5. <meta http-equiv="Content-Language" content="en-us">
  6. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  7.  
  8. <title>New Page 2</title>
  9. </head>
  10.  
  11. <frameset framespacing="0" border="0" frameborder="0" rows="220,*">
  12.     <frame name="banner" scrolling="no" noresize target="contents" src="up.htm">
  13.     <frameset cols="777,*">
  14.  
  15.         <frame name="contents" target="main" src="WelcomingPage.htm" scrolling="auto" noresize>
  16.         <frame name="main" scrolling="auto" src="new_page_1.htm" target="_self" noresize>
  17.     </frameset>
  18.     <noframes>
  19.     <body>
  20.     </body>
  21.     </noframes>
  22. </frameset>
  23.  
  24. </html>
  25.  


----------------------------------

This is the login page that will occurs in the contant frame after pressing on a button (that is in the index page)

-------------
Expand|Select|Wrap|Line Numbers
  1.  
  2. <html dir="rtl">
  3.  
  4. <head>
  5. <meta http-equiv="Content-Language" content="en-us">
  6. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  7.  
  8. <title>New Page 2</title>
  9. </head>
  10.  
  11. <frameset framespacing="0" border="0" frameborder="0" rows="220,*">
  12.     <frame name="banner" scrolling="no" noresize target="contents" src="up.htm">
  13.     <frameset cols="777,*">
  14.  
  15.         <frame name="contents" target="main" src="WelcomingPage.htm" scrolling="auto" noresize>
  16.         <frame name="main" scrolling="auto" src="new_page_1.htm" target="_self" noresize>
  17.     </frameset>
  18.     <noframes>
  19.     <body>
  20.     </body>
  21.     </noframes>
  22. </frameset>
  23.  
  24. </html>

--------------------------------

I want after the login of the user, showing a new page which is the teacher page in the same frame of the login page not in a new page(new window)...I do not know what is the problem...

This is the teacher page:
----------------------------

Expand|Select|Wrap|Line Numbers
  1.  
  2. <html dir="rtl">
  3.  
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
  6. <title>New Page 3</title>
  7.  
  8. <base target="_self">
  9. </head>
  10.  
  11. <body>
  12.  
  13. <form method="POST" action="logoutF.php" onSubmit="location.href='_derived/nortbots.htm';return false;" webbot-onSubmit>
  14.  
  15.     <div align="center">
  16.     <div align="right">
  17.         <table border="0" width="587" height="1" dir="rtl" id="table1">
  18.             <tr>
  19.                 <td height="161" width="581">
  20.                 <a target="contents" href="logoutF.php">
  21.                 <img border="0" src="images/logout.jpg" width="38" height="60" action= "logoutF.php" align="left"></a><p>&nbsp;</p>
  22.                 <p>&nbsp;</p>
  23.                 <p>&nbsp;</p>
  24.                 <p><b><span lang="ar-ae"><font size="6" color="#FF0000">اختاري 
  25.                 معلمتي أحد الخيارات الآتية:</font></span></b></p>
  26.                 <table border="1" width="100%" id="table2">
  27.                     <tr>
  28.                         <td>
  29.                         <p align="center">
  30.                         <a href="(Teacher)_Announcement_form.html">
  31.                         <img border="0" src="announcement.jpg" width="159" height="116"></a></td>
  32.                         <td>
  33.                         <p align="center">
  34.                         <img border="0" src="grade%20copy.jpg" width="159" height="116"></td>
  35.                     </tr>
  36.                 </table>
  37.                 </td>
  38.             </tr>
  39.         </table></div>
  40.     <p align="center">&nbsp;</div>
  41. </form>
  42.  
  43. <p>&nbsp;</p>
  44. <p></p>
  45.  
  46. </body>
  47.  
  48. </html>


Thanx .. hope you help me

Reply
Reply
Not the answer you were looking for? Post your question . . .
189,798 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top PHP Forum Contributors