Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 9th, 2006, 11:10 AM
Registered User
 
Join Date: Mar 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jon_stubber
Default chapter 12 user_login

This is driving me mad! For that 3 days ive checked the code for errors and it just dont work!

go to my web site, that i am doing for uni.

www.lsbuusedbookshop.co.uk

go to login. user name is 1234 and password 1234. i just says that that its incorrect , but the users in the DB. I duno what else to do , thought id ask people here the experts.

here the code... if any one can tell me why i be most greatful

<?php
session_start();
include "connect.inc.php";

if (isset($_POST['submit'])) {
  $query = "SELECT student_Id, password FROM members " .
           "WHERE student_Id = '" . $_POST['username'] . "' " .
           "AND password = (PASSWORD('" . $_POST['password'] . "'))";
  $result = mysql_query($query)
    or die(mysql_error());

 $row = mysql_fetch_array($result);

  if (mysql_num_rows($result) == 1) {
    $_SESSION['user_logged'] = $_POST['username'];
    $_SESSION['user_password'] = $_POST['password'];
    header ("Refresh: 5; URL=" . $_POST['redirect'] . "");
    echo "You are being redirected to your original page request!<br>";
    echo "(If your browser doesn't support this, " .
         "<a href=\"" . $_POST['redirect']. "\">click here</a>)";
  } else {
?>
<html>
<head>
<title>login_form</title>
</head>
<body>
<p>
  Invalid Username and/or Password<br>

  <form action="login_form.php" method="post">
    <input type="hidden" name="redirect"
      value="<?php echo $_POST['redirect']; ?>">
    Username: <input type="text" name="username"><br>
    Password: <input type="password" name="password"><br><br>
    <input type="submit" name="submit" value="submit">
  </form>
</p>
</body>
</html>
<?php
  }
} else {
  if (isset($_GET['redirect'])) {
    $redirect = $_GET['redirect'];
  } else {
    $redirect = "members.php";
  }
?>
<html>
<head>
<title>Beginning PHP5, Apache and MySQL</title>
</head>
<body>
<p>
  Login below by supplying your username/password...<br>
  Or <a href="register.php">click here</a> to register.<br><br>
  <form action="login_form.php" method="post">
    <input type="hidden" name="redirect"
      value="<?php echo $redirect; ?>">
    Username: <input type="text" name="username"><br>
    Password: <input type="password" name="password"><br><br>
    <input type="submit" name="submit" value="submit">
  </form>
</p>
</body>
</html>
<?php
}
?>

Plese anyone can help me , the project is in very shortly !!!

Thanks Jon


 
Old July 9th, 2006, 06:09 AM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Be sure when you are inserting the password, doing it this way:

INSERT INTO [...] PASSWORD('XJKCAD') [...];

I had that problem and that was the way for me.

Pd.- Sorry for my bad english.






Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 12/register/user_login airtime373 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 April 7th, 2008 08:14 PM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM
Errors on Chapter 12 example(12.8) sonnie ASP.NET 2.0 Professional 2 June 7th, 2006 10:55 AM
Chapter 12 Koga VB.NET 2002/2003 Basics 0 November 2nd, 2004 11:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.