Jump to content

Meta HTTP Refresh


sylph

Recommended Posts

Hi ppl,

 

I have this login page and after submit the form , it refresh the page itself by :

echo "<meta http-equiv=\"Refresh\" content=\"0;index.php\">";

 

It works fine in my local pc, but when I upload to the server, after login, the page got stuck at this line and the rest of the page is not displayed. And I have to refresh again on the browser and it works just fine. Has anyone encounter this before? How can I solve it?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/110612-meta-http-refresh/
Share on other sites

Hihi,

 

Thanks to you both for the reply =)

I tried both the method. If i use location header, I will get a header warning. I added in "url" to my code, but the problem is still there. Please help to see how I can improve this login form to make it auto refresh after login.

Thanks so much!!

 

Below is my script and my form. Above my <html> , I have :

session_start();

$username=$_SESSION['username'];

$userid=$_SESSION['userid'];

$userpass=$_SESSION['password'];

 

 

<? if($_POST['sublogin']) {

$login_error=array();

//session_register("login_error");

$flag=0;

/* Checks that username is in database and password is correct */

  $md5pass = md5($_POST['pass']);

  $result = confirmUser($_POST['email'], $md5pass);

/* Check error codes */

  if($result == 1){

  $flag=1;

$_SESSION['login_error']="Email address doesn't exist";

    }

  else if($result == 2){

  $flag=1;

                          $_SESSION['login_error']="Incorrect password, please try again";

}

if($flag==0) {

  session_unregister('login_error');

  /* Username and password correct, register session variables */

  $_POST['email'] = stripslashes($_POST['email']);

$_SESSION['username'] = $_POST['email'];

$_SESSION['password'] = $md5pass;

if(isset($_POST['remember'])){

setcookie("cookname", $_SESSION['username'], time()+60*60*24*100, "/");

setcookie("cookpass", $_SESSION['password'], time()+60*60*24*100, "/");

setcookie("cookid", $_SESSION['userid'], time()+60*60*24*100, "/");

}

echo "<meta http-equiv=\"Refresh\" content=\"0;url=index.php\">";

// header("Location: index.php");

 

}

}

?>

<?php if(!$username) { ?>

 

<form name="login" action="<? $PHP_SELF ?>" method="post">

 

<b>LOGIN</b> <br><br>

<?php  if($flag==1) {

          echo "<font color='#FF0000'>".$_SESSION['login_error']."</font>";

}

?>

<table>

<tr><td>EMAIL ADDRESS :</td><td><input type="text" name="email"></td></tr>

<tr><td>PASSWORD: </td><td><input type="password" name="pass"></td></tr>

            <tr><td colspan="2"><input type="checkbox" name="remember" >REMEMBER ME </td></tr>

            <tr><td colspan="2"><input type="submit" name="sublogin" value="Login"></td></tr>

</table>

</form>

Link to comment
https://forums.phpfreaks.com/topic/110612-meta-http-refresh/#findComment-567917
Share on other sites

Archived

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

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