Bluehost.com Web Hosting $6.95

using variable in php form before the form is POSTed

This is a discussion on using variable in php form before the form is POSTed within the PHP General forums, part of the PHP Programming Forums category; I have a form that will be filled in by the user, I want to have access to the content ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-12-2008
milt
 
Posts: n/a
Default using variable in php form before the form is POSTed

I have a form that will be filled in by the user, I want to have access to
the content of one of the fields in that form, in order to fill in an
another variable that is not part of the form. this variable is used by a
routine when the form is "posted". Question - is the $_post[field name]
availble before the submit button is pushed, or is there another way to get
the contents of the field?
thanks, Milt


Reply With Quote
  #2 (permalink)  
Old 05-13-2008
Robert Cummings
 
Posts: n/a
Default Re: [PHP] using variable in php form before the form is POSTed


On Mon, 2008-05-12 at 14:44 -0700, milt wrote:
> I have a form that will be filled in by the user, I want to have access to
> the content of one of the fields in that form, in order to fill in an
> another variable that is not part of the form. this variable is used by a
> routine when the form is "posted". Question - is the $_post[field name]
> availble before the submit button is pushed, or is there another way to get
> the contents of the field?


PHP only gets what the browser sends. The browser doesn't send until you
click the submit button (or perform a synonymous action). You'll need to
use JavaScript to work on data before it is submitted.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

Reply With Quote
  #3 (permalink)  
Old 05-13-2008
Kenoli
 
Posts: n/a
Default Re: using variable in php form before the form is POSTed

On May 12, 2:44*pm, milth...@sbcglobal.net ("milt") wrote:
> I have a form that will be filled in by the user, I want to have access to
> the content of one of the fields in that form, in order to fill in an
> another variable that is not part of the form. *this variable is used bya
> routine when the form is "posted". *Question - is the $_post[field name]
> availble before the submit button is pushed, or is there another way to get
> the contents of the field?
> thanks, Milt


How is the data getting into the field you want to access? If it is
getting there via a php variable, you can use the same variable to add
the same value to the variable that is not part of the form. If it is
inserted by the user, you would have to use javascript. Using Ajax,
you could trigger javascript to send the information from that field
when, say, the user moves to another field, to a php script on the
server. That script could process the data and even send info back to
the form or any other location.

--Kenoli
Reply With Quote
  #4 (permalink)  
Old 05-13-2008
tedd
 
Posts: n/a
Default Re: [PHP] using variable in php form before the form is POSTed

At 2:44 PM -0700 5/12/08, milt wrote:
>I have a form that will be filled in by the user, I want to have access to
>the content of one of the fields in that form, in order to fill in an
>another variable that is not part of the form. this variable is used by a
>routine when the form is "posted". Question - is the $_post[field name]
>availble before the submit button is pushed, or is there another way to get
>the contents of the field?
>thanks, Milt


Use hidden, such as:

<input type="hidden" name="step" value="1">

After the form is posted, $_POST['step'] will = 1.

I use this technique all the time so that I can use the same script
to present different forms based upon which step in the form
processing the user is on (i.e., step=1, step=2, step=3 and so on).

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
Reply With Quote
  #5 (permalink)  
Old 05-14-2008
Bastien Koert
 
Posts: n/a
Default Re: [PHP] using variable in php form before the form is POSTed

On Tue, May 13, 2008 at 9:02 AM, tedd <tedd.sperling@gmail.com> wrote:

> At 2:44 PM -0700 5/12/08, milt wrote:
>
>> I have a form that will be filled in by the user, I want to have access to
>> the content of one of the fields in that form, in order to fill in an
>> another variable that is not part of the form. this variable is used by a
>> routine when the form is "posted". Question - is the $_post[field name]
>> availble before the submit button is pushed, or is there another way to
>> get
>> the contents of the field?
>> thanks, Milt
>>

>
> Use hidden, such as:
>
> <input type="hidden" name="step" value="1">
>
> After the form is posted, $_POST['step'] will = 1.
>
> I use this technique all the time so that I can use the same script to
> present different forms based upon which step in the form processing the
> user is on (i.e., step=1, step=2, step=3 and so on).
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> You could get funky and send that data bit via AJAX to the server to be

preprocessed. But likely handling the data bit as the first step on
submission, is gonna be simpler and faster to do


--

Bastien

Cat, the other other white meat

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:27 AM.


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