Home > Archive > PHP SQL > March 2007 > What is wrong with my syntax??
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
What is wrong with my syntax??
|
|
| Nosferatum 2007-03-30, 4:00 am |
| 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?
<?php
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<br>\n<a
href='java script:history.go(-1)'>Back</a>");
}
?>
| |
| Captain Paralytic 2007-03-30, 7:00 pm |
| On 30 Mar, 09:46, "Nosferatum" <John.Ola...@gmail.com> 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?
>
> <?php
> 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<br>\n<a
> href='java script:history.go(-1)'>Back</a>");
>
> }
>
> ?>
There is usually a space between location@: and the url thus:
header("location: http://www.mysite.com/customers/cat50/index.php");
|
|
|
|
|