Results 1 to 2 of 2
Hi peeps, im a newb to PHP and canot understand why my script is not working properly.
my code is
Code:
<?php
if (isset($_REQUEST['email'])){
$to = "chris{at]absoluteurl*";
$subject = "Contact ...
- 02-04-2010 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 11
Basic PHP mail function help.
Hi peeps, im a newb to PHP and canot understand why my script is not working properly.
my code is
* wont let me post linksCode:<?php if (isset($_REQUEST['email'])){ $to = "chris{at]absoluteurl*"; $subject = "Contact Form Enquiry"; $message = $_REQUEST["message"]; $from = $_REQUEST["email"]; mail($to,$subject,$message,$from); header('Location: absoluteurl*');} else{ header('Location: absoluteurl*');} ?>
*wont let me post links
Now the email sends fine but its the bit where i ask if the email box is not filled in then it should go to the error page but it always forwards to the "thanks.php" page.
Any help is appeiated.
the form code is as below;
Code:<form name="contactform" method="post" action="contactscript.php"> <fieldset id="contactfield"> <legend id="contactleg">Contact Form</legend> Name: <input class="contactform" type="text" size="30" name="name" value="name"/><br /><br /> Email Address: <input class="contactform" type="text" size="30" name="email" value="email"/><br /><br /> Message: <br /><textarea rows="10" cols="30" name="message" value="message">Type your message here</textarea><br /> <input type="submit" value="Send Message" name="submit" /> </fieldset> </form>
- 02-04-2010 #2
header does a 301 redirect which means it happens in the browser. The script will carry on running on the server.
So, you need to stop the script after a redirect.
Also learn to validate user input - never trust the buggers!Code:header('Location: absoluteurl*'); exit();If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)
My new blog. It's probably not as good as I think it is.


Reply With Quote