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
6 1633
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
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:
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:
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 - <?php
-
require ("helplib.php");
-
connectdb();
-
-
session_start();
-
?>
-
-
-
<html>
-
<head>
-
<title>Staff</title>
-
<link rel="stylesheet" type="text/css" href="helpstyle.css">
-
-
<head>
-
-
<body>
-
<center>
-
<?php heading ("Staff Login");
-
-
$host="localhost";
-
$db_name="dbhelpdesk";
-
$tbl_name="tblstaff";
-
-
mysql_connect("$host", "root", "tmc")or die("cannot connect");
-
mysql_select_db("$db_name")or die("cannot select DB");
-
-
-
$staffID =isset($_POST['staffID']) ? $_POST['staffID'] :'';
-
$password =isset($_POST['password']) ? $_POST['password'] :'';
-
-
$sql ="SELECT * FROM tblstaff WHERE staffID='$staffID'and password='$password'";
-
$result=mysql_query($sql) or die ('no connection');
-
-
$count=mysql_num_rows($result);
-
-
if($count==1){
-
session_register("staffID");
-
session_register("password");
-
header("location:stafflog2.php");
-
}
-
else{
-
echo"Incorrect login staffID or password. Please try again";
-
}
-
?>
-
-
<table width="800" border="0" bordercolor="#660066" cellspacing="2" cellpadding="3">
-
<tr>
-
<form ACTION="stafflog.php" name="form1" METHOD="POST">
-
<td>
-
<table width="100%" border="0" bordercolor="#660066" cellspacing="5" cellpadding="3">
-
<tr>
-
<td colspan="3"bgcolor="#66cccc"><font color="#330099" size="4"><b>Staff Information<b></font></td>
-
</tr>
-
-
<tr>
-
<td width="78">StaffID</td>
-
<td width="8">:</td>
-
<td width="294"><input type="text" name="staffID" id="staffID"></td>
-
</tr>
-
-
<tr>
-
<td>Password</td>
-
<td>:</td>
-
<td><input type="password" name="password" id="password"></td>
-
</tr>
-
<tr>
-
<td> </td>
-
<td> </td>
-
<td colspan="2" width="8"><input type="submit" name="submit" value="Login"></td>
-
</tr>
-
</table>
-
</td>
-
</form>
-
</tr>
-
</table>
-
-
</center>
-
-
<?php footer (); ?>
-
-
</body>
-
</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
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:
Sign in to post your reply or Sign up for a free account.
Similar topics
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");
?>
|
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...
|
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...
|
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...
|
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 ...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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
|
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...
|
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...
|
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...
|
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,...
| |