Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

edesignuk

Moderator emeritus
Original poster
Mar 25, 2002
19,232
2
London, England
Another question...:eek:

Any reason why this shouldn't work?

This form:
PHP:
<form name="contactus" action="/?p=sendmail" method="post">
Query Type<select name="query_type">
<option selected>- Please Select -</option>
<option value="webmaster@thurrocktech.com">Webmaster</option>
<option value="jamie@thurrocktech.com">Jamie</option>
<option value="steve@thurrocktech.com">Steve</option>
</select>
<br/>
Name<input name="name" type="text">
<br/>
Email<input name="email" type="text">
<br/>
Confirm Email<input name="emailc" type="text">
<br/>
Telephone<input name="phone" type="text">
<br/> 
Subject<input name="subject" type="text">
<br/> 
Message<textarea name="emailbody"></textarea>
<br/>
<input type="submit">
</form>
Passes to this page to send:
PHP:
<?
$to=$_GET['query_type'];
$subject=$_GET['subject'];
$email=$_GET['emailbody'];
$headers="From: ".$_GET['email'];
$mailsend=mail($to,$subject,$email,$headers);
echo "Thank you";
?>
On the face of it, it seems to be working, I don't get any errors or anything. But no mail is coming through :( :confused:

(I know there are elements of the form that don't pass at the moment, just began working on it ;))
 

dubbz

macrumors 68020
Sep 3, 2003
2,284
0
Alta, Norway
Have you tried setting the various parameters in mail() to something else/static? Eg: Setting '$to' to 'webmaster@thurrocktech.com'. Then repeat for all the params till something happens? It's how I usually troubleshoot. :p

Been to long since I messed with PHP, so I can't be of much help, but maybe this page can be of more help.
 

edesignuk

Moderator emeritus
Original poster
Mar 25, 2002
19,232
2
London, England
Thank you muchly dubbz, not quite sure what fixed it, but after looking at the page you linked to I got it working.

Much appreciated!
 

jim.

macrumors 6502
Dec 22, 2004
308
0
C-ville, VA
In you first form you send as post. However, in your PHP you are trying to pull your variables from $_GET. Try using $_POST.

Jim
 

jeremy.king

macrumors 603
Jul 23, 2002
5,479
1
Holly Springs, NC
Couple other tips - especially if this is exposed to the interweb.

(1) Don't use email addresses in your html forms. Spam bots thrive on this.
(2) Don't use GET, since someone could manipulate URLs and use that form to SPAM
(3) Validate inputs to make sure they came from your site, again to prevent spammers.
(4) Add something to a users session to prevent them from using the form more than once every X minutes.

Good Luck!
 

edesignuk

Moderator emeritus
Original poster
Mar 25, 2002
19,232
2
London, England
kingjr3 said:
Couple other tips - especially if this is exposed to the interweb.

(1) Don't use email addresses in your html forms. Spam bots thrive on this.
(2) Don't use GET, since someone could manipulate URLs and use that form to SPAM
(3) Validate inputs to make sure they came from your site, again to prevent spammers.
(4) Add something to a users session to prevent them from using the form more than once every X minutes.

Good Luck!
All already done except for number 4 ;)

Thanks for the suggestings though everyone.
 

dhracer88

macrumors regular
Feb 21, 2005
113
0
I made a pretty simple one that works well, and has a built in check. I'm not all that fluent in PHP though, so I don't know anything about session checks and what not :eek: ...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.