View Full Version : Need a contact form....
k3v1n
05-11-2007, 08:25 PM
but not any normal one.
What im after is a full contact form with name, email, subject and of course message. But just before the message box i want another drop down menu that will ask the to select an option i.e website issues, forum issues ect.
When they select the relivent option it'll then select the correct email address to send there email to.
Anybody able to knock me one up? would be very very grateful :)
Thanks
thetestingsite
05-12-2007, 03:11 AM
Well, the form itself is done using HTML, but in order to send the email, you will need to use a server side script (PHP, ASP, etc). If you have PHP installed on your server, you could use the code listed here:
http://www.dynamicdrive.com/forums/showpost.php?p=82975&postcount=3
You can simply modify the html code to include a select box like the following:
<select name="to">
<option value="me@domain.com">Website Stuff</option>
<option value="you@domain.com">Something else</option>
<option value="blah@something.com">Yet Something else</option>
</select>
Hope this helps.
//EDIT: the only part of the script that should be used is the PHP script. For more info, look at Mike's post below.
mwinter
05-12-2007, 02:06 PM
[I need a contact form] but not any normal one.
What im after is a full contact form with name, email, subject and of course message. But just before the message box i want another drop down menu that will ask the to select an option i.e website issues, forum issues ect.
The use of a select element (as demonstrated previously), or a series of radio buttons, can be applied to any stock contact form that allows the choice of multiple addressees.
If you have PHP installed on your server, you could use the code listed here:
http://www.dynamicdrive.com/forums/showpost.php?p=82975&postcount=3
The original code is dreadful. There's no fallback should the request object fail to be created, and the PHP code poses a security risk. I can't open your archive in either Gzip (MingW) or 7-Zip so I can't confirm whether the same applies.
Regardless of the quality of implementation, I don't see the point in involving "AJAX" at all. It just seems another one of those cases where one can say "I've used AJAX", rather than there being any real benefit.
thetestingsite
05-12-2007, 02:15 PM
I should have been more specific in what I meant. The only thing that I was referring to was the use of the PHP code itself, then use any normal form (or that one if the OP wants). You do have a good point though:
I don't see the point in involving "AJAX" at all. It just seems another one of those cases where one can say "I've used AJAX", rather than there being any real benefit.
I simply pointed the OP to that one script because that was a working one that has simple "out-of-the-box" installation, as compared to some others that aren't as easy to implement. Anyways, I have editted my previous post to actually say only to use the PHP aspect of it, rather than the AJAX part.
k3v1n
05-12-2007, 04:53 PM
Thanks guys will give this a go
mwinter
05-12-2007, 05:19 PM
Anyways, I have editted my previous post to actually say only to use the PHP aspect of it, rather than the AJAX part.
But that aspect of it poses a security risk, as I previously wrote. It performs no validation allowing a malicious user to use the script to send spam to anyone they like.
Rolling ones own mail script is a risky venture - I wouldn't be very happy doing it myself. It's better to use a well-known third party script or, even better, remotely-hosted code. With the former, one can hope that it's been well-tested, but blame is still likely to fall on you, the developer, if a vulnerability is found and exploited (unless the original author assumes liability, which is unlikely). With the latter, if anything goes wrong the fault should lie with the provider.
k3v1n
05-12-2007, 07:27 PM
it doesnt work properly. I pasted the html coding into my contact.html file and it made the whole site squashed up in the middle.
any idea's why?
thetestingsite
05-12-2007, 07:44 PM
It's possibly due to some css styling issue. Anyways, you could go keep your html form as long as you use the following names (for this script at least): to, subject, body, from. Other than that, you may have to customize the PHP for it to work with your form.
Hope this helps
k3v1n
05-12-2007, 09:26 PM
So if i keep the php script you gave me above I can edit that to work with any html form?
Im after something like this
<form method="POST" target="_self" action="formmail.php">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="500" id="AutoNumber1" height="282">
<tr>
<td style="border-bottom: 1px solid #E1E1E1; padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="111" height="25">
<b><font size="2" color="#666666" face="Arial">Name:</font></b></td>
<td style="border-bottom: 1px solid #E1E1E1; padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="349" height="25">
<input type="text" name="s1" size="20" style="font-family: Arial; font-size: 8pt; color: #333333" tabindex="1"></td>
</tr>
<tr>
<td style="border-bottom: 1px solid #E1E1E1; padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="111" height="25">
<b><font size="2" color="#666666" face="Arial">Company:</font></b></td>
<td style="border-bottom: 1px solid #E1E1E1; padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="349" height="25">
<input type="text" name="s2" size="20" style="font-family: Arial; font-size: 8pt; color: #333333" tabindex="2"></td>
</tr>
<tr>
<td style="border-bottom: 1px solid #E1E1E1; padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="111" height="25">
<b><font size="2" color="#666666" face="Arial">E-mail Address:</font></b></td>
<td style="border-bottom: 1px solid #E1E1E1; padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="349" height="25">
<input type="text" name="s3" size="20" style="font-family: Arial; font-size: 8pt; color: #333333" tabindex="3"></td>
</tr>
<tr>
<td style="border-bottom: 1px solid #E1E1E1; padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="111" height="25">
<b><font size="2" color="#666666" face="Arial">Subject:</font></b></td>
<td style="border-bottom: 1px solid #E1E1E1; padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="349" height="25">
<input type="text" name="s4" size="20" style="font-family: Arial; font-size: 8pt; color: #333333" tabindex="4"></td>
</tr>
<tr>
<td style="border-bottom: 1px solid #E1E1E1; padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="111" height="25">
<b><font size="2" color="#666666" face="Arial">Website Rating:</font></b></td>
<td style="border-bottom: 1px solid #E1E1E1; padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="349" height="25">
<select size="1" name="s5" style="font-size: 8pt; color: #333333; font-family: Arial" tabindex="5">
<option>-Choose-</option>
<option>1 (worst)</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5 (Best)</option>
</select></td>
</tr>
<tr>
<td style="border-bottom: 1px solid #E1E1E1; padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="111" valign="top" height="25">
<b><font size="2" color="#666666" face="Arial">Referral:</font></b></td>
<td style="border-bottom: 1px solid #E1E1E1; padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="349" height="25">
<input type="text" name="s6" size="20" style="font-family: Arial; font-size: 8pt; color: #333333" tabindex="6"></td>
</tr>
<tr>
<td style="padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="111" height="23"> </td>
<td style="padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="349" height="23"> </td>
</tr>
<tr>
<td style="padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="111" height="23">
<b><font size="2" color="#666666" face="Arial">Message:</font></b></td>
<td style="padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" width="349" height="23"> </td>
</tr>
<tr>
<td style="border-bottom: 1px solid #E1E1E1; padding-left: 10; padding-right: 10; padding-top: 2; padding-bottom: 2" colspan="2" width="480" height="36">
<textarea rows="11" name="s7" cols="87" style="font-size: 8pt; color: #333333; font-family: Arial" tabindex="7"></textarea></td>
</tr>
</table>
<p><font face="Arial" style="font-size: 8pt">
<input type="submit" value="Send Message" name="send" style="font-family: Arial; font-size: 8pt; color: #333333">
<input type="reset" value="Reset Form" name="reset" style="font-family: Arial; font-size: 8pt; color: #333333"></font></p>
</form>
<div align="left">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
<tr>
How would I edit the php script to work with that? or is there a way I can do it without the php script?
djr33
05-13-2007, 12:48 AM
Whoa!
Use CSS!
About 90% of the above code can be deleted, placed in the CSS at the top of your page (or an external .css file), then just use the class attribute to set it, rather than having several lines of formatting per word, as it is now.
thetestingsite
05-13-2007, 01:58 AM
In addition to what djr33 posted above, you should use "unique" names for your form fields (at least names that can identify what field they represent). Below is the PHP contact script code (from the link I posted above), modified for your form (which you posted above).
Simply edit the part in red to point to your email address (which you want the emails sent to).
<?php
/*If you do not have a spot in your form for the "to" address, specify it in the first line; otherwise, uncomment the second line and comment or delete the first one. */
$to = 'me@domain.com';
//$to = $_POST['to'];
$name = $_POST['s1'];
$company = $_POST['s2'];
$email = $_POST['s3'];
$subject = $_POST['s4'];
$rating = $_POST['s5'];
$referral = $_POST['s6']
$message = $_POST['s7'];
else {
$from = 'From: '.$name.' <'.$email.'>';
}
$subject = stripcslashes($subject);
$body = stripcslashes($message);
if(mail($to, $subject, $body, $from)){
echo "Mail ($subject), was successfully sent.";
}
else {
echo "The email ($subject) could not be sent.";
}
?>
Hope this helps.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.