Left Quote    Black holes are where God divided by zero.
- Steven Wright    
Right Quote
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply

        Viewing Topic: PHP login sessions
  This user is offline  viospace
  Subject: "PHP login sessions" Posted: @ 3:26 am on Aug 01 2008   

Member #: 717
Rank: user - (7)
Since: 07/13/08
Posts: 4
From: Fairless Hills, PA

I finally understand enough of the login coding from here and about four other sites. I plan on printing each one out and comparing them visually on paper. This isn't completely necessary but it's best to optimize and put together a final set of files. I think it's best to do more copy from many just like the allsyntax quote.

One realization was understanding that session_star t(); needs to be on top of the pages. It's needed because there are session variables that look like this:

session_is_regi stered("us ername"

$_SESSION['user name']

$_SESSION['logg edin']

The main idea is that the login.php code checks to see if the $POST['username '] , i.e. the variable set from the submit button, is within the database. To do this the connection must be made to mysql. If it is, it will then register the session:

session_regi ster("myus ername";
session_registe r("mypassw ord";

and take you to, i.e. redirect to a main page using a header callout:

header(" ;location:index .php";

One nice bit of code will strip characters, not sure which ones yet, something to look up. Looks like a nice line to use.

$name = mysql_real_esca pe_string($_POS T['username']); // The function mysql_real_esca pe_string() stops hackers!

and another site uses:

$mypassword = stripslashes($m ypassword);
$myusername = mysql_real_esca pe_string($myus ername);


dogstar "I want a sandwich!"
    Viewed: 3,372 Times | Reply to This | To top
Viewing Page: 1 of 1

You must be logged in to post on the forums. Login or Register

"" Copyright © 2002-2021; All rights lefted, all lefts righted.
Privacy Policy