NYCPHP Meetup

NYPHP.org

[nycphp-talk] gnubie questions regarding working with form contents...

Joshua S. Freeman jfreeman at amnh.org
Thu May 1 22:39:59 EDT 2003


brilliant Greg..

I'll try it all out tomorrow and let everyone know how it worked out.

Thanks!

g'night!

J.

On 5/1/03 10:38 PM, "Greg Wilson" <greg at mbwpartners.net> wrote:

> On Thu, 2003-05-01 at 22:21, Joshua S. Freeman wrote:
>> I have a page with PHP doing the following things so far:
>> 
>> 1) if NOT submitting, then display a form.
>> 
>> 2) if submitting, echo the contents of the submission and insert into the
>> values into a database.
>> 
>> The insert statement is working just fine.
>> 
>> I'm having some problems with the echoing of the contents to the page.
>> 
>> 
>> Here is the echo statement I'm using to echo the inserted values:
>> 
>> ----------snip------------
>> 
>> while (list($name, $value) = each($HTTP_POST_VARS)) {
>> 
>>     echo "$name = $value<br>.\
";
>> 
>> ----------snip------------
>> 
>> 
>> problem number one is:  I forgot how to do that using 'foreach' instead of
>> while()  each()...
> 
> try:
> foreach ($arr as $key => $value) {
>   echo "Key: $key; Value: $value<br>\
";
> }
> 
> 
>> 
>> problem number two is: because of contents of $HTTP_POST_VARS, "submit =
>> submit " is coming up as a result of the
>> 
>> echo "$name = $value<br>.\
"
>> 
>> statement.
>> 
>> In other words, in addition to showing the submitter the values of his/her
>> submission, s/he's also seeing that 'submit=submit' is a value too...
>> 
> 
> before your foreach:
> unset ($HTTP_POST_VARS['submit']);
> this will pull it out of the array
> 
>> 
>> The next problem is that I need to take the submitted name/value pairs and
>> format and send an email with them to one email address... I have no idea
>> how do that though I know it involves $HTTP_POST_VARS again...
>> 
> 
> change the foreach statement above to:
> foreach ($arr as $key => $value) {
>   echo "Key: $key; Value: $value<br>\
";
>   $message .= "Key: $key; Value: $value<br>\
";
> }
> 
> and then use the mail function, something like:
> mail($contactemail, $subject, $message, $headers);
> to send the values.
> 
> 
>> I want to do this all on one page.
>> 
>> Any help/pointers appreciated!
>> 
> 
> hope that helps!
> 
> greg
> 
> 
>> Thanks!
>> 
>> Joshua
>> 
>> 
>> 
>> 
>> 
>> 
> 
> 
> 
> --- Unsubscribe at http://nyphp.org/list/ ---
> 
> 
> 




More information about the talk mailing list