View Single Post
 
Old September 25th, 2007, 11:38 AM
dbwieler dbwieler is offline
Registered User
 
Join Date: Sep 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default having a problem with login script

(these scripts are based off of chapter 13 in the "Beginning PHP, MySQL and APACHE" book.)
Whenever I try to login to my site, the login page passes through transact-user.php, but never redirects back to index.php. it sits at transact-user.php and shows a blank white page. I have also customized it so that none of the pages include the "header.php" that is in the book.

heres the login page, it's just a form and there is no PHP scripting on the page:
<form action="transact-user.php" method="post">

    Username:
    <input name="email" type="text">
    <br /><br />
    Password:
    <input name="passwd" type="password">
    <br /><br />
    <input type="submit" name="submit" value="Login">
  </form>

and heres the login/logout part of the transact-user.php page:

<?php
require_once 'conn.php';

if (isset($_REQUEST['action'])) {
  switch ($_REQUEST['action']) {
    case 'Login':
      if (isset($_POST['email'])
          and isset($_POST['passwd']))
      {
        $sql = "SELECT user_id, access_lvl,name " .
               "FROM cms_users " .
               "WHERE email='" . $_POST['email'] . "' " .
               "AND passwd='" . $_POST['passwd'] . "'";
        $result = mysql_query($sql, $conn)
          or die('Could not look up user information; ' .
                 mysql_error());

        if ($row = mysql_fetch_array($result)) {
          session_start();
          $_SESSION['user_id'] = $row['user_id'];
          $_SESSION['access_lvl'] = $row['access_lvl'];
          $_SESSION['name'] = $row['name'];
        }
      }
      redirect('index.php');
      break;

      case 'Logout':
      session_start();
      session_unset();
      session_destroy();

      redirect('index.php');
      break;
     ..... etc

I cannot for the life of me figure out why it does nothing after clicking the "login" button on the form except go to a blank white page. am I missing something?