|
Posted by <info on 10/11/61 11:58
With an if statement you should use else{
if($user == $username && $pass == $password){
header("location:" . $_SERVER['SERVER_URL'] . "search.php");
}else{
header("location:" . $_SERVER['SERVER_URL'] . "unauthorised.html");
}
and you already used $password as your DB_password so this is better
$db_hostname = "127.0.0.1";
$db_username = "xxxx";
$db_password = "xxxx";
$db_dbname = "xxxx";
<jerryyang_la1@yahoo.com> schreef in bericht
news:1158499421.459740.219300@d34g2000cwd.googlegroups.com...
> Trying to get this working..
> But I'm getting it wrong !
> Any Ideas ?
> Thanks
>
>
> <?php
> // grab form variables
> $user = $_POST["username"];
> $pass = $_POST["password"];
>
> $hostName = "127.0.0.1";
> $userName = "xxxx";
> $password = "xxxx";
> $dbName = "xxxx";
>
> // make connection to database
> mysql_connect($hostName, $userName, $password) or die("Unable to
> connect to host $hostName");
> mysql_select_db($dbName) or die("Unable to select database $dbName");
>
> // select fields for drop down list
> $query = "select *
> from users WHERE Username = '$user'";
> $result = mysql_query($query);
>
> // determine the number of companies
> $number = mysql_num_rows($result);
>
> //results from sql query
> for ($i=0; $i<$number; $i++) {
> $username = mysql_result($result,$i,"Username");
> $password = mysql_result($result,$i,"Password");
>
>
> if ($user == $username) {
> if ($pass == $password) {
> //if user and password are OK, redirect to here
> header("location:" . $_SERVER['SERVER_URL'] . "search.php");
> }
> }
> //end of if results
> }
> header("location:" . $_SERVER['SERVER_URL'] . "unauthorised.html");
> ?>
>
Navigation:
[Reply to this message]
|