How to write a php code for the form username & password and what’s the code for the username & passowrd file?

Question by Ahmed S: How to write a php code for the form username & password and what’s the code for the username & passowrd file?
Hi I’m trying to write the code belwo for the php form:

First name:


Last name:




so I want to put the username and password inside the file userandpass.php and when i click on the submit button the system will go and check the username and password from userandpass.php file so would you please help me on what should I put write inside the userandpass.php file, I have checked with this but it’s not working :


Welcome !


Thanks and have a nice day :)
yes i mean username and password not frist and last name sorry for that
so the code is still not working i added this code to the userandpass.php file
if($ _POST["username"]=="ahmed" AND $ _POST["password"]=="S" ){
echo 'Welcome';
}else{
echo 'Login Failed!';
}
?>
and i have changed the code to :

Username:


Password:




after enter ahmed and password s
the page still not working ? would you please help me with this ?

Best answer:

Answer by neorang
username and password, or firstname and lastname?
anyway,
change ‘fname’ to ‘firstname’ : it will show the value of firstname text input
but its not gonna check whether it is correct or not

so u need this:
if($ _POST["firstname"]=="ahmed" AND $ _POST["lastname"]=="S" ){

echo 'Welcome';

}else{

echo 'Login Failed!';

}
?>

What do you think? Answer below!

Revisions

There are no revisions for this post.

Tags: , , , , , , ,

No comments yet.

Leave a Reply