Jump to content

need edit profile script (old one doesn't work)


rallokkcaz

Recommended Posts

ok i need a edit profile script

what gets the users info just from where hes logged in

so if user1 went to edit profile whent to edit his profile it would show only his info
and if user2 click on that link it would take it to his info not user1's

here's the code i use now.

[code]<?php

    $id = $_GET['id'];

    $sql = "SELECT * FROM maaking_users WHERE userid='$id'";

    $result = @mysql_query($sql) or die(mysql_error());

    $user = mysql_fetch_assoc($result);
    echo <<<HTMLFORM
<form action="{$_SERVER['PHP_SELF']}" method="post">
<table  cellpadding="2" cellspacing="1" width="400">
  <tr>
    <td wdith="35%">Username:</td>
    <td>{$user['username']}</td>
  </tr> 
  <tr>
    <td>Full Name:</td>
    <td><input type="text" name="fullname" value="{$user['fullname']}" /></td>
  </tr><tr>
    <td>Password</td>
    <td>
New Password: <input type="password" name="password" value="$password" /></td>
  </tr>
<tr>
    <td>About Me:</td>
    <td><textarea height="200px" width="300px" input type="text/html"  name="about" value="" />{$user['about']}</textarea></td>
  </tr><tr
  <tr>
    <td>Email Address:</td>
    <td><input type="text" name="email" value="{$user['email']}" /></td>
  </tr>
  <tr>
    <td colspan="2">
      <input type="hidden" name="userid" value="{$user['userid']}" />
      <input type="submit" name="update" value="Update Profile">
    </td>
  </tr>
</table>
</form>
HTMLFORM;
}
elseif(isset($_POST['update']))
{
    foreach($_POST as $field_name => $field_value)
    {
        ${$field_name} = mysql_real_escape_string($field_value);
    }

    $sql = "UPDATE maaking_users  set password='$password', about='$about', email='$email', fullname='$fullname' WHERE userid='$userid'";

    $result = mysql_query($sql) or die(mysql_error());

    echo "Successfully updated profile <br>
<a href='profiles.php?id=$userid'>Go to Profile</a>";


}
?>[/code] *note code is missing some info*
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.