Forums

PHP

This topic is locked

Enquiry form

Posted 08 May 2006 08:34:57
1
has voted
08 May 2006 08:34:57 Raquel Poh posted:
I have created an enquiry form but i need to add in some validation in the name, email,enquiry and date of departture and arrival... not only that I would like the filled in forms to be sent back to my email and afterwhich upon clicking the submit button, users will be directed to a "thank you" page.I have used html as well as php. Do you know how to do that? This is the html form code:

<form name="enquiry" method="post" action="enqu.php">
<table width="98%" height="363" border="0" align="center">
<tr>
<td height="359">
<table width="95%" border="0">
<tr>
<td colspan="2" bgcolor="#996600"> </td>
</tr>
<tr bgcolor="#FFFFCC">
<td colspan="2"><font color="#FF0000" size="2" face="Alaska">*</font><font size="2" face="Alaska">Full
name(in NRIC):
<input name="name" type="text" id="name" size="50" maxlength="100">
</font></td>
</tr>
<tr>
<td width="39%" bgcolor="#FFFFCC"><font size="2" face="Alaska">Tel
(Home/ Office):
<input name="homenumber" type="text" id="homenumber" size="10" maxlength="10">
</font></td>
<td width="61%" bgcolor="#FFFFCC"><font size="2" face="Alaska">(Mobile):
<input name="hpnumber" type="text" id="hpnumber" size="10" maxlength="10">
</font></td>
</tr>
<tr bgcolor="#FFFFCC">
<td colspan="2"><font color="#FF0000" size="2" face="Alaska">*</font><font size="2" face="Alaska">Email:
<input name="email" type="text" id="email" size="30" maxlength="50">
</font></td>
</tr>
<tr bgcolor="#FFFFCC">
<td colspan="2"><font size="2" face="Alaska">Date of Departure:
<input name="dateofdept" type="text" id="dateofdept" size="2" maxlength="2">
/
<input name="monthofdept" type="text" id="monthofdept" size="2" maxlength="2">
/
<input name="yearofdept" type="text" id="yearofdept" size="4" maxlength="4">
<font size="1">(dd/mm/yyyy) </font></font></td>
</tr>
<tr bgcolor="#FFFFCC">
<td colspan="2"><font size="2" face="Alaska">Date of Return:
<input name="dateofreturn" type="text" id="dateofreturn" size="2" maxlength="2">
/
<input name="monthofreturn" type="text" id="monthofreturn" size="2" maxlength="2">
/
<input name="yearofreturn" type="text" id="yearofreturn" size="4" maxlength="4">
<font size="1">(dd/mm/yyyy) </font> </font></td>
</tr>
<tr bgcolor="#FFFFCC">
<td height="102" colspan="2"> <p><font size="2" face="Alaska"><br>
Name of other travellers: <br>
<textarea name="nameoftravellers" cols="50" rows="4" id="nameoftravellers">1)
2)
3)</textarea>
<br>
</font></p>
</td>
</tr>
<tr bgcolor="#FFFFCC">
<td colspan="2"><font color="#FF0000" size="2" face="Alaska">*</font><font size="2" face="Alaska">Your
enquiry: <br>
<textarea name="enquiry" cols="50" rows="5" id="enquiry"></textarea>
<input type="submit" name="Submit" value="Send">


<br>
<br>
<br>
<br>
</font></td>
</tr>
</table></td>
</tr>
</table>
<div align="center"> </div>
</form>

And this is the php code:

<?
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;

mail( " ", "Feedback Form Results",
$message, "From: $email" );
header( "Location: thankyou.html" );
?>


Thank you so much!!!

Replies

Replied 08 May 2006 12:52:46
08 May 2006 12:52:46 Roddy Dairion replied:
Hi Raquel, Do u get any error message with the current code you're using??
Replied 09 May 2006 04:34:15
09 May 2006 04:34:15 Raquel Poh replied:
I didn't get any error with the codes im using. I did check out how to do the validation on DWMX2004 however, when i set to validate the name, email and enquiry, and when i tried to leave the enquiry form blank while submitting, the error message only appear that name and email should be filled in but not the enquiry field.

As for allowing the data to be submitted back to me via email i still can't figure that out.

The php code is still not on track and i wonder what should be added in. Thanks alot for replying!!
Replied 10 May 2006 12:07:00
10 May 2006 12:07:00 Roddy Dairion replied:
For the email to be sent to you, you need to preset an email address where all the mail will be sent to you for example
<pre id=code><font face=courier size=2 id=code>
&lt;?php
$email = $_POST['email'] ;
$message = $_POST['message'] ;

mail( " ", "Feedback Form Results", $message, ""From: \nReply-To: $ \n" );
header( "Location: thankyou.html" );
?&gt;
</font id=code></pre id=code>
This shud work fine for emailing.
Replied 11 May 2006 06:41:27
11 May 2006 06:41:27 Raquel Poh replied:
Thank you so much for your help@@@ I figured out how to do ita already!!! Thanks alot, once again!!!
c",)

Reply to this topic