![]() |
|
#1
|
|||
|
|||
PHP sessions problemi use this code to verify the username & password, but how to pass the username in every pages such as 'welcome andy' if andy login and 'welcome jack' if jack login.
this script is unsecure, what script should i include in every pages so when i enter localhost it will ask me to login first. PHP Code:
|
|
#2
|
||||
|
||||
|
Hello andy,
One quick question before I proceed; what is the version of your PHP? __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#3
|
|||
|
|||
|
php4
|
|
#4
|
||||
|
||||
|
I am going to assume you're using the latest version off PHP4 i.e. v.4.3.2 at the time of this posting.
Here's how I will go about assisting you get your session-thingy up. I'll write some code and functions here in this thread and you tell me if it makes sense to you (or if they simply don't work for you). I was planning to write a tutorial on this and you can help me help others by contributing to this post - how's that? __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#5
|
|||
|
|||
|
ok, but my php is not the latest version, about 4.0 something
|
|
#6
|
||||
|
||||
Password Protect web pages/site using PHP sessions and MySQLHey andy,
It took me a while but I think the script works just fine with what I have written so far. I've used your database / table structure in the example so it will be easier for you to follow. The link to the example files and the notes: Password Protect web pages/site using PHP sessions and MySQL. Please post your questions, suggestions and comments here in this thread. __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#7
|
|||
|
|||
GreatWonderful, JDS! I haven't implemented your code yet, but I was just coming to the point in my site development where I wanted to add password-protection to certain pages on my site. I just read a tutorial on Session Handling with PHP 4 (posted on zend.com), it was a good tutorial, but I'm going to try the implementation shown here instead. It's much more to the point.
samtediou Let us know how your implementation goes, andy |
|
#8
|
|||
|
|||
|
Well, I copied and pasted your example, JDS to my own webspace. You can see the result here:
braindivot.com I had to do several things to make it work, and it's still not working entirely. Maybe you could see where I've gone wrong. 1. I had to take out the initial forward slash (/) from all url references in the code. I'm not sure why. For example, my code reads like PHP Code:
instead of PHP Code:
2. I modified the db connection to call my own db, of course, and put some php script in the example_login.php to automatically write a valid username and password into the text boxes. Code:
When I try to logout, however, or try to login again by pasting the login url in the address window of a browser window that has already been used to run the script, I get this error message: Warning: Cannot modify header information - headers already sent by (output started at /home.../pass/example_session_functions.php:122) in /home.../pass/example_session_functions.php on line 72 What can I do? Samtediou |
|
#9
|
|||
|
|||
|
thanx a lot!
|
|
#10
|
||||
|
||||
|
Quote:
this line: PHP Code:
PHP Code:
Quote:
Are you certain that you pasted the code to logout.php including a space or a tab somewhere at the top (or bottom) of that page? Please recreate the file but this time, ensure that there are absolutely no occurance of whitespace before or after <?php ?> __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
Recent GIDBlog
NARMY by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| php sessions | mrjameer | MySQL / PHP Forum | 0 | 24-Oct-2006 05:26 |
| Problem with executing PHP in webpage | fdgloworm | Apache Web Server Forum | 0 | 13-Feb-2006 11:43 |
| Php Sessions & Smarty Templating Engine | ohm_ | MySQL / PHP Forum | 0 | 18-Jan-2006 00:42 |
| Alt. Problem: PHP 4.4 GD compilation errors | Fezzen | Computer Software Forum - Linux | 2 | 12-Aug-2005 21:16 |
| Apache / PHP problem, maybe output length? | HaganeNoKokoro | Apache Web Server Forum | 2 | 08-Sep-2004 07:22 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The