Getting variables from form and create mail(newbie question)
Posted: Sat May 22, 2004 11:56 am
I want to get all the variables from the form and then send them in a mail. I want to send the mail in the same PHP page as the form is located.
Here's the form:
So when the button is clicked the mailFunction should start. How do you define a function in PHP?
So the mail function should be something like this:
Can anyone help me with this code?
Thanks
Here's the form:
Code: Select all
<form>
<table width="594" border="1">
<tr>
<td width="147" height="19">Naam:</td>
<td width="359"><input name="naam" type="text" id="naam" size="70"></td>
</tr>
<tr>
<td>Straat en nummer:</td>
<td><input name="straat" type="text" id="straat" size="70"></td>
</tr>
<tr>
<td>Postcode:</td>
<td><input name="postcode" type="text" id="postcode" size="70"></td>
</tr>
<tr>
<td>Gemeente:</td>
<td><input name="gemeente" type="text" id="gemeente" size="70"></td>
</tr>
<tr>
<td>Email-adres:</td>
<td><input name="email" type="text" id="email" size="70"></td>
</tr>
<tr>
<td>Tel. of GSM-nummer: </td>
<td><input name="telefoon" type="text" id="telefoon" size="70"></td>
</tr>
<tr>
<td colspan="2"><input name="button" onClick:'mailFunction' value="Bestelling verzenden per email"></td>
</tr>
</table>
</form>So the mail function should be something like this:
Code: Select all
<?php
/* recipients */
$to = "mary@example.com" . ", " ; // note the comma
$to .= "kelly@example.com";
/* subject */
$subject = "User info";
/* message */
$message = '
<html>
<body>
Naam: <? echo _GET[naam];?> /* How do you get that form variable???*/
Straat: <? echo _GET[straat];?>
and so on...
</body>
</html>
';
/* and now mail it */
mail($to, $subject, $message);
?>Thanks