Jump to content

Here's a tough one for ya! Try to follow along:


affluent980

Recommended Posts

I have a database table in which i have leads with their LeadID as a primary key, and columns like name, phone, etc, and most importantly, the Revenue column.  I am trying to set up my page so that i can edit the value in the revenue column for one lead at a time.  This is the form on the page:

<?php
/**
* If user is not logged in, then do not display anything.
* If user is logged in, then display the form to edit
* lead detail information.
*/
if($session->logged_in){
?>

<h1>Lead Detail Edit : <? echo $_GET['leadid']; ?></h1>
<?
if($form->num_errors > 0){
   echo "<td><font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font></td>";
}
?>
<form action="process.php" method="POST">
<table align="left" border="1" cellspacing="0" cellpadding="3">


<tr>
<td>Revenue:</td>
<td><input type="text" name="Revenue" maxlength="50" value=" ">
</td>
<td><? echo $form->error("email"); ?></td>
</tr>
<tr><td colspan="2" align="right">
<input type="hidden" name="subdet" value="1">
<input type="submit" value="Edit Lead"></td></tr>
<tr><td colspan="2" align="left"></td></tr>
</table>
</form>

<?

/* Link back to main */
echo "<br>Back To [<a href=\"main.php\">Main</a>]<br>";

}
}

?>

This seems to be working fine. and it posts the value i put in the Revenue input and subdet to process.php which is here:

             /* User submitted edit lead detail form */
      else if(isset($_POST['subdet'])){
         $this->procEditDetails();
      }

Which tells it to go to procEditDetails on process.php which is here:

   /**
    * procEditDetails - Attempts to edit the lead details
    */
   function procEditDetails(){
      global $session, $form;
      /* Account edit attempt */
      $retval = $session->editDetails($_POST['Revenue']);

      /* Account edit successful */
      if($retval){
         $_SESSION['leadedit'] = true;
         header("Location: ".$session->referrer);
      }
      /* Error found with form */
      else{
         $_SESSION['value_array'] = $_POST;
         $_SESSION['error_array'] = $form->getErrorArray();
         header("Location: ".$session->referrer);
      }
   }

which passes Revenue to the function editDetails on session.php which is here:

/**
    * editDetails - Attempts to edit the lead details
    *
    */
   function editDetails($subRevenue){
      global $database, $form;  //The database and form object
      /* Change Revenue */
      if($subRevenue){
         $database->updateLeadDetails($this->Revenue,"Revenue",$subRevenue);
      }
      
      /* Success! */
      return true;
   }

Which passes i don't know what on to the function updateLeadDetails on database.php which is here:

   /**
    * updateLeadDetails - Updates a field, specified by the field
    * parameter, in the leadid's row of the database.
    */
   function updateLeadDetails($Revenue, $field, $value){
      $q = "UPDATE ".TBL_Leads." SET ".$field." = '$value' WHERE LeadID = '$LeadID'";
      return mysql_query($q, $this->connection);
   }

And it passes everything back fine, with no errors, and in fact, confirms that update was successful, but it doesn't change the revenue value for that LeadID.  Am i not passing on the right variables?  Please help!  If you need any more information, i will provide.  This one has me stumped after 4 hours of trying to figure it out.

 

EDIT: you have been CODE tagged, remember in the future

Link to comment
Share on other sites

what framework is this in?

 

might get a better response looking to a framework specfic forum / section

 

in the mean time debug in steps, verify the data is in the right place at each function, if you can echo the SQL query that is being generated you'd be in good shape

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.