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.
Link to comment
Share on other sites

[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.
Link to comment
Share on other sites

[quote]and also if i wanted to make this page
instantly when the user creates his account how would i do that?[/quote]

That makes no sense. If this page exists, then as soon as a user submits there details to the database you can use this page to display there profile.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.