Jump to content

Updating Field In SQL Via PHP - HELP!!


oliverj777

Recommended Posts

Okay, I have a useredit page in where a user can manage their account info. All the text field and SQL connections work fine, and they all update perfectly. But when I go ahead and add my own text field (first name) and hit submit, it says success - but in my SQL it hasn't actually updated ... What the Ef?

 

Here are my snippets of my codes:

--useredit.php--

 

<form action="process.php" method="POST">

<input type"text" name"firstname" value="<? if($form->value("firstname") == ""){    echo $session->userinfo['firstname']; }else{    echo $form->value("firstname"); } ?>">

<input type="hidden" name="subedit" value="1">
                        <input type="submit" value="Edit Account">

 

--process.php--

 

function procEditAccount(){
      global $session, $form;
      /* Account edit attempt */
      $retval = $session->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email'], $_POST['firstname']);

      /* Account edit successful */
      if($retval){
         $_SESSION['useredit'] = true;
         header("Location: ".$session->referrer);
      }

 

--session.php--

 

function editAccount($subcurpass, $subnewpass, $subemail, $subfirstname){
      global $database, $form;

if($subfirstname){
         $database->updateUserField($this->username,"firstname",$subfirstname);
      }

 

--database.php--

 

 function updateUserField($username, $field, $value){
      $q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'";
      return mysql_query($q, $this->connection);
   }

 

 

If you need to see more code, let me know.

 

Would appreciate the help, thanks!

Ollie!

Link to comment
Share on other sites

So, when you were debugging this to find out what execution path your code is taking and what the data was at the different points along that path, at what point did you find you had the expected data and at what point did you find you did not? I can guarantee that the problem lies between those two points.

Link to comment
Share on other sites

Oh My Jesus Christ --

 

It's taken me, what 6 hours to figure this out ... And I've just found the problem .. You're not going to believe it.

 

I missed the '=' off the:

 

input type"text" name"firstname"...

 

Correction is:

input type="text" name="firstname"...

 

It had nothing to do with my PHP coding!! HOW ANNOYING!!

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.