Note that there are some explanatory texts on larger screens.

plurals
  1. POI want to show username and password who is loggedin
    primarykey
    data
    text
    <p>I am trying to make a profile page of user who is logged in so I want if user who is logged in click on his profile page it will show him his user name and password but i don't know what I am doing wrong here is code</p> <p><strong>login.php</strong></p> <pre><code>&lt;?php $username = "root"; $password = "123"; $hostname = "localhost"; $dbhandle = mysql_connect($hostname, $username, $password) or die("Could not connect to database"); $selected = mysql_select_db("login", $dbhandle); $myusername = $_POST['user']; $mypassword = $_POST['pass']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $query = "SELECT * FROM users WHERE Username='$myusername' and Password='$mypassword'"; $result = mysql_query($query); $count = mysql_num_rows($result); mysql_close(); if($count==1){ $seconds = 120 + time(); setcookie(loggedin, date("F jS - g:i a"), $seconds); header("location:login_success.php"); }else{ echo 'Incorrect Username or Password'; } ?&gt; </code></pre> <p><strong>login_success.php</strong></p> <pre><code>&lt;?php if(!isset($_COOKIE['loggedin'])){ header("location:index.php"); } ?&gt; &lt;html&gt; &lt;body&gt; &lt;h1&gt;Welcome!&lt;/h1&gt; &lt;a href="profile.php"&gt;Profile&lt;/a&gt; &lt;a href="logout.php"&gt;Logout&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>profile.php</strong></p> <pre><code>&lt;?php session_start(); ?&gt; &lt;html&gt; &lt;head&gt;&lt;title&gt;Profile&lt;/title&gt;&lt;/head&gt; &lt;body&gt; &lt;H2&gt;User Profile&lt;/h2&gt; &lt;/body&gt; &lt;/html&gt; &lt;?php $link = mysql_connect('localhost', 'root', '123'); if (!$link) { die('Could not connect: ' . mysql_error()); } if (!mysql_select_db('login')) { die('Could not select database: ' . mysql_error()); } $result = mysql_query('SELECT * FROM users where username=$myusername'); if (!$result) { die('Could not query:' . mysql_error()); } echo mysql_result($result,0,0); mysql_close($link); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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