Note that there are some explanatory texts on larger screens.

plurals
  1. PORedirect after a message "you have succesfully logged in" and "welcome back."
    primarykey
    data
    text
    <p>Hey guys, in this piece of code. Is there a way to redirect the user to the homepage after the messages "Welcome bace you will now be redirected to the homepage." and "You have succesfully logged in. you will now be redirected to the homepage." ?</p> <pre><code>OK I updated my code. Here it is: &lt;?php function redirect() { header('location: index.php'); } ?&gt; &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; &lt;html lang="en" &gt; &lt;head&gt; &lt;title&gt;Login | JM Today &lt;/title&gt; &lt;link href="Mainstyles.css" type="text/css" rel="stylesheet" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container"&gt; &lt;?php include("header.php"); ?&gt; &lt;?php include("navbar.php"); ?&gt; &lt;?php include("checkcook.php") ?&gt; &lt;div id="wrap"&gt; &lt;?php ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); $conn=mysql_connect("localhost", "***", "***") or die(mysql_error()); mysql_select_db('jmtdy', $conn) or die(mysql_error()); if(isset($_COOKIE['jmuser']) &amp;&amp; isset($_COOKIE['jmpass'])){ $status=checkCookie($_COOKIE['jmuser'], $_COOKIE['jmpass']); if($status==true){ echo '&lt;p class="statusmsg"&gt; Welcome back'.$_COOKIE['jmuser'].'. You will now be redirected to the homepage.&lt;/p&gt;'; sleep(5); redirect(); } } else{ if(isset($_POST['sublogin'])){ if(( strlen($_POST['user']) &gt;0) &amp;&amp; (strlen($_POST['pass']) &gt;0)) { checklogin($_POST['user'], $_POST['pass']); } elseif((isset($_POST['user']) &amp;&amp; empty($_POST['user'])) || (isset($_POST['pass']) &amp;&amp; empty($_POST['pass']))){ echo '&lt;p class="statusmsg"&gt;You didn\'t fill in the required fields.&lt;/p&gt;&lt;br/&gt;&lt;input type="button" value="Retry" onClick="location.href='."'login.php'\"&gt;"; } } else{ echo '&lt;p class="statusmsg"&gt;You came here by mistake, didn\'t you?&lt;/p&gt;'; } function checklogin($username, $password){ $username=mysql_real_escape_string($username); $password=mysql_real_escape_string($password); $result=mysql_query("select * from users where username = '$username'"); if($result != false){ $dbArray=mysql_fetch_array($result); $dbArray['password']=mysql_real_escape_string($dbArray['password']); $dbArray['username']=mysql_real_escape_string($dbArray['username']); if(($dbArray['password'] != $password ) || ($dbArray['username'] != $username)){ echo '&lt;p class="statusmsg"&gt;The username or password you entered is incorrect. Please try again.&lt;/p&gt;&lt;br/&gt;&lt;input type="button" value="Retry" onClick="location.href='."'login.php'\"&gt;"; return; } $_SESSION['username']=$username; $_SESSION['password']=$password; if(isset($_POST['remember'])){ setcookie("jmuser",$_SESSION['username'],time()+60*60*24*356); setcookie("jmpass",$_SESSION['username'],time()+60*60*24*356); } echo'&lt;p class="statusmsg"&gt; You have successfully logged in. You will now be redirected to the homepage.&lt;/p&gt;'; sleep(5); redirect(); } else{ echo'&lt;p class="statusmsg"&gt; The username or password you entered is incorrect. Please try again.&lt;/p&gt;&lt;br/&gt;input type="button" value="Retry" onClick="location.href='."'login.php'\"&gt;"; return; } } } ?&gt; &lt;/div&gt; &lt;br/&gt; &lt;br/&gt; &lt;?php include("footer.php") ?&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>But now, whatever I do (blank login, wrong password/username, ...) I don't get any message, and I'm not even redirected. Its just the header and a blank page.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload