PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Re: Using SESSION in PHP
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: Using SESSION in PHP

Réponse
 
LinkBack Outils de la discussion
Vieux 07/01/2008, 06h50   #1
jcage@lycos.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Using SESSION in PHP

On Jan 6, 9:43 pm, "J.O. Aho" <u...@example.net> wrote:
> jc...@lycos.com wrote:
> > Hello,

>
> > I have a form that uses a basic passphrase to ensure an employee user
> > is who they say they are. One field uses 'text' as the input type and
> > the other uses 'password'. When a query has been run, a user can
> > click the browser back button and the name is still there intact but
> > the password field is blank. My question is, what would the 'SESSION'
> > code look like that would allow a user to click their back button
> > where the 'userpass' field holds the original passphrase in the same
> > manner the browser holds the user name within the text field?

>
> Using Session will require that the user is logged in before the password will
> be there.
>
> --- page that gets the username/password ---
> session_start();
> $_SESSION['password']=$_POST['userpass']; // we assume you use default post
> --- eoe ---
>
> --- the login form ---
> <td>User Password:</td><td align="left"><input type="password"
> name="userpass" size="29" maxlength="30" value="<?php echo
> $_SESSION['password']; ?>"></td></tr>
> --- eoe ---
>
> If you want the password to be stored between sessions, then you have to use
> , which means you store the password in plain text on the client computer.
>
> I suggest you talk with the system administration and ask if it would be
> possible to upgrade the browsers to a more modern one, visit mozilla.org if
> you want a browser that can store both the username and password and on top of
> all encrypts the password it stores.
>
> --
>
> //Aho


Hmmm... Guess I'm back to looking at using . :-) As I
searched for a solution, I happened across http://www.phpfreaks.com/tutorials/120/0.php
and tweaked some code to get it to return 'something' in the password
field, just not what I was looking for. thanks for the replies, all...
  Réponse avec citation
Vieux 07/01/2008, 12h45   #2
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Using SESSION in PHP

jcage@lycos.com wrote:
> On Jan 6, 9:43 pm, "J.O. Aho" <u...@example.net> wrote:
>> jc...@lycos.com wrote:
>>> Hello,
>>> I have a form that uses a basic passphrase to ensure an employee user
>>> is who they say they are. One field uses 'text' as the input type and
>>> the other uses 'password'. When a query has been run, a user can
>>> click the browser back button and the name is still there intact but
>>> the password field is blank. My question is, what would the 'SESSION'
>>> code look like that would allow a user to click their back button
>>> where the 'userpass' field holds the original passphrase in the same
>>> manner the browser holds the user name within the text field?

>> Using Session will require that the user is logged in before the password will
>> be there.
>>
>> --- page that gets the username/password ---
>> session_start();
>> $_SESSION['password']=$_POST['userpass']; // we assume you use default post
>> --- eoe ---
>>
>> --- the login form ---
>> <td>User Password:</td><td align="left"><input type="password"
>> name="userpass" size="29" maxlength="30" value="<?php echo
>> $_SESSION['password']; ?>"></td></tr>
>> --- eoe ---
>>
>> If you want the password to be stored between sessions, then you have to use
>> , which means you store the password in plain text on the client computer.
>>
>> I suggest you talk with the system administration and ask if it would be
>> possible to upgrade the browsers to a more modern one, visit mozilla.org if
>> you want a browser that can store both the username and password and on top of
>> all encrypts the password it stores.
>>
>> --
>>
>> //Aho

>
> Hmmm... Guess I'm back to looking at using . :-) As I
> searched for a solution, I happened across http://www.phpfreaks.com/tutorials/120/0.php
> and tweaked some code to get it to return 'something' in the password
> field, just not what I was looking for. thanks for the replies, all...
>


That's a little old (over 4 years) and a bit out of date. You don't
need set(); just use $_.

You also don't need to store the password in plain text on the user's
machine. You could easily hash the password.

Some ideas - untested, but alter as required to suit your needs:

$userid = ''; // Initialize the values
$password = '';
$hashedpw = '';
if (isset($_['userid'])) { // If userid is in
$userid = $_['userid']);
if (isset($_['password'])) // Check for hashed password
$hashedpw = $_['password'));
}

... other stuff, as necessary ...

if ($userid <> '') {
$result = mysql_query("SELECT pw, MD5(pw) AS hashedpw FROM users " .
"WHERE userid = $userid");
if ($result) {
$data = mysql_fetch_assoc($result);
if ($data) {
if (($data['hashedpw'<>'') && ($data['hashedpw']==$hashedpw))
$password = $data['password'];
}

... other stuff, as necessary ...


<input type=text name="userid" value="<?php echo $userid;?>">
<input type=password name="password" value="<php echo $password;?>">


But this won't necessarily you when the user uses the back button.
With the back button, your browser is probably pulling the information
from the cache. If the password was filled in by the above code (i.e.
the existed and was valid) the first time the user displayed the
page, the password should be filled in the second time. But if the user
typed in the password, the password may not be filled in. This
operation is browser dependent and there isn't anything you can do about
it from the PHP end.



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

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


É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,09829 seconds with 10 queries