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
https://forums.phpfreaks.com/topic/211789-updating-field-in-sql-via-php-help/
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.

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!!

Archived

This topic is now archived and is closed to further replies.

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