Jump to content

Recommended Posts

Below code is working fine but i need to redirect on 3 different pages and its giving me error. My table structure is as

 

User table

Email                                  Password

admin@yahoo.com             123

tariq@yahoo.com                987

bilal@yahoo.com                 456  

 

if user name is like; admin@yahoo.com the page should redirect on welcome.php

if user name is like; info@aiousoft.com the page should redirect to welcome2.php

and if user doesnot exist in database then give error as ELSE "user doesnot exist"

 

thanks

 

signin.php

 

<html><head><title>Sign In</title></head><body>
<?php include 'header.php'; ?>
<?php include 'menu.php'; ?>
<center>
<form method="post" action="checklogin.php">
  <h3>Please Signin</h3>
  <table width="400" border="0">
    <tr><td>Email</td>
      <td><input name="email" type="text" id="email"></td></tr>
    <tr><td>Password</td>
      <td><input name="password" type="password" id="password"></td></tr>
  </table>

 <p><label>
    <input type="submit" email="submit" value="Submit">
    </label><input email="reset" type="reset">
    </p>
  </form>
</center>
</body>
</html>

 

checklogin.php

<html><head><title>Check Login</title></head><body>
<?php
include 'header.php';
include 'menu.php';

$email=$_POST['email'];
$password=$_POST['password'];

@ $db = mysql_pconnect('localhost', 'root', '');
if (!$db)
{ echo 'Error: Could not connect to database. Please try again later.';
exit;}
mysql_select_db('car');
$q=mysql_query("select * from user where email='".$email."'  and password='".$password."' ") or die(mysql_error());
$res=mysql_fetch_row($q);
if($res)
{
 header('location:welcome.php');
}
else
{
  echo' Please signin again as your user name and password is not valid';
}
?>
</body>
</html>

 

 

header.php

menu.php

What error are you getting?

 

It seems it would be best to add a new column to your db's user table and hold the script name that you want that user to redirect to. Then when the user logs in redirect them to that page instead of in an if/else block.

 

In your else statement above, you have a misplaced quote in the echo statement (no space between echo and first quote)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.