Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submitting forms in Php

Status
Not open for further replies.

gajer

Vendor
Jan 10, 2008
4
ZA
Hello, I need to have an online form submitted to my email address, but I do not want to have it use the customers email client. The server side language supported by my host is PHP, but I am clueless in this regard. The page can be viewed at I need all the fields to be sent to my email address. Can anyone help with php code, and how it should be integrated.
 
Change the action of your form from mailto:... to a page that will hold your script.

The script can be something as simple as:

Code:
$formfields="The Form Contents: Textfield1:" . $_POST['textfield'] . "<br>Textfield2:" . $_POST['textfield2'] . "<br>Textfield3:" . $_POST['textfield3'] . "<br>Textfield4:" . $_POST['textfield4'] . "<br>SeletBox:" . $_POST['select'] . "<br>Textfield5:" . $_POST['textfield5'] . "<br>Textfield6:" . $_POST['textfield6'];


$to      = 'nobody@example.com';
$subject = 'the subject';
$message = $formfields;
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);





----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
HI, thanks for the reply. It kinda makes sense, seeing as I've not use php before. But to be sure, how would I associate my online form with the code.
I'm a bit lost from the "$headers =" bit.
 
As I said change the Action of your form. that reads action="mailto:...." to the file that will hold the script such as, myemailscript.php.

Make sure the file myemailscript.php is located in the same folder as the page that contains your form.

As for the headers, that's just your information, Replace webmater@example.com with your email. or the email you wish to appear in the FROM field of the email you receive.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top