login form. need help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mavrick_12
Forum Newbie
Posts: 2
Joined: Fri Apr 16, 2010 7:45 am

login form. need help

Post by mavrick_12 »

hi
i want to ceate a login form using php and mysql.The new user should first sign up and then login.
thank you.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: login form. need help

Post by social_experiment »

mavrick_12 wrote:hi
i want to ceate a login form using php and mysql.The new user should first sign up and then login.
thank you.
Do you have any code that you have created?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
mavrick_12
Forum Newbie
Posts: 2
Joined: Fri Apr 16, 2010 7:45 am

Re: login form. need help

Post by mavrick_12 »

yes
<?php

if (isset($_POST['btn_login']) && $_POST['btn_login']) {
$username = $_POST['txt_username'];
$password = $_POST['txt_password'];

login($username, $password);
}
?>
<form method="POST" action="login.php">
<table align="center" width="30%" class="decorated">
<thead>
<tr>
<th colspan="2">Login</th>
</tr>
</thead>
<tbody>
<tr>
<td>Username : </td><td class="odd"><input type="text" name="txt_username"></td>
</tr>
<tr>
<td>Password : </td><td class="odd"><input type="password" name="txt_password"></td>
</tr>
<tr>
<td></td><td><input type="submit" name="btn_login" value="Login"></td>
</tr>
</tbody>
</table>

</form>
</fieldset>
</P>
User avatar
JAY6390
Forum Newbie
Posts: 20
Joined: Sat Apr 17, 2010 6:51 am
Location: UK

Re: login form. need help

Post by JAY6390 »

Hi Mavrick

OK so you have the basics in place, but you have login($username, $password) which won't do anything unless you've got a function defined and haven't posted it. You will need to create a function to verify the user like so

Code: Select all

function login($username, $password) {
    //Code here to validate against database/file containing username/password pairs
    //Return the result here
}
Regards

Jay
Post Reply