/    Sign up×
Community /Pin to ProfileBookmark

Help me plz….URGENT

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

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@netbuddyOct 06.2006 — Ok, thats fine, many in this forum may be able to help you but what have you done sofar to help yourself?

If you search for login scripts, you may find an existing thread that can walk you through it.

So please post any code you have so far so people can help you, you may get lucky and someone may write just what you want...
Copy linkTweet thisAlerts:
@bella07authorOct 06.2006 — 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>

[/CODE]


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>

[/CODE]


checklogin.php
<i>
</i>&lt;?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";
}


?&gt;


loginsuccess.php
<i>
</i>&lt;? php
session_start();
if(!session_is_registered(mystaffID))
?&gt;

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Check&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;a href="stafflog2.php"&gt;Go To List &lt;/a&gt;

Login Successful
&lt;/body&gt;
&lt;/html&gt;



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
Copy linkTweet thisAlerts:
@netbuddyOct 06.2006 — I can see </form> bur no opening <form method="post" action="whatscripttocall.php?anyparameterstopass">

Im not sure if this is correct...

[code=php]session_start();
session_destroy();[/code]


and as far as I can remember, the session_start() should be the very first item the PHP parser should come across, eg...

[code=php]<?php
session_start();[/code]


You can check if a form is present by using [code=php]if(isset($_POST['Submit'])){ // form present ! do something
...
} else { // do this as no form present
...
}[/code]
Copy linkTweet thisAlerts:
@bella07authorOct 07.2006 — i still get the error "page cant be found"

is it i put this code:

if(isset($_POST['Submit'])){ // form present ! do something

...

} else { // do this as no form present

...

}

to my checklogin.php at :

if(isset($_POST['Submit'])){

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

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

} else { echo "no form present";

}

?
Copy linkTweet thisAlerts:
@netbuddyOct 07.2006 — Your running before you can walk.

You need to have a form to present to the server, you neither have a form or buttons for a form so the PHP can get the data.

When you click the link to call you script, your calling the script to display HTML in the browser and because theirs no output, guess what.... (I should be obvious)

HTML information can be found in this site by searching for it.
Copy linkTweet thisAlerts:
@bella07authorOct 07.2006 — i dont really get it...

can u tell me how i must correct the php login??

u mean that i havent do the form for login??

i thought i ready done it

in [U]stafflog.php [/U] for html

sorry,cause i'm begginer for php ?

thanks a lot for the help ?
Copy linkTweet thisAlerts:
@netbuddyOct 07.2006 — </form> does not constitute a form.

I suggest that you make a HTML page with your login form requirements, use an editor, then save that html file WITHOUT ANY TRACE OF PHP code in that file.

Write the PHP script that controls your login, if the login fails, send them back to your login HTML page. If not, forward that user onwards to another page that indicates that they logged in.

When you have done that, you can begin to iron out any issues with your PHP script.

Like I said before, your trying to run before you can walk so go here: http://devzone.zend.com/node/view/id/627 :for PHP help. as you should know the basics of HTML, if not, consult the HTML forum, here: http://www.webdeveloper.com/forum/forumdisplay.php?f=2 : and they will tell you how to make a form!
×

Success!

Help @bella07 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...