RE: [PHP] Member's Area Script
| From: | Stephen Craton | Date: | Sat, 28 Sep 2002 23:56:25 +0000 |
| Subject: | RE: [PHP] Member's Area Script | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-117997@lists.php.net to get a copy of this message | ||
Thank you very much!!!
Thanks,
Stephen
http://www.melchior.us
http://php.melchior.us
:: -----Original Message-----
:: From: debbie_dyer [mailto:debbie_dyer@surfanytime.co.uk]
:: Sent: Saturday, September 28, 2002 6:03 PM
:: To: php-general@lists.php.net
:: Subject: Re: [PHP] Member's Area Script
::
::
::
:: $conn = $main; <- that line is the problem - you cant use
:: global vars inside functions without declaring them as global
::
:: ----- Original Message -----
:: From: "Stephen Craton" <webmaster@melchior.us>
:: To: <php-general@lists.php.net>
:: Sent: Saturday, September 28, 2002 11:49 PM
:: Subject: [PHP] Member's Area Script
::
::
:: > Hello again,
:: >
:: > I'm trying to write a script that has a member's area in
:: it. So far
:: > I've been able to successfully validate only one username
:: and only one
:: > password but now I'm going big and trying to compare it
:: with a table
:: > in my MySQL database. Everything goes nice and smooth
:: until I actually
:: > try and enter in my username and password. I type it in, copy and
:: > paste, whaetever and it tells me the error I wanted it to say "The
:: > username and password is not a good combo." I've copied
:: and pasted the
:: > username and password from the database directly yet it
:: still gives me
:: > this error. Here's my code for the login() function that
:: logs the user
:: > in:
:: >
:: > function login($username, $password)
:: > {
:: > $conn = $main;
:: > if (!$conn)
:: > return 0;
:: >
:: > $result = mysql_query("select * from user
:: > where username='$username'
:: > and passwd = '$password'");
:: > if (!$result)
:: > return 0;
:: >
:: > if (mysql_num_rows($result)>0)
:: > return 1;
:: > else
:: > return 0;
:: > }
:: >
:: > Here's the code for the part that calls the login() function:
:: >
:: > if(login($user, $pass))
:: > {
:: > $valid_user = $user;
:: > session_register("valid_user");
:: > }
:: > else
:: > {
:: > echo "<font face='Arial, Helvetica, sans-serif'
:: > size='3'><center><b>You supplied an invalid username and password
:: > combo. Try again please.</b></center>"; exit;
:: > }
:: >
:: > And here's the part that connects to the database:
:: >
:: > <?php
:: > # FileName="Connection_php_mysql.htm"
:: > # Type="MYSQL"
:: > # HTTP="true"
:: > $hostname_main = "localhost";
:: > $database_main = "mom";
:: > $username_main = "root";
:: > $password_main = "";
:: > $main = mysql_pconnect($hostname_main, $username_main,
:: $password_main)
:: > or die(mysql_error()); ?>
:: >
:: > Does anyone see why it's doing this to me? Please help!!
:: >
:: > Thanks,
:: > Stephen
:: > http://www.melchior.us
:: > http://php.melchior.us
:: >
:: >
:: >
:: > --
:: > PHP General Mailing List (http://www.php.net/)
:: > To unsubscribe, visit: http://www.php.net/unsub.php
:: >
::
::
:: --
:: PHP General Mailing List (http://www.php.net/)
:: To unsubscribe, visit: http://www.php.net/unsub.php
::
::