sylph Posted June 17, 2008 Share Posted June 17, 2008 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 More sharing options...
xtopolis Posted June 17, 2008 Share Posted June 17, 2008 You can try a header instead. <?php header("Location: index.php"); ?> I don't know why the meta refresh doesn't work. Remember if you're going to use the header method, you can't output anything to the page before using it. Link to comment https://forums.phpfreaks.com/topic/110612-meta-http-refresh/#findComment-567527 Share on other sites More sharing options...
whizard Posted June 17, 2008 Share Posted June 17, 2008 Your code should be: echo "<meta http-equiv=\"Refresh\" content=\"0;url=index.php\">"; note the url= before index.php\ HTH Dan Link to comment https://forums.phpfreaks.com/topic/110612-meta-http-refresh/#findComment-567632 Share on other sites More sharing options...
sylph Posted June 18, 2008 Author Share Posted June 18, 2008 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 More sharing options...
serverman Posted June 18, 2008 Share Posted June 18, 2008 Your code should be: echo "<meta http-equiv=\"Refresh\" content=\"0;url=index.php\">"; note the url= before index.php\ HTH Dan you know you can also just echo'<meta http-equiv="Refresh" content="0;url=index.php">'; you might need a 0\; but i dont know lol Link to comment https://forums.phpfreaks.com/topic/110612-meta-http-refresh/#findComment-567995 Share on other sites More sharing options...
sylph Posted June 18, 2008 Author Share Posted June 18, 2008 thanks but it didn't solve the problem.. Any other method?? Please help.. kinda desperate to get this thing working. Link to comment https://forums.phpfreaks.com/topic/110612-meta-http-refresh/#findComment-568299 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.