Reply to Re: query string passing woes........ help... please....

Your name:

Reply:


Posted by J.O. Aho on 02/28/07 16:06

rcoan@chaparralboats.com wrote:
> ok, this is my first attempt at php and this all seemed simple enough
> when I started. Well everything's working except one thing.
>
> This page is being passed emailaddress in a query string:
> http://www.chaparralmedia.net/brochureRequests/contact.htm?emailaddress=r_coan%40hotmail.com
>
> How do I get that from contact.htm to a varible in my contact.php
> page?

Quick look at the contact.htm source, the form seems ok.

In your contact.php you need to "fetch" the values sent, as since of PHP 4.1
the global values are by default turned off (older PHP examples assumes it's on).

$emailaddress=$_POST['emailaddress'];

Now the value sent with the form is stored in the variable $emailaddress.

If you try to access the page with

http://www.chaparralmedia.net/brochureRequests/contact.php?emailaddress=r_coan%40hotmail.com

the $emailaddress will be empty, as the method is now get and not post as
default for a form.

$emailaddress=$_GET['emailaddress'];

this would store the value in $emailaddress, if you use the get-method, but
that won't normally work on forms (you can change the method if you want,
check w3c for options).

If you want to be able to use both results via the get and post method, then
use $_REQUEST:

$emailaddress=$_REQUEST['emailaddress'];

If you are unsure how the data is sent, use $_REQUEST.


> I'm trying to make the php script send an email with the form
> data to the email address (emailaddress) but I can't seem to get it to
> work.

There are risks of using data from a form, specially if the user can select to
whom to send the e-mail.

mail("mail@to.address.example.net","The Subject","The message you want to send
to the person with mail@to.address.example.net address.");

See this page for further information, do read all the user comments before
you use mail(): http://www.php.net/manual/en/function.mail.php

--

//Aho

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация