User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,950 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,890 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 3413 | Replies: 2
Reply
Join Date: Jul 2005
Posts: 2
Reputation: Sean_F is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Sean_F Sean_F is offline Offline
Newbie Poster

Help Help with Login Box

  #1  
Jul 11th, 2005
Hey, im trying to make a PHP Login box for a program that i am making for my A Level project
however, im new with PHP so dont really know much about the code lol.

this is what i have so far

<html>

<body>

<?php

$username = "Admin";
$password = "Password";

if ($username=!$password; )
{
print "The Username or Password is incorrect";
}

elseif ($username=$password; )
{
(i want it to go to a webpage if the username and password match)
}

?>

<p align="left"><font face="Arial" size="5"><b>Login</b></font></p>
<table border="0" width="29%" id="table2">
<tr>
<td><b><font face="Arial" size="4">Username:</font></b></td>
<td width="148"><input type="text" name="Username" size="20"></td>
</tr>
<tr>
<td><b><font face="Arial" size="4">Password:</font></b></td>
<td width="148"><input type="password" name="Password" size="20"></td>
</tr>
</table>



</body>
</html>

im not sure if this is correct or not.
if there is somebody that can help can you please email me.
seanfinn@gmail.com
or, post here.

thanks alot

Sean
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: Seattle, WA
Posts: 53
Reputation: senexom is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
senexom's Avatar
senexom senexom is offline Offline
Junior Poster in Training

Solution Re: Help with Login Box

  #2  
Jul 11th, 2005
Hey Sean,

You need to begin by learning the proper way of writing HTML, then the php syntax, then working on your logic...

Just so you know no one here is going to write code for you, well I guess I can only speak for my self. But I'll get you started on fixing your problems...

1. Your HTML is missing a <form></form> tags, which is essential if you want your information to be submitted somewhere.

2. The user name and password variables will overwrite your actual user name and password submitted from the form since they are named the same. Also look into using $_GET[], $_POST[], $_REQUEST[].
[PHP]$username = "Admin";
$password = "Password";[/PHP]

3. Following line of code is checking if password is not equal to user name. Why would you check if password is the same as user name, makes not sense and has nothing to do with knowledge of PHP, your logic is missing.
[PHP]if ($username=!$password; ) ...[/PHP]
Should be something along the lines of ...
[PHP]if($secretUser==$_POST['username'] && $secretPass==$_POST['password']){
// let them in...
} else {
// display error message...
}[/PHP]

4. [PHP]elseif ($username=$password; )[/PHP] First there is not elseif in PHP (that's VB syntax), Second, you must use double == signs when comparing values otherwise you have just assigned the value of $password to the $username.

Get this to work and comeback, there is more then enough references on google regarding what you're doing here. We'll be glad to help you further.
Reply With Quote  
Join Date: Jul 2005
Posts: 2
Reputation: Sean_F is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Sean_F Sean_F is offline Offline
Newbie Poster

Re: Help with Login Box

  #3  
Jul 11th, 2005
yeah thanks alot.
i have sorted it out now and have fully working login boxes
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:00 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC