Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
| Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP 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
  #1 (permalink)  
Old March 9th, 2006, 10:51 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jon_stubber
Default begin php & mysql - chapter 12, user_form.php


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




  #2 (permalink)  
Old March 9th, 2006, 10:57 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jon_stubber
Default


The actual code this relates to is the user_login form for chapt 12 of begin php apach,mysql web delvelopmt.

See ive have the register.php page working, this registers a user then sends them to the memebers area. so i no the connection to DB is ok as the register.php checks to see if the student id is in the DB then if not it adds to DB. Ive loaded my mysql admin and the users are in the DB.



Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 12 modified register.php problem GOUR CHANDRA PAUL BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 April 27th, 2006 02:14 PM
Chp 12, common_db.inc & userviewer.php reques jaymax BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 February 1st, 2006 05:18 PM
Chapter 12 update_account.php file andrene BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 July 25th, 2005 07:00 PM
Chapter 12 - useraccount.php buzzuh BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 September 3rd, 2004 02:53 PM
Chapter 12 Transact-Article.php czambran BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 June 17th, 2004 01:58 PM





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