This is a discussion on Question before I end up writing alot of extra code... within the PHP General forums, part of the PHP Programming Forums category; Hi everyone! So it's been a nice long weekend, I come in to work and try and mess with ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi everyone!
So it's been a nice long weekend, I come in to work and try and mess with a project that I'm working on to get some new features added. All was going well until I realized that now my application is breaking... Here's the details... PHP 5.2 MySQL 5.2 I store the info in the database which is submitted from a HTML form.. Some of it text boxes, some check boxes, some radio buttons... I $_POST the info from the form into the processing script. The problem I'm running into though, is when a value has not changed it doesn't get $_POSTed back and my update script erases the info in the database... I'm trying to avoid using $_GET since it can be quite a few variables. Is there anyway I can do it without comparing the original field to what I am displaying? -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com japruim@raoset.com |
|
|||
|
Jason Pruim wrote:
> The problem I'm running into though, is when a value has not changed > it doesn't get $_POSTed back Are you certain about that? I'm pretty certain _all_ values are posted back, regardless of whether they've changed or not. Otherwise, how would you ever get a hidden value POSTed ? /Per Jessen, Zürich |
|
|||
|
Jason Pruim wrote:
> Hi everyone! > > So it's been a nice long weekend, I come in to work and try and mess > with a project that I'm working on to get some new features added. All > was going well until I realized that now my application is breaking... > > Here's the details... > > PHP 5.2 > MySQL 5.2 > > I store the info in the database which is submitted from a HTML form.. > Some of it text boxes, some check boxes, some radio buttons... I $_POST > the info from the form into the processing script. > > The problem I'm running into though, is when a value has not changed it > doesn't get $_POSTed back and my update script erases the info in the > database... I'm trying to avoid using $_GET since it can be quite a few > variables. > > Is there anyway I can do it without comparing the original field to what > I am displaying? > > > -- > > Jason Pruim > Raoset Inc. > Technology Manager > MQC Specialist > 11287 James St > Holland, MI 49424 > www.raoset.com > japruim@raoset.com > > > > I don't see how this happens unless you are using a blank form to update an existing record. -Shawn |
|
|||
|
>
> The problem I'm running into though, is when a value has not changed it > doesn't get $_POSTed back and my update script erases the info in the > database... I'm trying to avoid using $_GET since it can be quite a few > variables. > > Is there anyway I can do it without comparing the original field to what I > am displaying? I would assume that when you bring up your form to be edited you would query your database to pull up the current information and then: 1 - echo those values out in your form fields OR 2 - Put the values into hidden form fields If you use #2 then when you do your update you can just check to see if any form objects are left blank...if they are blank use your hidden values...if they aren't blank use the form values. f you use #1 then you just update using all the form values. |
|
|||
|
At 3:25 PM -0400 7/7/08, Jason Pruim wrote:
>Hi everyone! > >So it's been a nice long weekend, I come in to work and try and mess >with a project that I'm working on to get some new features added. >All was going well until I realized that now my application is >breaking... > >Here's the details... > >PHP 5.2 >MySQL 5.2 > >I store the info in the database which is submitted from a HTML >form.. Some of it text boxes, some check boxes, some radio >buttons... I $_POST the info from the form into the processing >script. > >The problem I'm running into though, is when a value has not changed >it doesn't get $_POSTed back and my update script erases the info in >the database... I'm trying to avoid using $_GET since it can be >quite a few variables. > >Is there anyway I can do it without comparing the original field to >what I am displaying? Try print_r($_POST); to see if everything is OK. Sometimes I get get tripped up on what html controls actually are set to (i.e., 'on' instead of 1). Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com |
|
|||
|
Hey,
Dude you could use it this way <input type='checkbox' name='something' value='1'> <input type='checkbox' name='something' value='2'> <input type='checkbox' name='something' value='3'> Once u submit it, do a small server side validation if(isset($_POST['something'] || $_POST['something']) != ""){ insert............... } This way you could avoid replacing the values with nulls. Thanks, Vam On Mon, Jul 7, 2008 at 12:25 PM, Jason Pruim <japruim@raoset.com> wrote: > Hi everyone! > > So it's been a nice long weekend, I come in to work and try and mess with a > project that I'm working on to get some new features added. All was going > well until I realized that now my application is breaking... > > Here's the details... > > PHP 5.2 > MySQL 5.2 > > I store the info in the database which is submitted from a HTML form.. Some > of it text boxes, some check boxes, some radio buttons... I $_POST the info > from the form into the processing script. > > The problem I'm running into though, is when a value has not changed it > doesn't get $_POSTed back and my update script erases the info in the > database... I'm trying to avoid using $_GET since it can be quite a few > variables. > > Is there anyway I can do it without comparing the original field to what I > am displaying? > > > -- > > Jason Pruim > Raoset Inc. > Technology Manager > MQC Specialist > 11287 James St > Holland, MI 49424 > www.raoset.com > japruim@raoset.com > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > |
|
|||
|
sorry it needs to be a array for checkbox for the example below. So you
could use is_empty() instead. something like that. <input type='checkbox' name='something[]' value='1'> <input type='checkbox' name='something[]' value='2'> <input type='checkbox' name='something[]' value='3'> On Tue, Jul 8, 2008 at 7:37 PM, VamVan <vamseevan@gmail.com> wrote: > Hey, > > Dude you could use it this way > > <input type='checkbox' name='something' value='1'> > <input type='checkbox' name='something' value='2'> > <input type='checkbox' name='something' value='3'> > > Once u submit it, > > do a small server side validation > > if(isset($_POST['something'] || $_POST['something']) != ""){ > insert............... > } > > This way you could avoid replacing the values with nulls. > > Thanks, > Vam > > > On Mon, Jul 7, 2008 at 12:25 PM, Jason Pruim <japruim@raoset.com> wrote: > >> Hi everyone! >> >> So it's been a nice long weekend, I come in to work and try and mess with >> a project that I'm working on to get some new features added. All was going >> well until I realized that now my application is breaking... >> >> Here's the details... >> >> PHP 5.2 >> MySQL 5.2 >> >> I store the info in the database which is submitted from a HTML form.. >> Some of it text boxes, some check boxes, some radio buttons... I $_POST the >> info from the form into the processing script. >> >> The problem I'm running into though, is when a value has not changed it >> doesn't get $_POSTed back and my update script erases the info in the >> database... I'm trying to avoid using $_GET since it can be quite a few >> variables. >> >> Is there anyway I can do it without comparing the original field to what I >> am displaying? >> >> >> -- >> >> Jason Pruim >> Raoset Inc. >> Technology Manager >> MQC Specialist >> 11287 James St >> Holland, MI 49424 >> www.raoset.com >> japruim@raoset.com >> >> >> >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > |