473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Variable not passed

I've successfully tested sending the variable "msg" back to login.php.
However further down I am sending the variable "id" to menu.php but it
is not being sent. It does not appear in the URL in the format
http://{domain}/menu.php?id={value}. It is also not retrievable via
$_GET['id']; I don't see any differences yet one works the other
doesn't. Please help!

Thank you!
Tim

<?php
session_start();
require_once("Connections/usersDB.php");

// username and password sent from signup form
$userID=$_POST['userID'];
$password=$_POST['password'];
$userType=$_POST['clientType'];

// encrypt password
$encrypted_password=md5($password);
$_SESSION["password"] = $encrypted_password;

// if password encryption is not used
//$sql="SELECT * FROM $table_name WHERE userName='$userID' and
password='$password'";
//$result=mysql_query($sql);

// if password encryption is used
if ($userType == ""){
$sql="SELECT * FROM $table_name WHERE userName = '$userID' and
userPassword = '$encrypted_password'";
$result=mysql_query($sql);
if (!$result) {
header("location:login.php?msg=1");
}
else {
$rows = mysql_num_rows($result);
if($rows < 1) {
// Return to login page with error message
header("location:login.php?msg=2");
}
}
}
else {
$sql = "INSERT INTO $table_name
(`userName`,`userPassword`,`userType`,`userStatus` ) VALUES
('$userID','$encrypted_password','$userType','1')" ;
$result=mysql_query($sql);
if (!$result) {
header("location:login.php?msg=3");
}
}

// Register $userID, $password, $userType
$_SESSION['userID'] = $userID;
$_SESSION['password'] = $encrypted_password;
$_SESSION['userType'] = $userType;

// Determine next page based on user type
if ($userType == "admin") {
header("location:menu.php?id=1");
}
elseif ($userType = "dynamixSI") {
header("location:menu.php?id=2");
}
elseif ($userType == "VAR") {
header("location:menu.php?id=3");
}
elseif ($userType == "salesAgent") {
header("location:menu.php?id=4");
}
else {
header("location:phone.php");
}

?>

Nov 9 '07 #1
4 1805
On Nov 9, 11:37 pm, Big Moxy <bigm...@gmail.comwrote:
I've successfully tested sending the variable "msg" back to login.php.
However further down I am sending the variable "id" to menu.php but it
is not being sent. It does not appear in the URL in the format
http://{domain}/menu.php?id={value}. It is also not retrievable via
$_GET['id']; I don't see any differences yet one works the other
doesn't. Please help!

Thank you!
Tim

<?php
session_start();
require_once("Connections/usersDB.php");

// username and password sent from signup form
$userID=$_POST['userID'];
$password=$_POST['password'];
$userType=$_POST['clientType'];

// encrypt password
$encrypted_password=md5($password);
$_SESSION["password"] = $encrypted_password;

// if password encryption is not used
//$sql="SELECT * FROM $table_name WHERE userName='$userID' and
password='$password'";
//$result=mysql_query($sql);

// if password encryption is used
if ($userType == ""){
$sql="SELECT * FROM $table_name WHERE userName = '$userID' and
userPassword = '$encrypted_password'";
$result=mysql_query($sql);
if (!$result) {
header("location:login.php?msg=1");
}
else {
$rows = mysql_num_rows($result);
if($rows < 1) {
// Return to login page with error message
header("location:login.php?msg=2");
}
}}

else {
$sql = "INSERT INTO $table_name
(`userName`,`userPassword`,`userType`,`userStatus` ) VALUES
('$userID','$encrypted_password','$userType','1')" ;
$result=mysql_query($sql);
if (!$result) {
header("location:login.php?msg=3");
}

}

// Register $userID, $password, $userType
$_SESSION['userID'] = $userID;
$_SESSION['password'] = $encrypted_password;
$_SESSION['userType'] = $userType;

// Determine next page based on user type
if ($userType == "admin") {
header("location:menu.php?id=1");}

elseif ($userType = "dynamixSI") {
header("location:menu.php?id=2");}

elseif ($userType == "VAR") {
header("location:menu.php?id=3");}

elseif ($userType == "salesAgent") {
header("location:menu.php?id=4");}

else {
header("location:phone.php");

}

?>
I don't know if it helps, but you have to use absolute URL's in the
location header. Also, I admit
I haven't seen yet an example of specifying the query string in the
location header. Are you
sure it's included by the protocol?

Nov 9 '07 #2
On Nov 9, 3:11 pm, Darko <darko.maksimo...@gmail.comwrote:
On Nov 9, 11:37 pm, Big Moxy <bigm...@gmail.comwrote:


I've successfully tested sending the variable "msg" back to login.php.
However further down I am sending the variable "id" to menu.php but it
is not being sent. It does not appear in the URL in the format
http://{domain}/menu.php?id={value}. It is also not retrievable via
$_GET['id']; I don't see any differences yet one works the other
doesn't. Please help!
Thank you!
Tim
<?php
session_start();
require_once("Connections/usersDB.php");
// username and password sent from signup form
$userID=$_POST['userID'];
$password=$_POST['password'];
$userType=$_POST['clientType'];
// encrypt password
$encrypted_password=md5($password);
$_SESSION["password"] = $encrypted_password;
// if password encryption is not used
//$sql="SELECT * FROM $table_name WHERE userName='$userID' and
password='$password'";
//$result=mysql_query($sql);
// if password encryption is used
if ($userType == ""){
$sql="SELECT * FROM $table_name WHERE userName = '$userID' and
userPassword = '$encrypted_password'";
$result=mysql_query($sql);
if (!$result) {
header("location:login.php?msg=1");
}
else {
$rows = mysql_num_rows($result);
if($rows < 1) {
// Return to login page with error message
header("location:login.php?msg=2");
}
}}
else {
$sql = "INSERT INTO $table_name
(`userName`,`userPassword`,`userType`,`userStatus` ) VALUES
('$userID','$encrypted_password','$userType','1')" ;
$result=mysql_query($sql);
if (!$result) {
header("location:login.php?msg=3");
}
}
// Register $userID, $password, $userType
$_SESSION['userID'] = $userID;
$_SESSION['password'] = $encrypted_password;
$_SESSION['userType'] = $userType;
// Determine next page based on user type
if ($userType == "admin") {
header("location:menu.php?id=1");}
elseif ($userType = "dynamixSI") {
header("location:menu.php?id=2");}
elseif ($userType == "VAR") {
header("location:menu.php?id=3");}
elseif ($userType == "salesAgent") {
header("location:menu.php?id=4");}
else {
header("location:phone.php");
}
?>

I don't know if it helps, but you have to use absolute URL's in the
location header. Also, I admit
I haven't seen yet an example of specifying the query string in the
location header. Are you
sure it's included by the protocol?- Hide quoted text -

- Show quoted text -
AFIK the absolute URL is not mandatory because most web servers
support its absence. As I indicated, the query string worked
successfully for all of my ?msg={value} options. I did however change
the URL to absolute and I am at least getting the ?id={value} passed
but {value} is wrong. That's another problem for another post if I
don't figure it out.

Thanks,
Tim

Nov 9 '07 #3
On Nov 10, 12:53 am, Big Moxy <bigm...@gmail.comwrote:
On Nov 9, 3:11 pm, Darko <darko.maksimo...@gmail.comwrote:
On Nov 9, 11:37 pm, Big Moxy <bigm...@gmail.comwrote:
I've successfully tested sending the variable "msg" back to login.php.
However further down I am sending the variable "id" to menu.php but it
is not being sent. It does not appear in the URL in the format
http://{domain}/menu.php?id={value}. It is also not retrievable via
$_GET['id']; I don't see any differences yet one works the other
doesn't. Please help!
Thank you!
Tim
<?php
session_start();
require_once("Connections/usersDB.php");
// username and password sent from signup form
$userID=$_POST['userID'];
$password=$_POST['password'];
$userType=$_POST['clientType'];
// encrypt password
$encrypted_password=md5($password);
$_SESSION["password"] = $encrypted_password;
// if password encryption is not used
//$sql="SELECT * FROM $table_name WHERE userName='$userID' and
password='$password'";
//$result=mysql_query($sql);
// if password encryption is used
if ($userType == ""){
$sql="SELECT * FROM $table_name WHERE userName = '$userID' and
userPassword = '$encrypted_password'";
$result=mysql_query($sql);
if (!$result) {
header("location:login.php?msg=1");
}
else {
$rows = mysql_num_rows($result);
if($rows < 1) {
// Return to login page with error message
header("location:login.php?msg=2");
}
}}
else {
$sql = "INSERT INTO $table_name
(`userName`,`userPassword`,`userType`,`userStatus` ) VALUES
('$userID','$encrypted_password','$userType','1')" ;
$result=mysql_query($sql);
if (!$result) {
header("location:login.php?msg=3");
}
}
// Register $userID, $password, $userType
$_SESSION['userID'] = $userID;
$_SESSION['password'] = $encrypted_password;
$_SESSION['userType'] = $userType;
// Determine next page based on user type
if ($userType == "admin") {
header("location:menu.php?id=1");}
elseif ($userType = "dynamixSI") {
header("location:menu.php?id=2");}
elseif ($userType == "VAR") {
header("location:menu.php?id=3");}
elseif ($userType == "salesAgent") {
header("location:menu.php?id=4");}
else {
header("location:phone.php");
}
?>
I don't know if it helps, but you have to use absolute URL's in the
location header. Also, I admit
I haven't seen yet an example of specifying the query string in the
location header. Are you
sure it's included by the protocol?- Hide quoted text -
- Show quoted text -

AFIK the absolute URL is not mandatory because most web servers
support its absence.
You're probably right, but HTTP specification says:
The field value consists of a single absolute URI.

Location = "Location" ":" absoluteURI

An example is:

Location: http://www.w3.org/pub/WWW/People.html
As I indicated, the query string worked
successfully for all of my ?msg={value} options. I did however change
the URL to absolute and I am at least getting the ?id={value} passed
but {value} is wrong. That's another problem for another post if I
don't figure it out.

Thanks,
Tim
Regards

Nov 10 '07 #4
Darko:
[Big Moxy:]
AFIK the absolute URL is not mandatory because most web servers
support its absence.
Most web servers supporting relative URLs is not a reason for not
using absolute URLs.
You're probably right, but HTTP specification says:
The field value consists of a single absolute URI.
Location = "Location" ":" absoluteURI
An example is:
Location:http://www.w3.org/pub/WWW/People.html
(What a poor example URL.)

Which means that, you are right, an absolute URL is required.

The rule that defines the Location header was fixed to include
fragment identifiers, so in practice the rule is:

Location = "Location" ":" absoluteURI [ "#" fragment ]

--
Jock

Nov 10 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Randell D. | last post by:
I have a script (below) that can be passed an array and it will dump the contents of the array in to an html table - I use it during development so its nothing sexy. It handles multidimsional...
7
by: Donna Hawkins | last post by:
I want to use javascript to redirect to a URL which has been passed as a variable (in php). I have searched but cannot find any solution. I think this code is a basic redirect: <script...
4
by: Michael | last post by:
All, I'll asked a question but I was not detailed (clear) enough for people to help so I'll retry. I have a cgi script pass a variable from one page to the next. The 'receiving' page replaces...
10
by: Blaxer | last post by:
There is probably a really easy way to do this, so please forgive me but I would like to set the value of a variable from a variable, an example would be... function Calculate_Something(ByVal...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
7
by: icosahedron | last post by:
Is there a way to determine if a parameter to a function is a constant (e.g. 2.0f) versus a variable? Is there some way to determine if this is the case? (Say some metaprogramming tip or type...
2
by: Daniel Reardon | last post by:
All, I'm sure that this is an old question, but I'm having problems getting a substring of a passed in variable. I can do other string manipulation with it such as concatonation, but I'm really...
2
by: assgar | last post by:
I am having problems getting the user selected form info to inserted into the mysql database. I am also rec eving an error: Warning: Variable passed to each() is not an array or object in ...
3
by: hon123456 | last post by:
Dear all, I have a session variable session("loginid) which can be passed from A.asp to B.asp. Then In B.asp I have a hyperlink to C.asp e.g. < A href..C.asp>. The session variable cannot be...
11
by: Googy | last post by:
Hi friends!! As we know that the input parameters in a function is fixed when the function is defined but how does printf processes variable number of input arguments ? For example: 1....
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.