Note that there are some explanatory texts on larger screens.

plurals
  1. POUsername behind URL
    primarykey
    data
    text
    <p>Hello Stack overflow currently I'm kind of stuck with my user_profile/username_here. The problem is that you can fill in every username you want and it still will show the made up username if you put it behind the '/' well I got that filtered out but now how do I let up show the username of the user that is logged in behind the URL? I'm also using URL rewriting. the htaccess:</p> <pre><code>RewriteEngine on RewriteBase / RewriteRule ^profile/([a-zA-Z0-9-\._]+)(\/)? /profile.php?username=$1 [L,QSA] </code></pre> <p>Here is the code I'm using for the user_profile.php:</p> <pre><code>&lt;?php require_once('db.php'); session_start(); if(!isset($_SESSION['id'])) { header("location: access_denied.php"); } else { $username = $_SESSION['username']; $firstname = $_SESSION['firstname']; $lastname = $_SESSION['lastname']; $result3 = mysql_query("SELECT * FROM tab where username='$username' AND firstname='$firstname' AND lastname='$lastname'"); if($row3 = mysql_fetch_array($result3)) { $username = $row3['username']; $firstname = $row3['firstname']; $lastname = $row3['lastname']; } ?&gt; &lt;html&gt; &lt;body&gt; &lt;table width="398" border="0" align ="center" cellpadding="0"&gt; &lt;tr&gt; &lt;td height ="26" colspan="2"&gt;Profile info&lt;/td&gt; &lt;td&gt;&lt;div align="right"&gt;&lt;a href="log_out.php"&gt;Logout&lt;/a&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="129" rowspan="5"&gt;&lt;img src="&lt;?php echo $picture?&gt;" width="129" height="129" alt="no image found"/&gt;&lt;/td&gt; &lt;td width="82" valign="top"&gt;&lt;div align="left"&gt;Username:&lt;/div&gt;&lt;/td&gt; &lt;td width="165" valign="top"&gt;&lt;?php echo $username ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="82" valign="top"&gt;&lt;div align="left"&gt;Firstname:&lt;/div&gt;&lt;/td&gt; &lt;td width="165" valign="top"&gt;&lt;?php echo $firstname ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="82" valign="top"&gt;&lt;div align="left"&gt;lastname:&lt;/div&gt;&lt;/td&gt; &lt;td width="165" valign="top"&gt;&lt;?php echo $lastname ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p align="center"&gt;&lt;a href="index.php"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; &lt;?php } ?&gt; </code></pre> <p>Where do I need to put the code so that the username that is currently is logged in behind the url? Explanation is welcome to since I'm fairly new to PHP. Also if you see any errors please say so.</p>
    singulars
    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