Page 1 of 1
login form. need help
Posted: Sat Apr 17, 2010 3:55 am
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.
Re: login form. need help
Posted: Sat Apr 17, 2010 4:10 am
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?
Re: login form. need help
Posted: Sat Apr 17, 2010 5:24 am
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>
Re: login form. need help
Posted: Sat Apr 17, 2010 7:16 am
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