What is wrong with my syntax??

What is wrong with my syntax??

am 30.03.2007 10:46:31 von Nosferatum

This processing script is supposed to check users submitted customer
number and customer pass and see if these are equal to the data in my
MySQL db. Associated with each customer number and customer pass are a
destinationID (a fixed number, 10,20,30,40 or 50) which should
redirect the user.
But the processing script just hangs and displays the destinationID,
no redirect.
Can anyone see anything wrong with the syntax?



session_start();

//register user session
$_SESSION['customer_number'] = "$customer_number";
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['rabkat'] = $row['destinationID'];

$kundenummer = $_POST['customer_number'];
$orgnummer = $_POST['customer_pass'];


//my mysql login details
$host="mi.ip.details";
$username="username";
$password="password";
$db_name="my_database";
$tbl_name="my_table";

// connect and choose db
mysql_connect("$host", "$username", "$password")or die("I cant
connect");
mysql_select_db("$db_name")or die("I can't choose db");

//process search
$sql="SELECT destinationID FROM $tbl_name WHERE
customer_number='$customer_number' AND
customer_pass='$customer_pass'";
$result=mysql_query($sql);


if ($result && (mysql_num_rows($result)!= 0)) {
$row = mysql_fetch_array($result);
echo $row['destinationID'];

}


//choose correct destination based upon users data from mysql

switch($row['destinationID']) {
case '10':
header("location:http://www.mysite.com/customers/cat10/
index.php");
break;
case '20':
header("location:http://www.mysite.com/customers/cat20/
index.php");
break;
case '30':
header("location:http://www.mysite.com/customers/cat30/
index.php");
break;
case '40':
header("location:http://www.mysite.com/customers/cat40/
index.php");
break;
case '50':
header("location:http://www.mysite.com/customers/cat50/
index.php");
break;
default:
printf("Wrong customer number or customer pass
\n href='javascript:history.go(-1)'>Back");
}


?>

Re: What is wrong with my syntax??

am 30.03.2007 16:20:11 von Captain Paralytic

On 30 Mar, 09:46, "Nosferatum" wrote:
> This processing script is supposed to check users submitted customer
> number and customer pass and see if these are equal to the data in my
> MySQL db. Associated with each customer number and customer pass are a
> destinationID (a fixed number, 10,20,30,40 or 50) which should
> redirect the user.
> But the processing script just hangs and displays the destinationID,
> no redirect.
> Can anyone see anything wrong with the syntax?
>
> > session_start();
>
> //register user session
> $_SESSION['customer_number'] = "$customer_number";
> $_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
> $_SESSION['rabkat'] = $row['destinationID'];
>
> $kundenummer = $_POST['customer_number'];
> $orgnummer = $_POST['customer_pass'];
>
> //my mysql login details
> $host="mi.ip.details";
> $username="username";
> $password="password";
> $db_name="my_database";
> $tbl_name="my_table";
>
> // connect and choose db
> mysql_connect("$host", "$username", "$password")or die("I cant
> connect");
> mysql_select_db("$db_name")or die("I can't choose db");
>
> //process search
> $sql="SELECT destinationID FROM $tbl_name WHERE
> customer_number='$customer_number' AND
> customer_pass='$customer_pass'";
> $result=mysql_query($sql);
>
> if ($result && (mysql_num_rows($result)!= 0)) {
> $row = mysql_fetch_array($result);
> echo $row['destinationID'];
>
> }
>
> //choose correct destination based upon users data from mysql
>
> switch($row['destinationID']) {
> case '10':
> header("location:http://www.mysite.com/customers/cat10/
> index.php");
> break;
> case '20':
> header("location:http://www.mysite.com/customers/cat20/
> index.php");
> break;
> case '30':
> header("location:http://www.mysite.com/customers/cat30/
> index.php");
> break;
> case '40':
> header("location:http://www.mysite.com/customers/cat40/
> index.php");
> break;
> case '50':
> header("location:http://www.mysite.com/customers/cat50/
> index.php");
> break;
> default:
> printf("Wrong customer number or customer pass
\n > href='javascript:history.go(-1)'>Back");
>
> }
>
> ?>

There is usually a space between location@: and the url thus:
header("location: http://www.mysite.com/customers/cat50/index.php");