Question before I end up writing alot of extra code...

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


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-07-2008
Jason Pruim
 
Posts: n/a
Default Question before I end up writing alot of extra code...

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




Reply With Quote
  #2 (permalink)  
Old 07-07-2008
Per Jessen
 
Posts: n/a
Default Re: [PHP] Question before I end up writing alot of extra code...

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

Reply With Quote
  #3 (permalink)  
Old 07-07-2008
Shawn McKenzie
 
Posts: n/a
Default Re: Question before I end up writing alot of extra code...

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
Reply With Quote
  #4 (permalink)  
Old 07-07-2008
Dan Shirah
 
Posts: n/a
Default Re: [PHP] Question before I end up writing alot of extra code...

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

Reply With Quote
  #5 (permalink)  
Old 07-07-2008
tedd
 
Posts: n/a
Default Re: [PHP] Question before I end up writing alot of extra code...

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
Reply With Quote
  #6 (permalink)  
Old 07-09-2008
VamVan
 
Posts: n/a
Default Re: [PHP] Question before I end up writing alot of extra code...

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


Reply With Quote
  #7 (permalink)  
Old 07-09-2008
VamVan
 
Posts: n/a
Default Re: [PHP] Question before I end up writing alot of extra code...

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

>


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:08 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0