Jump to content


This topic is now archived and is closed to further replies.


User authentication HELP by using IF ELSEIF and ELSE statement and redirect page on 3 differnet urls

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"






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

    <input type="submit" email="submit" value="Submit">
    </label><input email="reset" type="reset">



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


@ $db = mysql_pconnect('localhost', 'root', '');
if (!$db)
{ echo 'Error: Could not connect to database. Please try again later.';
$q=mysql_query("select * from user where email='".$email."'  and password='".$password."' ") or die(mysql_error());
  echo' Please signin again as your user name and password is not valid';





Share this post

Link to post
Share on other sites

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)

Share this post

Link to post
Share on other sites

  • 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.