Jump to content

HELP to create user profiles


rallokkcaz

Recommended Posts

So you know how to insert and update data but not how to display it? An example...

[code=php:0]
<?php
  // coonnect to database
  if (isset($_GET['uname'])) {
    $sql = "SELECT uname,location,age FROM users WHERE uname='{$_GET['uname']}'";
    if ($result = mysql_query($sql)) {
      $row = mysql_fetch_assoc($result);
      echo $row['uname']."</ br>";
      echo $row['location']."</ br>";
      echo $row['age']."</ br>";
    } else {
    echo "query failed ".mysql_error();
    }
  } else {
    echo "no user selected";
  }
?>
[/code]

If this file was called profiles.php and you called it using http://yoursite/profiles.php?uname=bob it would display bob's name location and age.
[quote]but how do you allow them to edit it[/quote]

Make a simular page (called editprofile.php or something) but instead of just displaying the data, place it in a form ready to be submitted to an UPDATE sql statement.

[quote]make the page look a little more professinal.[/quote]

Use html to markup your data. What I posted was just a very simple example to get you started, Im not going to write a finished product.
Do a Google search for handling forms in HTML, there are loads of tutorials available or even visit scripts archives and download some examples, they'll show you exactly how its done.

Then its just a case of collecting the data in a PHP script using $_POST and inserting it all into the database.

Its like a register page when a user wants to sign up for whatever you're making. Once you have their registration details and its all correct you can insert it into a user's table in the database. Then whenever you use another script to view their profile all you're doing is extracting the data and displaying it in the browser.
i think hes talking about a publically viewed profile... for example myspace profiles.. which is what i'm trying to figure out.  i cant speak for him... but maybe he means how do you make it so that each  person has their own "www.mywebsite.com/*******" with the * as the digits of their user ID?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.