|
-
Dec 4th, 2008, 11:04 AM
#1
Thread Starter
Frenzied Member
Begginers Login help
Hi guys,
Below is the code but when i run the script on my server it shows the Access Denied before i even type anything in also when i type in the correct username and password how do i get it to remove the login box stuff and just leave the Access Granted text?.
PHP Code:
<html>
<head/>
<body>
<form action="login.php" method=POST>
Username <input type=text name=user><br/>
Password <input type=text name=pass><br/>
<input type=submit value="Go"><p>
</form>
<?php
$user=$_POST['user'];
$pass=$_POST['pass'];
if (($user=='admin') && ($pass=='admin')) echo "Access Granted!";
else echo "Access Denied!";
?>
</body>
</html>
come back and mark your original post as resoved if your problem is fixed
Jamie Garland
-
Dec 4th, 2008, 11:17 AM
#2
Re: Begginers Login help
I'm not going to give you the answer on this one, but I will attempt to help.
PHP Code:
<?php
$user=$_POST['user'];
$pass=$_POST['pass'];
if (($user=='admin') && ($pass=='admin')) echo "Access Granted!";
else echo "Access Denied!";
?>
The above code is getting the post variables "user" and "pass" and putting them in the local variables $user and $pass.
So, when you first access the form, you have not posted anything, thus the "Access Denied" message.
If you enter "admin" and "admin" into the text boxes, it will post back and show "Access Granted" but the form will still appear.
You will need to check your variables and decide what you want to display based on that.
-
Dec 5th, 2008, 09:05 AM
#3
Lively Member
Re: Begginers Login help
 Originally Posted by Jamie_Garland
Hi guys,
Below is the code but when i run the script on my server it shows the Access Denied before i even type anything in also when i type in the correct username and password how do i get it to remove the login box stuff and just leave the Access Granted text?.
PHP Code:
<html>
<head/>
<body>
<form action="login.php" method=POST>
Username <input type=text name=user><br/>
Password <input type=text name=pass><br/>
<input type=submit value="Go"><p>
</form>
<?php
$user=$_POST['user'];
$pass=$_POST['pass'];
if (($user=='admin') && ($pass=='admin')) echo "Access Granted!";
else echo "Access Denied!";
?>
</body>
</html>
Unless "login.php" is the same page, then it is not processing the infomation in the text boxes.
Alternatively, try
<form action="" method=POST>
Visual Basic 6 + MS Access
-
Dec 5th, 2008, 01:36 PM
#4
Thread Starter
Frenzied Member
Re: Begginers Login help
Can anyone help me with placing a link if the access has been accepted and if its denied the link dosent show this is the code that i have so far?.
Code:
<?php
$user=$_POST['user'];
$pass=$_POST['pass'];
if (($user=='admin') && ($pass=='admin')) echo "Access Granted!";
else echo "Access Denied!";
?>
come back and mark your original post as resoved if your problem is fixed
Jamie Garland
-
Dec 5th, 2008, 02:34 PM
#5
Re: Begginers Login help
That code looks identical to the code you posted above.
At least change your echo to output a link before you ask for help; You'll find most people around here help those who help themselves.
Also, if you're looking at having someone authenticate to get into your page, and any subsequent pages, you should look into Sessions.
W3Schools has a good tutorial at:
http://www.w3schools.com/php/php_sessions.asp
But I would also suggest you go through their entire PHP tutorial at:
http://www.w3schools.com/php/php_intro.asp
-
Dec 12th, 2008, 04:29 AM
#6
Re: Begginers Login help
Check to see if the POST is == ""
If(!$_POST['user'] == "" && !$_POST['pass'] == ""){
if (($user=='admin') && ($pass=='admin')) echo "Access Granted!";
else echo "Access Denied!";
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|