PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Variable not passed
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Variable not passed

Réponse
 
LinkBack Outils de la discussion
Vieux 09/11/2007, 23h37   #1
Big Moxy
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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 !

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");
}

?>

  Réponse avec citation
Vieux 10/11/2007, 00h11   #2
Darko
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Variable not passed

On Nov 9, 11:37 pm, Big Moxy <bigm...@gmail.com> wrote:
> 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 !
>
> 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 s, 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?

  Réponse avec citation
Vieux 10/11/2007, 00h53   #3
Big Moxy
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Variable not passed

On Nov 9, 3:11 pm, Darko <darko.maksimo...@gmail.com> wrote:
> On Nov 9, 11:37 pm, Big Moxy <bigm...@gmail.com> wrote:
>
>
>
>
>
> > 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 !

>
> > 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 s, 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

  Réponse avec citation
Vieux 10/11/2007, 14h55   #4
Darko
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Variable not passed

On Nov 10, 12:53 am, Big Moxy <bigm...@gmail.com> wrote:
> On Nov 9, 3:11 pm, Darko <darko.maksimo...@gmail.com> wrote:
>
>
>
> > On Nov 9, 11:37 pm, Big Moxy <bigm...@gmail.com> wrote:

>
> > > 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 !

>
> > > 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 s, 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

  Réponse avec citation
Vieux 10/11/2007, 17h38   #5
John Dunlop
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut HTTP Location header (was: Variable not passed)

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

  Réponse avec citation
Vieux 11/11/2007, 12h45   #6
AnrDaemon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Variable not passed

Greetings, Big Moxy.
In reply to Your message dated Saturday, November 10, 2007, 02:53:51,

> AFIK the absolute URL is not mandatory because most web servers
> support its absence.


But webservers isn't dealing with URL's passed in Location redirects.
It is completely for browsers and actually NOT supported by Opera for example.
I mean, if You show the <a href="/some/path/document" link on page, it is NOT
means that browser will send it to server as it is.
Instead, browser will reconstruct full URL before passing it to server.
For Location, there's strict demand for ABSOLUTE URI, including protocol,
host and the rest.

> 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.


Take a look at http_build_query function if You want to pass more than one
parameter in request.


--
Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 16h55.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,21852 seconds with 14 queries