SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Value from form not being passed

    hi, i wrote myself a little "edit profile" script in which the users can edit they're own information that's stored in my database about them when they register.
    i was fooling with it yesterday trying to make it so if they changed their email it'd created a new pw, store it in the db, and mail it to them. well, this failed horribly as it wouldn't store it in the database.
    i said screw it, and i removed that code, but now it won't store the new pw in the db at all! here's my code.
    (this is kinda lengthy, so bare with me.)
    right where you see echo $password;
    that isn't getting the password from the field.
    also i know the query is successful cause when i changed my email, it records that.
    PHP Code:
    <?php // edit_profile.php
    $date_y date("Y");
    $db_connect mysql_connect(edited out);
    $db_name "name";

    include (
    'error.php');

    session_start();

    if (!
    $username) {
    ?>
    <?
    include('head.php');
    include(
    'join_header.php'); ?>
    <center><font size="2">
    Please login in order to access this part of the site.<br>
    If you are not a member, please <a href="/join.php">click here</a> to join.</font>
    <br>
    <br>
    <form action="<?=$PHP_SELF?>" method="post">
    <table width="300" cellpadding="0" cellspacing="0">
     <tr>
      <td width="100"><font size="2">Username:</font></td>
      <td width="200"><input type="text" name="username" size="25"></td>
     </tr>
     <tr>
      <td width="100"><font size="2">Password:</font></td>
      <td width="200"><input type="password" name="password" size="25"></td>
     </tr>
     <tr>
      <td width="100"><font size="2">&nbsp</font></td>
      <td width="200" align="center"><font size="1"><a href="/send_pw.php"><i>Forgot your password?</i></a></font></td>
     </tr>
     <tr>
      <td width="300" colspan="2" align="center"><br><input type="submit" name="submit" value="Login">&nbsp;&nbsp;<input type="reset" value="Clear"></form></td>
     </tr>
    </table>
    </center>
    <?php
    include ('join_footer.php');
    exit;
    }

    session_register("username");
    session_register("password");

    $db_query "SELECT * from 3dartisan_users WHERE username='$username' AND password='$password'";
    $result mysql_db_query($db_name$db_query$db_connect);
    if (!
    $result) {
    error("A database error occurred while checking your login details.\\nIf this error persists, please contact [email]info@3dartisan.net[/email].");
    }

    if (
    mysql_num_rows($result) == 0) {
    session_unregister("username");
    session_unregister("password");
    include (
    '../head.php');
    include (
    '../resources_header.php');
    ?>
    <center><font size="2">We're sorry, the username and/or password you submitted was incorrect.</br>
    Please <a href="<?=$PHP_SELF?>">click here</a> to return to the login screen and try again.<br>
    To register for a user account, <a href="/join.php">click here</a>.
    <?php
    exit;
    }

    $user_name mysql_result($result,0,"username");

    if(!
    $update) {

    include (
    'http://www.3dartisan.net/head.php');
    ?>
    <body bgcolor="#000000" text="#FFFFFF" link="#808080" vlink="#CCCCCC" alink="#FFFFFF" topmargin="0">
    <center><img src="/images/nav2.jpg" border="0" usemap="#FPMap0" width="800" height="100"></center>
    <br><? include ('member_options.php'); ?>
    <br>
    <?

    $get_users 
    "SELECT * from 3dartisan_users WHERE username = '$user_name'";
    $user_results mysql_db_query($db_name$get_users$db_connect);
    $user_row mysql_fetch_array($user_results);
    $id $user_row[id];
    $old_email $user_row[email];

    ?>

    <form action="<?=$PHP_SELF ?>" method="POST">
    <table bgcolor="#000000" width="80%" cellpadding="1" cellspacing="1" align="center">
     <tr>
      <td width="40%" bgcolor="#555555" valign="middle"><font size="2" face="Arial">Username:</td>
      <td  width="60%" bgcolor="#520608" valign="middle"><input type="text" size="25" name="username" value="<? echo $user_row[username]; ?>"><font size="1"><i>(<a href="/logout.php?from_link=edit_profile.php">Logout</a>)</i></font></td>
     </tr>
     <tr>
      <td width="40%" bgcolor="#555555" valign="middle"><font size="2" face="Arial">Password:</td>
      <td width="60%" bgcolor="#520608" valign="middle"><input type="text" size="25" name="password" value="<? echo $user_row[password]; ?>"></td>
     </tr>
     <tr>
      <td width="40%" bgcolor="#555555" valign="middle"><font size="2" face="Arial">Email Address:</font></td>
      <td width="60%" bgcolor="#520608" valign="middle"><input type="text" size="25" name="email" value="<? echo $user_row[email]; ?>"></td>
     </tr>
     <tr>
      <td width="40%" bgcolor="#555555" valign="middle"><font size="2" face="Arial">Display Email:</td>
      <td width="10%" bgcolor="#520608" valign="middle"><input type="radio" name="dis_email" value="1" checked><font size="2" face="verdana" color="#FFFFFF">Yes&nbsp;&nbsp;&nbsp;<input type="radio" name="dis_email" value="0"><font size="2" face="verdana" color="#FFFFFF">No</font></td>
     </tr>
     <tr>
      <td width="40%" bgcolor="#555555" valign="middle"><font size="2" face="Arial">Website:</td>
      <td width="60%" bgcolor="#520608" valign="middle"><input type="text" size="25" name="url" value="<? echo $user_row[url]; ?>"></td>
     </tr>
     <tr>
      <td width="40%" bgcolor="#555555" valign="middle"><font size="2" face="Arial">ICQ:</td>
      <td width="30%" bgcolor="#520608" valign="middle"><input type="text" size="12" maxlength="15" name="icq" value="<? echo $user_row[icq]; ?>"></td>
     </tr>
     <tr>
      <td width="40%" bgcolor="#555555" valign="middle"><font size="2" face="Arial">AIM:</td>
      <td width="60%" bgcolor="#520608" valign="middle"><input type="text" size="25" name="aim" value="<? echo $user_row[aim]; ?>"></td>
     </tr>
     <tr>
      <td width="40%" bgcolor="#555555" valign="middle"><font size="2" face="Arial">Yahoo!:</td>
      <td width="60%" bgcolor="#520608" valign="middle"><input type="text" size="25" name="yahoo" value="<? echo $user_row[yahoo]; ?>"></td>
     </tr>
      <tr>
      <td width="40%" bgcolor="#555555" valign="middle"><font size="2" face="Arial">MSN Messanger:</td>
      <td width="60%" bgcolor="#520608" valign="middle"><input type="text" size="25" name="msn" value="<? echo $user_row[msn]; ?>"></td>
     </tr>
      <tr>
      <td width="40%" bgcolor="#555555" valign="middle"><font size="2" face="Arial">Interests:</td>
      <td width="60%" bgcolor="#520608" valign="middle"><input type="text" size="25" name="interests" value="<? echo $user_row[interests]; ?>"></td>
     </tr>
      <tr>
      <td width="40%" bgcolor="#555555" valign="middle"><font size="2" face="Arial">Comments:</td>
      <td width="60%" bgcolor="#520608" valign="middle"><textarea name="comments" rows="5" cols="40"><? echo $user_row[comments?></textarea></td>
     </tr>
     <tr>
      <td width="40%" bgcolor="#555555" valign="middle">&nbsp;</td>
      <td width="60%" bgcolor="#520608" valign="middle"><input type="submit" name="update" value="Update Info"></td>
     </tr>
      <td width="100%" colspan="2"><center><? include ('general_footer.php'); ?></center></td>
     </tr>
    </table>
    <?

    } else {

    echo 
    $password;

    $sql="UPDATE 3dartisan_users SET username = '$username', password = '$password', email = '$email', dis_email = '$dis_email', url = '$url', icq = '$icq', aim = '$aim', yahoo = '$yahoo', msn = '$msn', interests = '$interests', comments = '$comments' WHERE username = '$user_name'";

    if(!
    mysql_db_query($db_name$sql$db_connect)){
    echo 
    "A database error occurred while updating your info. If this error persists, please contact [email]info@3dartisan.net[/email].";
    echo 
    mysql_error();
    exit;
    }
    include(
    'head.php');
    include(
    'join_header.php');
    ?>
    <table width="400" cellspacing="1" cellpadding="1" align="center">
     <tr>
      <td bgcolor="#555555" align="center" valign="middle"><font size="2" face="arial">Your information has been updated.<br>If you changed your email address, an email has sent to the submitted email address with a new password.<br>Click <a href="/resources">here</a> to return to the resource section, or click <a href="/index.php">here</a> to return home.</font></td>
     </tr>
    </table>
    <?
    include('join_footer.php');
    }
    ?>
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  2. #2
    epsilon transition cupid's Avatar
    Join Date
    Aug 2001
    Location
    Kent, Ohio
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm.. Could this be because it's getting conflicted with the session variable $password? What happens if you changed the field name to something else.. like $user_password?

  3. #3
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yea, they were conflicting.
    Thanks
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •