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 > [PHP] storing / processing login info (newbie stuff not intutorials)
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
[PHP] storing / processing login info (newbie stuff not intutorials)

Réponse
 
LinkBack Outils de la discussion
Vieux 14/03/2008, 16h01   #1
good_times
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut [PHP] storing / processing login info (newbie stuff not intutorials)


1. instead of typing: $conn=ocilogon("usrname","passwrd","db");
can i save this info in a file and have my php script either include or call
it when it needs to make a db connection? what would that look like? i may
want to point my app to a test db at some point & it would be nice to only
change it in one place.

2. i see an example where a form in a login.html submits to "authcheck.php"
but authcheck.php just prints ('User not found in LDAP' or 'error occured'
or 'success'). how can authcheck.php redirect the user to... say.. BACK to
the login.html and tell it "yes or no" and then have login.html either
direct the user to a different data entry page (if the login was good), or
display "sorry, try again" - all from the 1 form's "submit"

thanx in advance,
mike.
--
View this message in context: http://www.nabble.com/storing---proc...p16048165.html
Sent from the PHP - General mailing list archive at Nabble.com.

  Réponse avec citation
Vieux 14/03/2008, 16h15   #2
tedd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] storing / processing login info (newbie stuff not intutorials)

At 8:01 AM -0700 3/14/08, good_times wrote:
>1. instead of typing: $conn=ocilogon("usrname","passwrd","db");
>can i save this info in a file and have my php script either include or call
>it when it needs to make a db connection? what would that look like? i may
>want to point my app to a test db at some point & it would be nice to only
>change it in one place.


Use:

include('config.php');

Where:

$usrname = 'username';
$passwrd = 'password';
$db = 'mydB';

In your script

include('config.php');
$conn=ocilogon($usrname,$passwrd,$db);



>2. i see an example where a form in a login.html submits to "authcheck.php"
>but authcheck.php just prints ('User not found in LDAP' or 'error occured'
>or 'success'). how can authcheck.php redirect the user to... say.. BACK to
>the login.html and tell it "yes or no" and then have login.html either
>direct the user to a different data entry page (if the login was good), or
>display "sorry, try again" - all from the 1 form's "submit"


If ($auth != true)
{
header('Location: http://www.example.com/login.html');
}

It's all in the manuals.

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Réponse avec citation
Vieux 14/03/2008, 16h19   #3
Shawn McKenzie
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] storing / processing login info (newbie stuff not intutorials)

good_times wrote:
> 1. instead of typing: $conn=ocilogon("usrname","passwrd","db");
> can i save this info in a file and have my php script either include or call
> it when it needs to make a db connection? what would that look like? i may
> want to point my app to a test db at some point & it would be nice to only
> change it in one place.
>
> 2. i see an example where a form in a login.html submits to "authcheck.php"
> but authcheck.php just prints ('User not found in LDAP' or 'error occured'
> or 'success'). how can authcheck.php redirect the user to... say.. BACK to
> the login.html and tell it "yes or no" and then have login.html either
> direct the user to a different data entry page (if the login was good), or
> display "sorry, try again" - all from the 1 form's "submit"
>
> thanx in advance,
> mike.


1. Normally you would have a file that is included in every file or most
files that does certain things like setup the db connection, etc...
This file can also include other files based upon some other logic that
you define, but a simple example would be to include('db_config.php');
in your pages:

db_config.php

$db_username = 'myusername';
$db_password = 'somepassword';
$db_name = 'mydb';

Then you can use those vars in your code.

2. Just have the login.html form submit to itself. At the top of the
file check to see if it is a POST request and if so check the user
credentials, set a session var that shows that they are loggedin and use
header() to redirect to the correct page.

-Shawn
  Réponse avec citation
Vieux 14/03/2008, 17h38   #4
Philip Thompson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] storing / processing login info (newbie stuff not in tutorials)

On Mar 14, 2008, at 10:15 AM, tedd wrote:

> At 8:01 AM -0700 3/14/08, good_times wrote:
>> 1. instead of typing: $conn=ocilogon("usrname","passwrd","db");
>> can i save this info in a file and have my php script either
>> include or call
>> it when it needs to make a db connection? what would that look
>> like? i may
>> want to point my app to a test db at some point & it would be nice
>> to only
>> change it in one place.

>
> Use:
>
> include('config.php');
>
> Where:
>
> $usrname = 'username';
> $passwrd = 'password';
> $db = 'mydB';
>
> In your script
>
> include('config.php');
> $conn=ocilogon($usrname,$passwrd,$db);
>
>
>
>> 2. i see an example where a form in a login.html submits to
>> "authcheck.php"
>> but authcheck.php just prints ('User not found in LDAP' or 'error
>> occured'
>> or 'success'). how can authcheck.php redirect the user to... say..
>> BACK to
>> the login.html and tell it "yes or no" and then have login.html
>> either
>> direct the user to a different data entry page (if the login was
>> good), or
>> display "sorry, try again" - all from the 1 form's "submit"

>
> If ($auth != true)
> {
> header('Location: http://www.example.com/login.html');


exit;

This will potentially save you some headaches.... Read more at:

http://php.net/header


> }
>
> It's all in the manuals.
>
> Cheers,
>
> tedd
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com



HTH,
~Philip

"Personally, most of my web applications do not have to factor 13.7
billion years of space drift in to the calculations, so PHP's rand
function has been great for me..." ~S. Johnson
  Réponse avec citation
Vieux 14/03/2008, 18h46   #5
tedd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] storing / processing login info (newbie stuff not intutorials)

At 11:38 AM -0500 3/14/08, Philip Thompson wrote:
>On Mar 14, 2008, at 10:15 AM, tedd wrote:
>>At 8:01 AM -0700 3/14/08, good_times wrote:
>>>2. i see an example where a form in a login.html submits to "authcheck.php"
>>>but authcheck.php just prints ('User not found in LDAP' or 'error occured'
>>>or 'success'). how can authcheck.php redirect the user to... say.. BACK to
>>>the login.html and tell it "yes or no" and then have login.html either
>>>direct the user to a different data entry page (if the login was good), or
>>>display "sorry, try again" - all from the 1 form's "submit"

>>
>>If ($auth != true)
>> {
>> header('Location: http://www.example.com/login.html');

>
>exit;
>
>This will potentially save you some headaches.... Read more at:
>
>http://php.net/header
>


Yeah, you're right. But I didn't see headaches = OFF in the OP's question. :-)

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  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 03h34.


É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,17717 seconds with 13 queries