473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Errors in my login script

7
i want to make login for my php,by using staffID and password.

password and staffID actually must be found in tblStaff ( database table name)

so when i click 'submit' , it would retrive to tblStaff,to make sure that there is password and staffID in the list of tblstaff

if correct,then staff can add,delete and edit list,if not then show valid staffid and pasword

and for the session variable for staffid must start with 2 uppercase letters 'ST' followed by 3 digit

password must be alphanumeric, minimun 3 characters and max 10

and i want only type='A' that can delete,edit and add the list staff


thanks
Oct 6 '06 #1
6 1633
irin07
7
but still there's an error
i try to create a login in php

maybe u can try to find what is the error in this code


stafflog.php

Code:
<?php
require ("helplib.php");
connectdb();

session_start();
session_destroy();

?>

<html>
<head>
<title>Staff and Tickets Information</title>
<link rel="stylesheet" type="text/css" href="helpstyle.css">

<head>

<body>
<center>

<?php heading ("Staff and Tickets Information"); ?>

<br>
<table width="70%" border="2" cellspacing="6" cellpadding="15" bordercolor="#660066">
<tr align="center">
<td><h2><a href="staff2.php">Staff Information</a></td>
</tr>
<tr align="center">
<td><h2><a href="tickets2.php">Tickets Information</h2></a></td>
</tr>
</table>
</form>
</center>
<br><br>

<a href="index.php">Log out</a>

<?php footer (); ?>
</body>
</html>



stafflog2.php


Code:
<?php
require ("helplib.php");
connectdb();

session_start();
session_destroy();

?>

<html>
<head>
<title>Staff and Tickets Information</title>
<link rel="stylesheet" type="text/css" href="helpstyle.css">

<head>

<body>
<center>

<?php heading ("Staff and Tickets Information"); ?>

<br>
<table width="70%" border="2" cellspacing="6" cellpadding="15" bordercolor="#660066">
<tr align="center">
<td><h2><a href="staff2.php">Staff Information</a></td>
</tr>
<tr align="center">
<td><h2><a href="tickets2.php">Tickets Information</h2></a></td>
</tr>
</table>
</form>
</center>
<br><br>

<a href="index.php">Log out</a>

<?php footer (); ?>
</body>
</html>


checklogin.php

Code:
<?php

$host="localhost";
$staffID="root";
$password="tmc";
$db_name="dbhelpdesk";
$tbl_name="tblstaff";

mysql_connect("$host", "$staffID", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");


$mystaffID =isset($_POST['mystaffID']) ? $_POST['mystaffID'] :'';
$mypassword =isset($_POST['mypassword']) ? $_POST['mypassword'] :'';

$sql ="SELECT * FROM $tbl_name WHERE staffID='$mystaffID' and password='$mypassword'";
$result=mysql_query($sql);

$count=mysql_num_rows($result);

if ($count==1){
session_register("mystaffID");
session_register("mypassword");
header("location:login_success.php");
}
else{
echo"Valid staffID or password";
}


?>


login_success.php


Code:
<? php
session_start();
if(!session_is_registered(mystaffID))
?>

<html>
<head>
<title>Check</title>
</head>
<body>
<a href="stafflog2.php">Go To List </a>

Login Successful
</body>
</html>


password and staffID actually must be found in tblStaff (in database mysql)

so when i click 'submit' , it would retrive to tblStaff,

if correct,it will show the tblstaff,if not then show valid staffid and pasword

now the error is when i click 'submit' the error msg say that the page cannot be found

and if i want to put session variable for password and staffID, where should i put the code???

thanks
Oct 6 '06 #2
ronverdonk
4,258 Expert 4TB
You could start with putting your code within php or code tags. That would make it at least more readable. The way it shows now is a mess.

Ronald :cool:
Oct 7 '06 #3
irin07
7
stafflog.php

Code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require ("helplib.php");
  3. connectdb();
  4.  
  5. session_start();
  6. session_destroy();
  7.  
  8. ?>
  9.  
  10. <html>
  11. <head>
  12. <title>Staff and Tickets Information</title>
  13. <link rel="stylesheet" type="text/css" href="helpstyle.css">
  14.  
  15. <head>
  16.  
  17. <body>
  18. <center>
  19.  
  20. <?php heading ("Staff and Tickets Information"); ?>
  21.  
  22. <br>
  23. <table width="70%" border="2" cellspacing="6" cellpadding="15" bordercolor="#660066">
  24. <tr align="center">
  25. <td><h2><a href="staff2.php">Staff Information</a></td>
  26. </tr>
  27. <tr align="center">
  28. <td><h2><a href="tickets2.php">Tickets Information</h2></a></td>
  29. </tr>
  30. </table>
  31. </form>
  32. </center>
  33. <br><br>
  34.  
  35. <a href="index.php">Log out</a>
  36.  
  37. <?php footer (); ?>
  38. </body>
  39. </html>
  40.  

stafflog2.php


Code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require ("helplib.php");
  3. connectdb();
  4.  
  5. session_start();
  6. session_destroy();
  7.  
  8. ?>
  9.  
  10. <html>
  11. <head>
  12. <title>Staff and Tickets Information</title>
  13. <link rel="stylesheet" type="text/css" href="helpstyle.css">
  14.  
  15. <head>
  16.  
  17. <body>
  18. <center>
  19.  
  20. <?php heading ("Staff and Tickets Information"); ?>
  21.  
  22. <br>
  23. <table width="70%" border="2" cellspacing="6" cellpadding="15" bordercolor="#660066">
  24. <tr align="center">
  25. <td><h2><a href="staff2.php">Staff Information</a></td>
  26. </tr>
  27. <tr align="center">
  28. <td><h2><a href="tickets2.php">Tickets Information</h2></a></td>
  29. </tr>
  30. </table>
  31. </form>
  32. </center>
  33. <br><br>
  34.  
  35. <a href="index.php">Log out</a>
  36.  
  37. <?php footer (); ?>
  38. </body>
  39. </html>
  40.  
checklogin.php

Code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $host="localhost";
  4. $staffID="root";
  5. $password="tmc";
  6. $db_name="dbhelpdesk";
  7. $tbl_name="tblstaff";
  8.  
  9. mysql_connect("$host", "$staffID", "$password")or die("cannot connect");
  10. mysql_select_db("$db_name")or die("cannot select DB");
  11.  
  12.  
  13. $mystaffID =isset($_POST['mystaffID']) ? $_POST['mystaffID'] :'';
  14. $mypassword =isset($_POST['mypassword']) ? $_POST['mypassword'] :'';
  15.  
  16. $sql ="SELECT * FROM $tbl_name WHERE staffID='$mystaffID' and password='$mypassword'";
  17. $result=mysql_query($sql);
  18.  
  19. $count=mysql_num_rows($result);
  20.  
  21. if ($count==1){
  22. session_register("mystaffID");
  23. session_register("mypassword");
  24. header("location:login_success.php");
  25. }
  26. else{
  27. echo"Valid staffID or password";
  28. }
  29.  
  30.  
  31. ?>
  32.  
login_success.php


Code:
Expand|Select|Wrap|Line Numbers
  1. <? php
  2. session_start();
  3. if(!session_is_registered(mystaffID))
  4. ?>
  5.  
  6. <html>
  7. <head>
  8. <title>Check</title>
  9. </head>
  10. <body>
  11. <a href="stafflog2.php">Go To List </a>
  12.  
  13. Login Successful
  14. </body>
  15. </html>
  16.  

password and staffID actually must be found in tblStaff (in database mysql)

so when i click 'submit' , it would retrive to tblStaff,

if correct,it will show the tblstaff,if not then show valid staffid and pasword

now the error is when i click 'submit' the error msg say that the page cannot be found

and if i want to put session variable for password and staffID, where should i put the code???
Oct 8 '06 #4
ronverdonk
4,258 Expert 4TB
1. what is the purpose of session_start(); and session_destroy(); right after each other?
2. your stafflog.php and stafflog2.php code look identical to me.
3. I don't see any <form> (I see a </form>) and I don't see any submit button.

Ronald :cool:
Oct 9 '06 #5
irin07
7
1. what is the purpose of session_start(); and session_destroy(); right after each other?
2. your stafflog.php and stafflog2.php code look identical to me.
3. I don't see any <form> (I see a </form>) and I don't see any submit button.

Ronald :cool:
ooppsss...sorry. i post wronly,t\ the code for stafflog.php
shld be this

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require ("helplib.php");
  3. connectdb();
  4.  
  5. session_start();
  6. ?>
  7.  
  8.  
  9. <html>
  10. <head>
  11. <title>Staff</title>
  12. <link rel="stylesheet" type="text/css" href="helpstyle.css">
  13.  
  14. <head>
  15.  
  16. <body>
  17. <center>
  18. <?php heading ("Staff Login"); 
  19.  
  20. $host="localhost";
  21. $db_name="dbhelpdesk";
  22. $tbl_name="tblstaff";
  23.  
  24. mysql_connect("$host", "root", "tmc")or die("cannot connect");
  25. mysql_select_db("$db_name")or die("cannot select DB");
  26.  
  27.  
  28. $staffID =isset($_POST['staffID']) ? $_POST['staffID'] :'';
  29. $password =isset($_POST['password']) ? $_POST['password'] :'';
  30.  
  31. $sql ="SELECT * FROM tblstaff WHERE staffID='$staffID'and password='$password'";
  32. $result=mysql_query($sql) or die ('no connection');
  33.  
  34. $count=mysql_num_rows($result);
  35.  
  36. if($count==1){
  37.     session_register("staffID");
  38.     session_register("password");
  39. header("location:stafflog2.php");
  40. }
  41. else{
  42.     echo"Incorrect login staffID or password. Please try again";
  43.     }
  44. ?>
  45.  
  46. <table width="800" border="0" bordercolor="#660066" cellspacing="2" cellpadding="3">
  47. <tr>
  48. <form ACTION="stafflog.php"  name="form1" METHOD="POST">
  49. <td>
  50. <table width="100%" border="0" bordercolor="#660066" cellspacing="5" cellpadding="3">
  51. <tr> 
  52.    <td colspan="3"bgcolor="#66cccc"><font color="#330099" size="4"><b>Staff Information<b></font></td>
  53. </tr>
  54.  
  55. <tr> 
  56.    <td width="78">StaffID</td>
  57.    <td width="8">:</td>
  58.    <td width="294"><input type="text" name="staffID" id="staffID"></td>
  59. </tr>
  60.  
  61. <tr>
  62.    <td>Password</td>
  63.    <td>:</td>
  64.    <td><input type="password" name="password" id="password"></td>
  65. </tr>
  66. <tr>
  67. <td>&nbsp;</td>
  68. <td>&nbsp;</td>
  69. <td colspan="2" width="8"><input type="submit" name="submit" value="Login"></td>
  70. </tr>
  71. </table>
  72. </td>
  73. </form>
  74. </tr>
  75. </table>
  76.  
  77. </center>
  78.  
  79. <?php footer (); ?>
  80.  
  81. </body>
  82. </html>
now i try to put the php and html to 1 page...
but i still find the error

this my error msg

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\xitami-24\app\webpages\php3\helplib.php:42) in C:\xitami-24\app\webpages\php3\stafflog.php on line 5

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\xitami-24\app\webpages\php3\helplib.php:42) in C:\xitami-24\app\webpages\php3\stafflog.php on line 5
Oct 10 '06 #6
ronverdonk
4,258 Expert 4TB
You probably do some header things in "helplib.php" and/or in the "connectdb();" call. The session_start() should definitely be at the start of each script.

Ronald :cool:
Oct 10 '06 #7

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

Similar topics

3
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"); ?>
1
by: Paul | last post by:
Background: I wrote an ASP.NET website in C# and it went into production back in February 2004. The production webservers (2 servers using sticky-ip load balancing) are running on Windows 2000...
1
by: Mind Dragon | last post by:
I have an ASP application that works fine locally but when it's uploaded occasionally, I get viewstate errors. Another thing is that the viewstate for that page is disabled. There are cases where I...
1
by: dhyder | last post by:
OK, like the title says my error is Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. I have looked into this a lot, but have not...
2
by: MDANH2002 | last post by:
Hi From VB.NET I want to simulate the POST request of the following HTML form <html> <title>HTTP Post Testing</title> <body> <form action=http://www.example.com/postdata ...
3
by: Alan M Dunsmuir | last post by:
I'm using Kate in Linux (and UltraEdit when I have to drop back into Windows) for writing my PHP code. As a independent, self-employed developer, I cannot afford a commercial IDE for PHP such as is...
4
by: cyberlei | last post by:
hi all, I`m getting this error Notice: Undefined index: user in c:\inetpub\wwwroot\login.php on line 96 Notice: Undefined variable: message in c:\inetpub\wwwroot\login.php on line 101 Could...
3
by: satishknight | last post by:
Hi, Can some one tell me how to change the validation sequence for the code pasted below, actually what I want it when any one enters the wrong login information (already registered users) then it...
4
by: K Viltersten | last post by:
We have a project working well today and it's developed on VS2005. Since we're planing to switch to VS2008 in a soon future, i've been trying to move the project to VS2008 Express (Web...
4
by: kimiraikkonen | last post by:
Hi, Just to test, i placed a simple webbrowser to login a site, this site has no problems and has same error with IE6 SP2 but it's suppressed as well and no problem with Firefox browser, but using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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,...

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.