Topic: what code do i need to change

hi what code do i need to change if i want users who logged in invalid information to be redirected to another page instead of the original log in page.

<?
include_once "connect.php";
include_once "functions.php";

if (isset ( $_GET ["logout"] )) {
    $_SESSION ['user'] = 0;
    $msg = "Logged Out";
    header('location: index.php');
    exit();
}


if ($userid) {
    $msg = "Already Logged";
    header('location: members.php');
    exit();
}
elseif (isset ( $_POST ["password"] ) && isset ( $_POST ["email"] )) {
    $inEmail    = fixquotes ( $_POST ["email"] );
    $inPassword = fixquotes ( $_POST ["password"] );
    $rs = mysql_query ( "SELECT id FROM users AS u WHERE email='$inEmail' AND password='$inPassword'" ) or die ( mysql_error () );
    if (mysql_num_rows ( $rs )) {
      list($userid) = mysql_fetch_array ( $rs );
        $_SESSION ['user'] = $userid;
        $msg = "Logged in";
        header('location: members.php');
      exit();
    } elseif ($_REQUEST['register']) {
     $inName  = fixquotes($_REQUEST['name']);
     $street = fixquotes($_REQUEST['street']);
     $city = fixquotes($_REQUEST['city']);
     $state = fixquotes($_REQUEST['state']);
     $zipcode = fixquotes($_REQUEST['zipcode']);
     $website = fixquotes($_REQUEST['website']);
     $firstName = fixquotes($_REQUEST['firstName']);
     $lastName = fixquotes($_REQUEST['lastName']);
     $workPhone = fixquotes($_REQUEST['workPhone']);
     $cellPhone = fixquotes($_REQUEST['cellPhone']);
     $fax = fixquotes($_REQUEST['fax']);
     $dot = fixquotes($_REQUEST['dot']);
     $mc = fixquotes($_REQUEST['mc']);
     $trucks = intval($_REQUEST['trucks']);
     $website = "http://".str_replace("http://", "", $website);
     if (!$inName || !$inEmail || !$inPassword || !checkEmail($inEmail) || !$state
         || !$firstName || !$workPhone || !$dot) {
      $msg = "Invalid Registery Details";
     } else {
      mysql_query("INSERT INTO users
                   (name, email, password, street, city, state, zipcode, website,
                   firstName, lastName, workPhone, cellPhone, fax, dot, mc, trucks)
                   VALUES('$inName', '$inEmail', '$inPassword', '$street', '$city',
                   '$state', '$zipcode', '$website', '$firstName', '$lastName',
                   '$workPhone', '$cellPhone', '$fax', '$dot', '$mc', '$trucks')") or die(mysql_error());
        $rs = mysql_query ( "SELECT id FROM users AS u WHERE email='$inEmail' AND password='$inPassword'" ) or die ( mysql_error () );
        list($userid) = mysql_fetch_array ( $rs );
          if ($userid) {
       $_SESSION ['user'] = $userid;
           $msg = "Registered Successfully";
       $headers  = "MIME-Version: 1.0\n";
       $headers .= "Content-type: text/html; charset=windows-1255\n";
       $headers .= "From: Movers Community <info@moverscommunity.com>\n";
       $MSG = "<div>
       Thank you for registering to MoversCommunity.com<br><br>
       These are your user details:<br><br>
       Company Name: $inName,<br>
       Contact Email: $inEmail,<br>
       Password: $inPassword,<br>
       Street: $street,<br>
       City: $city,<br>
       State: $state,<br>
       Zipcode: $zipcode,<br>
       Website: $website,<br>
       Contact First Name: $firstName,<br>
       Contact Last Name: $lastName,<br>
       Work Phone: $workPhone,<br>
       Cell Phone: $cellPhone,<br>
       Fax: $fax,<br>
       DOT#: $dot,<br>
       MC#: $mc,<br>
       # of Trucks: $trucks
       </div>";
           mail($inEmail, "Registered Successfully", $MSG, $headers);
      }
      else {
       $msg = "Invalid Registery Details";
      }
     }
    }
    else {
         $_SESSION ['user'] = 0;
         $msg = "Invalid Login Details";
    }
}

include "header.php";
?>
<h1><img src='07.png'> Login / Register</h1>
<?
if (!empty($msg)) {
echo "<div class=msg>$msg</div>";
if ($_SESSION['user']!=0) {//logged
  include "footer.php";
  exit();
}
}
?>

<span class=title>LOGIN</span>
<form method=post action='login.php'>
<table align=center style='border:1px solid #9999ff;width:250px; background:#eeeeff'>
    <tr>
        <td>
    Email:<br>
    <input style='margin-left:20px;width:150px' name=email value='<?=$_POST ['email']?>'> <br>
        Password:<br><input style='margin-left:20px;width:150px' AUTOCOMPLETE=OFF name=password type=password>
        </td></tr><tr><td align=right>
        <input type=submit value='Login'>
    </td>
    </tr>
</table>
</form>



<span class=title>OR REGISTER</span>

<form method=post action='login.php'>
<input name=register type=hidden value=1>
<table align="center" cellpadding="0" cellspacing="0" height="527"
width="544" style='border:1px solid #2165a5;background:#eeeeee'>
  <tbody>
    <tr bgcolor="#2165a5">
      <td colspan="2" height="26">&nbsp;&nbsp;&nbsp;<span style='color:white'>&nbsp;<strong>Company
Information</strong> </span></td>
    </tr>
    <tr>
      <td class="small" height="22" colspan=2>&nbsp;<span class='req'>*</span> Required Fields</td>
    </tr>
    <tr>
      <td height="26" width="200" align=right>
      Company Name <span class='req'>*</span>
      </td>
      <td width="286"><input class="textbox" maxlength="50" size="25" name="name" value='<?=$_POST['name']?>'> </td>
    </tr>
    <tr>
      <td height="26">
      <div align="right">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Street&nbsp;&nbsp;</div>
      </td>
        <td><input class="textbox" maxlength="50" size="25" name="street" value='<?=$_POST['street']?>'>
      </td>
    </tr>
    <tr>
      <td height="26">
      <div align="right">City&nbsp;&nbsp;</div>
      </td>
      <td><input class="textbox" maxlength="50" size="25" name="city" value='<?=$_POST['city']?>'>
      </td>
    </tr>
    <tr>
      <td height="28">
      <div align="right"><label id="VDaemonID_3">State<span class='req'>*</span>&nbsp;&nbsp;</label></div>
      </td>
      <td>
      <select name="state">
      <option value="" selected="selected">-Select State-</option>
<?getOptions(array_keys($states),$_POST['state']);?>
      </select>
      </td>
    </tr>
    <tr>
      <td height="26">
      <div align="right">Zip Code&nbsp;&nbsp;</div>
      </td>
      <td><input class="textbox" maxlength="10" size="10" name="zipcode" value='<?=$_POST['zipcode']?>'>
      </td>
    </tr>
    <tr>
      <td height="26">
      <div align="right">Website&nbsp;&nbsp;</div>
      </td>
      <td><input class="textbox" maxlength="512" size="25" name="website" value='<?=$_POST['website']?>'>
      </td>
    </tr>
    <tr bgcolor="#2165a5">
      <td colspan="2" height="26">&nbsp;&nbsp;&nbsp;&nbsp;<span
style='color:white'>Contact Information </span></td>
    </tr>
    <tr>
      <td height="26">
      <div align="right"><label id="VDaemonID_4">Contact First Name
<span class='req'>*</span>&nbsp;&nbsp;</label></div>
      </td>
      <td><input class="textbox" maxlength="25" size="25"
name="firstName" value='<?=$_POST['firstName']?>'> </td>
    </tr>
    <tr>
      <td height="26">
      <div align="right">Contact Last Name &nbsp;&nbsp;</div>
      </td>
      <td><input class="textbox" maxlength="25" size="25"
name="lastName" value='<?=$_POST['lastName']?>'> </td>
    </tr>
    <tr>
      <td height="26">
      <div align="right"><label id="VDaemonID_5">Contact Work Phone
<span class='req'>*</span>&nbsp;&nbsp;</label></div>
      </td>
      <td><input class="textbox" maxlength="25" size="15"
name="workPhone" value='<?=$_POST['workPhone']?>'> </td>
    </tr>
    <tr>
      <td height="26">
      <div align="right">Contact Cell Phone&nbsp;&nbsp;</div>
      </td>
      <td><input class="textbox" maxlength="25" size="15"
name="cellPhone" value='<?=$_POST['cellPhone']?>'></td>
    </tr>
    <tr>
      <td height="26">
      <div align="right">Contact Fax Number&nbsp;&nbsp;</div>
      </td>
      <td><input class="textbox" maxlength="25" size="15" name="fax" value='<?=$_POST['fax']?>'></td>
    </tr>
    <tr>
      <td height="26">
      <div align="right"><label id="VDaemonID_6">Contact E-mail
<span class='req'>*</span>&nbsp;&nbsp;</label></div>
      </td>
      <td><input class="textbox" maxlength="75" size="25"
name="email" value='<?=$_POST['email']?>'> </td>
    </tr>
    <tr>
      <td height="26">
      <div align="right"><label id="VDaemonID_6">Required Password
<span class='req'>*</span>&nbsp;&nbsp;</label></div>
      </td>
      <td><input class="textbox" maxlength="75" size="25"
name="password" value='<?=$_POST['password']?>'> </td>
    </tr>
    <tr bgcolor="#2165a5">
      <td colspan="2" height="26">&nbsp;&nbsp;&nbsp;&nbsp;<span
style='color:white'>Truck Information</span></td>
    </tr>
    <tr>
      <td height="26">
      <div align="right"><label id="VDaemonID_7">DOT Number
<span class='req'>*</span>&nbsp;&nbsp;</label></div>
      </td>
      <td><input class="textbox" maxlength="8" size="8"
name="dot" value='<?=$_POST['dot']?>'> </td>
    </tr>
    <tr>
      <td height="26">
      <div align="right">MC Number&nbsp;&nbsp;</div>
      </td>
      <td><input class="textbox" maxlength="6" size="6"
name="mc" value='<?=$_POST['mc']?>'></td>
    </tr>
    <tr>
      <td height="28">
      <div align="right">Number of Trucks&nbsp;&nbsp;</div>
      </td>
      <td>
      <select name="trucks">
      <option value="" selected="selected">-Select-</option>
<?
$trackArr = array();
for ($i=1; $i<=25; ++$i)
$trackArr[] = $i;
getOptions(array_keys($trackArr), $_POST['trucks']);
?>
      </select>
      </td>
    </tr>

    <tr>
      <td colspan="2" height="28">
      <div align="center"><input value="Continue" name="cmdSubmit"
type="submit"> </div>
      </td>
    </tr>
  </tbody>
</table>
</form>

<? include "footer.php";?>

Re: what code do i need to change

hi,

It would me much easier for peop;e to help you if you upload your file and post a link.

keep in mind that php is a server-side script, meaning it reside on the server and not all servers are configure the same, so it may not work on your test server but might work online on different configuration

Re: what code do i need to change

zevion wrote:

hi,

It would me much easier for peop;e to help you if you upload your file and post a link.

keep in mind that php is a server-side script, meaning it reside on the server and not all servers are configure the same, so it may not work on your test server but might work online on different configuration

In this case, providing the PHP code is actually better than posting a link, since obviously the PHP code won't show on the server.

In response to your question...

This is the bit of code that handles incorrect logins:

    else {
         $_SESSION ['user'] = 0;
         $msg = "Invalid Login Details";
    }

You could change it to something like this to redirect the user to an error page:

    else {
         $_SESSION ['user'] = 0;
         header('location: error.php');
    }

This uses the PHP header() function to change the page. I haven't tested this, but it should work fine. You'll need to change "error.php" to link to your error page.

Re: what code do i need to change

here is a link
http://moverscommunity.com/login.php the file is already uploaded on the web