PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.comp.lang.php > Newbie question = how to send variable form one page to the other
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Newbie question = how to send variable form one page to the other

Réponse
 
LinkBack Outils de la discussion
Vieux 26/06/2007, 16h43   #1
GD
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Newbie question = how to send variable form one page to the other

Newbie question = how to send variable form one page to the other

i have a page with a very simple login. i want to be able to use the
username variable to great the user by username when he reaches the
page where he is redirected to. and at the same time get the ID field
from my table which is and INT and PRIMARY_KEY.

i've tried using a regular vairable and calling it back from the
second page, but the second page doesn't read the first page's
variable.

btw, i'm using the login server behaviour that comes with dramweaver
cs3 that adds the following code:

$LoginRS__query=sprintf("SELECT username, password FROM information
WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"),
GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $WebParashaDB) or
die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//here is where i need to enter my text


//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>

any would be appreciated.

thank you very much,
GD

  Réponse avec citation
Vieux 26/06/2007, 21h54   #2
Armand Brahaj
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question = how to send variable form one page to the other

GD wrote:
> Newbie question = how to send variable form one page to the other
>
> i have a page with a very simple login. i want to be able to use the
> username variable to great the user by username when he reaches the
> page where he is redirected to. and at the same time get the ID field
> from my table which is and INT and PRIMARY_KEY.
>
> i've tried using a regular vairable and calling it back from the
> second page, but the second page doesn't read the first page's
> variable.
>
> btw, i'm using the login server behaviour that comes with dramweaver
> cs3 that adds the following code:
>
> $LoginRS__query=sprintf("SELECT username, password FROM information
> WHERE username=%s AND password=%s",
> GetSQLValueString($loginUsername, "text"),
> GetSQLValueString($password, "text"));
>
> $LoginRS = mysql_query($LoginRS__query, $WebParashaDB) or
> die(mysql_error());
> $loginFoundUser = mysql_num_rows($LoginRS);
> if ($loginFoundUser) {
> $loginStrGroup = "";
>
> //here is where i need to enter my text
>
>
> //declare two session variables and assign them
> $_SESSION['MM_Username'] = $loginUsername;
> $_SESSION['MM_UserGroup'] = $loginStrGroup;
>
> if (isset($_SESSION['PrevUrl']) && false) {
> $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
> }
> header("Location: " . $MM_redirectLoginSuccess );
> }
> else {
> header("Location: ". $MM_redirectLoginFailed );
> }
> }
> ?>
>
> any would be appreciated.
>
> thank you very much,
> GD
>

To better understand, use a simple code from your self!
There are different ways to pass a variable from a page to another.
The easiest method I guess, is to send the variables (in a GET method)
via URL.
so
from the first page, call the second page with a ling like
second.php?variable=value

You can then read the value of the variable by
echo $_GET["variable"]; // will print "value"

2 other methods are:
2. POST Method (forms with post)
3. Sessions or

Good luck
  Réponse avec citation
Vieux 26/06/2007, 23h24   #3
AnUser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question = how to send variable form one page to the other

GD wrote:
> Newbie question = how to send variable form one page to the other
>
> i have a page with a very simple login. i want to be able to use the
> username variable to great the user by username when he reaches the
> page where he is redirected to. and at the same time get the ID field
> from my table which is and INT and PRIMARY_KEY.
>
> i've tried using a regular vairable and calling it back from the
> second page, but the second page doesn't read the first page's
> variable.
>
> btw, i'm using the login server behaviour that comes with dramweaver
> cs3 that adds the following code:
>
> $LoginRS__query=sprintf("SELECT username, password FROM information
> WHERE username=%s AND password=%s",
> GetSQLValueString($loginUsername, "text"),
> GetSQLValueString($password, "text"));
>
> $LoginRS = mysql_query($LoginRS__query, $WebParashaDB) or
> die(mysql_error());
> $loginFoundUser = mysql_num_rows($LoginRS);
> if ($loginFoundUser) {
> $loginStrGroup = "";
>
> //here is where i need to enter my text
>
>
> //declare two session variables and assign them
> $_SESSION['MM_Username'] = $loginUsername;
> $_SESSION['MM_UserGroup'] = $loginStrGroup;
>
> if (isset($_SESSION['PrevUrl']) && false) {
> $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
> }
> header("Location: " . $MM_redirectLoginSuccess );
> }
> else {
> header("Location: ". $MM_redirectLoginFailed );
> }
> }
> ?>
>
> any would be appreciated.
>
> thank you very much,
> GD
>

GD,
This may be a dumb question but is there a reason you can't use ?
If you were to use , you can just use an include file that checks
for on each page. Not sure if that's the best way but it may be
something that offers you the functionality as well as a much leaner
method than the Dreamweaver code.

SC
  Réponse avec citation
Vieux 27/06/2007, 00h21   #4
Ben Peddell
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie question = how to send variable form one page to the other

GD wrote:
> Newbie question = how to send variable form one page to the other
>
> i have a page with a very simple login. i want to be able to use the
> username variable to great the user by username when he reaches the
> page where he is redirected to. and at the same time get the ID field
> from my table which is and INT and PRIMARY_KEY.
>
> i've tried using a regular vairable and calling it back from the
> second page, but the second page doesn't read the first page's
> variable.
>
> btw, i'm using the login server behaviour that comes with dramweaver
> cs3 that adds the following code:
>
> $LoginRS__query=sprintf("SELECT username, password FROM information
> WHERE username=%s AND password=%s",
> GetSQLValueString($loginUsername, "text"),
> GetSQLValueString($password, "text"));
>
> $LoginRS = mysql_query($LoginRS__query, $WebParashaDB) or
> die(mysql_error());
> $loginFoundUser = mysql_num_rows($LoginRS);
> if ($loginFoundUser) {
> $loginStrGroup = "";
>
> //here is where i need to enter my text
>
>
> //declare two session variables and assign them
> $_SESSION['MM_Username'] = $loginUsername;
> $_SESSION['MM_UserGroup'] = $loginStrGroup;
>
> if (isset($_SESSION['PrevUrl']) && false) {
> $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
> }
> header("Location: " . $MM_redirectLoginSuccess );
> }
> else {
> header("Location: ". $MM_redirectLoginFailed );
> }
> }
> ?>
>
> any would be appreciated.
>
> thank you very much,
> GD
>


Does this look more like what you want?

// Get the loginUsername and password from the request
$loginUsername = $_REQUEST['loginUsername'];
$password = $_REQUEST['password'];
// Create a query using the loginUsername and password
// We want the username, usergroup and ID
$LoginRS__query=sprintf("SELECT username, usergroup, ID
FROM information
WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"),
GetSQLValueString($password, "text"));
// Execute the query or die with the mysql error
$LoginRS = mysql_query($LoginRS__query, $WebParashaDB) or
die(mysql_error());
// If there is at least one row, then we have succeeded.
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {

//here is where i need to enter my text

// Fetch the data from the row
$loginRow = mysql_fetch_assoc($LoginRS);
// declare three session variables and assign them
$_SESSION['MM_Username'] = $loginRow['username'];
$_SESSION['MM_UserGroup'] = $loginRow['usergroup'];
$_SESSION['MM_ID'] = $loginRow['ID'];
// FALSEd out: If there was a previous URL, then go to it.
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
// Redirect to the Login Success page
header("Location: " . $MM_redirectLoginSuccess );
}
// Otherwise
else {
// Redirect to the Login Failed page
header("Location: ". $MM_redirectLoginFailed );
}
}
  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 23h33.


Édité par : vBulletin® version 3.7.2
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
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12174 seconds with 12 queries