<form method="post" action="process.php">
Username
<input type="text" name="user" />
<br />
Password
<input type="password" name="pass" />
<br />
<input type="submit" name="submit" value="Login" />
</form>
<?
//get variables from login screen.mdb
$user = $_POST['user'];
$pass = $_POST['pass'];
if (odbc_num_rows($query)) {
header("Location: process.php");
exit();
} else {
echo "you can't log in.";
}
?>
I have done the process PHP but how can i validate users? When i run the code it comes up with the following errors:
Warning: odbc_num_rows(): supplied argument is not a valid ODBC result resource in c:\phpdev5\www\tmpa3fcbrhqz1.php on line 15
you can't log in.
where am i going wrong?
PHP Login script
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Code: Select all
$query="select password from table_name where user_name='%s'";
$result=mysql_query(sprintf($query,$_POSTї'username']));- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Basically you need to connect to the database, then query the database.
[php_man]odbc_connect[/php_man]()
[php_man]odbc_exec[/php_man]()
Google gives you:
http://www.w3schools.com/php/php_db_odbc.asp
Mac
[php_man]odbc_connect[/php_man]()
[php_man]odbc_exec[/php_man]()
Google gives you:
http://www.w3schools.com/php/php_db_odbc.asp
Mac
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
That won't work - he's trying to query an Access database not MySQL, not that it's stated in the current topic but it was in a previous thread so it's an easy mistake to make.phpcoder wrote:Code: Select all
$query="select password from table_name where user_name='%s'"; $result=mysql_query(sprintf($query,$_POSTї'username']));
viewtopic.php?p=80865
Mac