Note that there are some explanatory texts on larger screens.

plurals
  1. POPhp session echo not showing anymore?
    text
    copied!<p>I have this php that is a login screen then goes to the profile page, and there it is suppose to echo out the users; username and email on the screen. I had it working before haven't changed anything but now only the username prints out. </p> <p>This is the login php:</p> <pre><code>public function Login($username, $password){ if(!empty($username) &amp;&amp; !empty($password)){ $stmt = $this-&gt;db-&gt;prepare("SELECT username, password, email FROM users WHERE BINARY username = ? AND BINARY password = ?"); $stmt-&gt;bindParam(1,$username); $stmt-&gt;bindParam(2,$password); $stmt-&gt;execute(); if($stmt-&gt;rowCount() == 1){ $_SESSION['username'] = $username; $email = $stmt-&gt;fetchColumn(2); $email = $_SESSION['email']; header('Location: http://www.mywebsite.com/dev/profile.php'); }else{ echo "Incorrect username or password please try again."; } }else{ echo "Must type username or password."; } } </code></pre> <p>This is the profile php : </p> <pre><code>&lt;?php session_start(); $username = $_SESSION["username"]; $email = $_SESSION["email"]; if(!$_SESSION["username"]){ header("Location: http://www.mywebsitelogin.com/dev/"); } </code></pre> <p>And this is how im echoing it out:</p> <pre><code>&lt;?php echo '&lt;h1&gt;'.htmlentities($username).'&lt;/h1&gt;'; ?&gt; &lt;?php echo '&lt;h3&gt;'.htmlentities($email).'&lt;/h3&gt;'; ?&gt; </code></pre> <p>Also on a side question is there a more constant way of including a file inside a php other than include_once(). Because it's happened where that part of the php code fails for no reason when refreshing or entering a page.</p>
 

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