1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Edit profile info into db

Discussion in 'MySQL' started by W3C, Dec 5, 2006.

  1. W3C

    W3C New Member

    Joined:
    Nov 24, 2006
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    0
    OKay. So I made edited this editing profile php doc. I have the database and everything. When I hit update It says your profile has been updated. Then I go to the memberlist I click on the profile I just edited and it doesn't show waht I updated.

    Code:
    PHP:
    <title></title>
    <?php
    ob_start
    ();
    include(
    "config.php");
    if (
    $logged[username])
    {
    // the user is logged in!  We continue...
    if (!$_POST[update])
    {
    // the form hasn't been submitted.  We continue...
    $profile mysql_query("SELECT * FROM family_users WHERE username = '$logged[username]'");
    $profile = @mysql_fetch_array($profile);
    // the above lines get the information so that it can be displayed in the html form.
    echo("
    <center><form method=\"POST\">
    <table width=\"100%\">
    <tr>
    <td align=\"right\" width=\"25%\">
    Location:
    </td>
    <td align=\"left\">
    <input type=\"text\" size=\"25\" maxlength=\"25\" name=\"locate\" value=\"
    $profile[location]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    MSN Messenger:
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"msn\" value=\"
    $profile[msn]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    AOL Messenger:</td>
    <td align=\"left\">
    <input size=\"25\" name=\"aim\"  value=\"
    $profile[aim]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    Email Address:</td>
    <td align=\"left\">
    <input size=\"25\"  name=\"email\" value=\"
    $profile[email]\"></td>
    </tr>
    <tr>

    <td align=\"right\" width=\"25%\">
    Kids:
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids1\" value=\"
    $profile[kids1]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids2\" value=\"
    $profile[kids2]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids3\" value=\"
    $profile[kids3]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids4\" value=\"
    $profile[kids4]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids5\" value=\"
    $profile[kids5]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids6\" value=\"
    $profile[kids6]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids7\" value=\"
    $profile[kids7]\"></td>
    </tr>
    <tr>

    <td align=\"center\">
    </td>
    <td align=\"left\">
    <input type=\"submit\" name=\"update\" value=\"Update\"></td>
    </tr>
    </table>
    </form>
    </center>"
    );
    }
    else
    {

    $email htmlspecialchars($_POST[email]);
    $aim htmlspecialchars($_POST[aim]);
    $msn htmlspecialchars($_POST[msn]);
    $locate htmlspecialchars($_POST[locate]);
    $kids1 htmlspecialchars($_POST[kids1]);
    $kids2 htmlspecialchars($_POST[kids2]);
    $kids3 htmlspecialchars($_POST[kids3]);
    $kids4 htmlspecialchars($_POST[kids4]);
    $kids5 htmlspecialchars($_POST[kids5]);
    $kids6 htmlspecialchars($_POST[kids6]);
    $kids7 htmlspecialchars($_POST[kids7]);
    /*
    $email = $_POST[email];
    $aim = $_POST[aim];
    $msn = $_POST[msn];
    $locate = $_POST[locate];
    $kids1 = $_POST[kids1];
    $kids2 = $_POST[kids2];
    $kids3 = $_POST[kids3];
    $kids4 = $_POST[kids4];
    $kids5 = $_POST[kids5];
    $kids6 = $_POST[kids6];
    $kids7 = $_POST[kids7];
    */
    // the above lines get rid of all html.

    $update mysql_query
    ("UPDATE 'family_users' SET 'email' = '$email', 
    'msn' = '
    $msn', 
    'aim' = '
    $aim', 
    'location' = '
    $locate', 
    'kids1' = '
    $kids1', 
    'kids2' = '
    $kids2', 
    'kids3' = '
    $kids3', 
    'kids4' = '
    $kids4', 
    'kids5' = '
    $kids5', 
    'kids6' = '
    $kids6', 
    'kids7' = '
    $kids7' WHERE 'username' = '$logged[username]'");
    $sql "$email$msn$aim$locate$kids1$kids2$kids3$kids4$kids5$kids6$kids7";
    echo (
    "Your profile has been updated!");
    echo 
    $sql;
    // updates the information in the database.
    }
    }
    else
    {
    // They aren't logged in!
    echo ("<a href=\"login.php\">You must login</a>");
    }
    ?>
    Thanks in advance.
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Does it show the details contained in profile or does it show everything except the details you just updated?

    try adding 'or die(mysql_error())' after mysql_query and look for any errors!
     
  3. W3C

    W3C New Member

    Joined:
    Nov 24, 2006
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    0
    OKay. So I made edited this editing profile php doc. I have the database and everything. When I hit update It says your profile has been updated. Then I go to the memberlist I click on the profile I just edited and it doesn't show waht I updated.

    Code:
    PHP:
    <title></title>
    <?php
    ob_start
    ();
    include(
    "config.php");
    if (
    $logged[username])
    {
    // the user is logged in!  We continue...
    if (!$_POST[update])
    {
    // the form hasn't been submitted.  We continue...
    $profile mysql_query("SELECT * FROM family_users WHERE username = '$logged[username]'");
    $profile = @mysql_fetch_array($profile);
    // the above lines get the information so that it can be displayed in the html form.
    echo("
    <center><form method=\"POST\">
    <table width=\"100%\">
    <tr>
    <td align=\"right\" width=\"25%\">
    Location:
    </td>
    <td align=\"left\">
    <input type=\"text\" size=\"25\" maxlength=\"25\" name=\"locate\" value=\"
    $profile[location]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    MSN Messenger:
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"msn\" value=\"
    $profile[msn]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    AOL Messenger:</td>
    <td align=\"left\">
    <input size=\"25\" name=\"aim\"  value=\"
    $profile[aim]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    Email Address:</td>
    <td align=\"left\">
    <input size=\"25\"  name=\"email\" value=\"
    $profile[email]\"></td>
    </tr>
    <tr>

    <td align=\"right\" width=\"25%\">
    Kids:
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids1\" value=\"
    $profile[kids1]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids2\" value=\"
    $profile[kids2]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids3\" value=\"
    $profile[kids3]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids4\" value=\"
    $profile[kids4]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids5\" value=\"
    $profile[kids5]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids6\" value=\"
    $profile[kids6]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids7\" value=\"
    $profile[kids7]\"></td>
    </tr>
    <tr>

    <td align=\"center\">
    </td>
    <td align=\"left\">
    <input type=\"submit\" name=\"update\" value=\"Update\"></td>
    </tr>
    </table>
    </form>
    </center>"
    );
    }
    else
    {

    $email htmlspecialchars($_POST[email]);
    $aim htmlspecialchars($_POST[aim]);
    $msn htmlspecialchars($_POST[msn]);
    $locate htmlspecialchars($_POST[locate]);
    $kids1 htmlspecialchars($_POST[kids1]);
    $kids2 htmlspecialchars($_POST[kids2]);
    $kids3 htmlspecialchars($_POST[kids3]);
    $kids4 htmlspecialchars($_POST[kids4]);
    $kids5 htmlspecialchars($_POST[kids5]);
    $kids6 htmlspecialchars($_POST[kids6]);
    $kids7 htmlspecialchars($_POST[kids7]);
    /*
    $email = $_POST[email];
    $aim = $_POST[aim];
    $msn = $_POST[msn];
    $locate = $_POST[locate];
    $kids1 = $_POST[kids1];
    $kids2 = $_POST[kids2];
    $kids3 = $_POST[kids3];
    $kids4 = $_POST[kids4];
    $kids5 = $_POST[kids5];
    $kids6 = $_POST[kids6];
    $kids7 = $_POST[kids7];
    */
    // the above lines get rid of all html.

    $update mysql_query
    ("UPDATE 'family_users' SET 'email' = '$email', 
    'msn' = '
    $msn', 
    'aim' = '
    $aim', 
    'location' = '
    $locate', 
    'kids1' = '
    $kids1', 
    'kids2' = '
    $kids2', 
    'kids3' = '
    $kids3', 
    'kids4' = '
    $kids4', 
    'kids5' = '
    $kids5', 
    'kids6' = '
    $kids6', 
    'kids7' = '
    $kids7' WHERE 'username' = '$logged[username]'");
    $sql "$email$msn$aim$locate$kids1$kids2$kids3$kids4$kids5$kids6$kids7";
    echo (
    "Your profile has been updated!");
    echo 
    $sql;
    // updates the information in the database.
    }
    }
    else
    {
    // They aren't logged in!
    echo ("<a href=\"login.php\">You must login</a>");
    }
    ?>
     
  4. W3C

    W3C New Member

    Joined:
    Nov 24, 2006
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    0
    Sorry. I had copied the wrong code. If you can edit this for me that would be great.
    Thanks.

    Code:
    PHP:
    <title>Welcome. <?php $logged[username]; ?></title><?php
    ob_start
    ();
    include(
    "config.php");
    if (
    $logged[username])
    {
    // the user is logged in!  We continue...
    if (!$_POST[update])
    {
    // the form hasn't been submitted.  We continue...
    $profile mysql_query("SELECT * from family_users where username = '$logged[username]'");
    $profile mysql_fetch_array($profile);
    // the above lines get the information so that it can be displayed in the html form.
    echo("
    <center><form method=\"POST\">
    <table width=\"100%\">
    <tr>
    <td align=\"right\" width=\"25%\">
    Username
    </td>
    <td align=\"left\">
    <input disabled=\"disabled\" type=\"text\" size=\"25\" maxlength=\"25\" name=\"locate\" value=\"
    $profile[username]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    Last Name
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"msn\" value=\"
    $profile[lname]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    First Name</td>
    <td align=\"left\">
    <input size=\"25\" name=\"aim\"  value=\"
    $profile[fname]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    Email Address</td>
    <td align=\"left\">
    <input size=\"25\"  name=\"email\" value=\"
    $profile[email]\"></td>
    </tr>
    <tr>

    <td align=\"right\" width=\"25%\">
    Kids:
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids1\" value=\"
    $profile[kids1]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids2\" value=\"
    $profile[kids2]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids3\" value=\"
    $profile[kids3]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids4\" value=\"
    $profile[kids4]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids5\" value=\"
    $profile[kids5]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids6\" value=\"
    $profile[kids6]\"></td>
    </tr>
    <tr>
    <td align=\"right\" width=\"25%\">
    </td>
    <td align=\"left\">
    <input size=\"25\" name=\"kids7\" value=\"
    $profile[kids7]\"></td>
    </tr>
    <tr>

    <td align=\"center\">
    </td>
    <td align=\"left\">
    <input type=\"submit\" name=\"update\" value=\"Update\"></td>
    </tr>
    </table>
    </form>
    </center>"
    );
    }
    else
    {
    $email htmlspecialchars($_POST[email]);
    $fname htmlspecialchars($_POST[fname]);
    $lname htmlspecialchars($_POST[lname]);
    $username htmlspecialchars($_POST[username]);
    $kids1 htmlspecialchars($_POST[kids1]);
    $kids2 htmlspecialchars($_POST[kids2]);
    $kids3 htmlspecialchars($_POST[kids3]);
    $kids4 htmlspecialchars($_POST[kids4]);
    $kids5 htmlspecialchars($_POST[kids5]);
    $kids6 htmlspecialchars($_POST[kids6]);
    $kids7 htmlspecialchars($_POST[kids7]);
    // the above lines get rid of all html.
    echo ("Your profile has been updated!");
    $update mysql_query("Update family_users set
    email = '
    $email',
    lname = '
    $lname',
    fname = '
    $fname',
    kids1 = '
    $kids1',
    kids2 = '
    $kids2',
    kids3 = '
    $kids3',
    kids4 = '
    $kids4',
    kids5 = '
    $kids5',
    kids6 = '
    $kids6',
    kids7 = '
    $kids7',
    username = '
    $logged[username]'
    where username = '
    $logged[username]'");
    // updates the information in the database.
    }
    }
    else
    {
    // They aren't logged in!
    echo ("<a href=\"login.php\">You must login</a>");
    }
    ?>
     

Share This Page