Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You <strong>have</strong> to store an ID field with every record in your user database table and you should make it a primary key with auto_increment enabled. That way whenever a new record is added to your database table, the record will automatically be given a unique id number that will allow you to access it.</p> <p>Next, when you are creating profile.php, do a check at the top of the page for the presence of an id in the $_GET array, if it exists, escape it to prevent sql injetion and do a mysql query to pull the info you need from that particular user's record. Something like this:</p> <pre><code>if(isset($_GET['id'])) { //check if id exists in $_GET $id = mysql_real_escape_string($_GET['id']); //prevent sql injection $resc = mysql_query("SELECT fldFullName, fldEmail, Password, Gender, DOB FROM Members WHERE id='$id' LIMIT 1"); //query the db for record if(mysql_num_rows($resc) == 1) { //make sure the user exists $user = mysql_fetch_assoc($resc); //convert mysql resource into array that can be used throughout your script } else { echo "no user with that id"; } else { echo "no id provided."; } </code></pre> <p>Now all your user's info is stored in an array called <code>$user</code> for use throughout your page.</p> <p>Then if you want to get fancy with it and better SEO results, look into apache <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html" rel="nofollow noreferrer"><code>mod_rewrite</code></a> module which will allow you to do URL rewriting so that you can have URLs that look like <code>/profile/someusername</code> rather than <code>/profile.php?id=1234</code>. <em>Much better!</em></p> <p>Here are some resources for getting started with mod_rewrite:</p> <ol> <li><a href="http://articles.sitepoint.com/article/guide-url-rewriting" rel="nofollow noreferrer">http://articles.sitepoint.com/article/guide-url-rewriting</a></li> <li><a href="http://www.workingwith.me.uk/articles/scripting/mod_rewrite" rel="nofollow noreferrer">http://www.workingwith.me.uk/articles/scripting/mod_rewrite</a></li> </ol>
    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.
    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