php - Username behind URL -


hello stack overflow i'm kind of stuck user_profile/username_here. problem can fill in every username want , still show made username if put behind '/' got filtered out how let show username of user logged in behind url? i'm using url rewriting. htaccess:

rewriteengine on rewritebase /  rewriterule ^profile/([a-za-z0-9-\._]+)(\/)?                    /profile.php?username=$1 [l,qsa] 

here code i'm using user_profile.php:

<?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 * tab username='$username' , firstname='$firstname' , lastname='$lastname'");       if($row3 = mysql_fetch_array($result3)) {         $username = $row3['username'];         $firstname = $row3['firstname'];         $lastname = $row3['lastname'];     }    ?> <html>     <body>         <table width="398" border="0" align ="center" cellpadding="0">             <tr>             <td height ="26" colspan="2">profile info</td>                 <td><div align="right"><a href="log_out.php">logout</a></div></td>             </tr>             <tr>                 <td width="129" rowspan="5"><img src="<?php echo $picture?>" width="129" height="129" alt="no image found"/></td>                 <td width="82" valign="top"><div align="left">username:</div></td>                 <td width="165" valign="top"><?php echo $username ?></td>             </tr>             <tr>                 <td width="82" valign="top"><div align="left">firstname:</div></td>                 <td width="165" valign="top"><?php echo $firstname ?></td>             </tr>             <tr>                 <td width="82" valign="top"><div align="left">lastname:</div></td>                 <td width="165" valign="top"><?php echo $lastname ?></td>             </tr>         </table>         <p align="center"><a href="index.php"></a></p>     </body> </html> <?php     } ?> 

where need put code username logged in behind url? explanation welcome since i'm new php. if see errors please so.

do not use mysql_* -- has been deprecated in php 5.5. use mysqli or pdo instead.

your code can place anywhere want. since have variables set, have build link.

<a href="profile/<?php echo $username; ?>"> 

this build link such: http://domain.tld/profile/username


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -