Hi Guys, I am learning PHP and I have a question, I have a form called index.php basic code below:
[code=html]
<form action=”logincheck.php” method=”post”>
<table>
<tr>
<td>Username: </td>
<td><input type=”text” name=”user” value=”<?php echo $user; ?>”/></td>
</tr>
<tr>
<td>Password: </td>
<td><input type=”password” name=”password”/></td>
</tr>
<td><input type=”submit” name=”Submit” value=”Login” /></td>
<td><input type=”button” name=”Register” value=”Register” onclick=”location.href=’register.php'” /></td>
</table>
Once I submit the page it calls logincheck.php if it encounters errors I have a include(index.php) and the displays error, my question is how would you guys go about redisplaying the errors under the table in the above index.php file?
I am currently using the following:
[code=php]
if (is_user($user,$pass,$file) == true)
{
include (‘logdin.php’);
print ‘Congrats ‘. $_POST[‘user’].’ you have managed to log in’;
} else {
include (‘index.php’);
print ‘Username and Password combination doesn’t exist’;
}
Is it OK to use the include command like I have above or is there a better way? What about the header(), what is that used for? I know the difference between include() and require() but don’t know what header() is used for.
If I use the include command and it is a good idea how can I keep the user name in the username field once I have submitted?
I hope you know what I mean.
Thanks.