Jump to content

Redirecting


Drezard

Recommended Posts

Hello, Just wondering, How would i redirect this script (I cant use headers, it wont let me). I just need it to redirect to login_sucess.php automatically or it could say "please click here to goto login_sucess.php"

Help would be much appreciated, Thanks

Script:

[code]
<?php
session_start();
if (isset($_POST['submit'])) {  // check to see if the forum has been submitted
    //  where is tasys 'submit', use the name of the submit button on the form
   include('connect.php');
   // get form input
    // check to make sure it's all there
    // escape input values for greater safety
    $user = empty($_POST['user']) ? die ("ERROR: Enter a Username") : mysql_escape_string($_POST['user']);
    $pass = empty($_POST['pass']) ? die ("ERROR: Enter a Password") : mysql_escape_string($_POST['pass']);
   $sql="SELECT * FROM users WHERE user='$user' and pass='$pass'";
   $result=mysql_query($sql);
   // Mysql_num_row is counting table rows
   $count=mysql_num_rows($result);
   // If result matched $user and $pass, table row must be 1 row
   if($count==1){
      // Register $user, $pass and redirect to file "login_success.php" and make cookie to save user data
$_SESSION['userinfo'] = mysql_fetch_array($result);

   }
   else {
      echo "Wrong Username or Password";
   }
}

?>

<html>
<head>
</head>

<body>

<?php
if (!isset($_POST['submit'])) {
// form not submitted
?>

    <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
    Username: <input type="text" name="user">
    Password: <input type="text" name="pass">
    <input type="submit" name="submit">
    </form>

<?php
}
?>

</body>
</html>
[/code]

Thanks, Daniel
Link to comment
Share on other sites

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.