liamloveslearning Posted September 30, 2009 Share Posted September 30, 2009 hi guys, just tried to make my first ever contact form handcoded as opposed to downloading one online, very unsuccessful in my attempt and its bugging me, can anybody see why this isnt working? I really appreciate any help html Book a Party<br /> <br /> <form id="form1" name="form1" method="post" action="bookparty.php"> <p>Name <br /> <input name="name" type="text" size="30" maxlength="40" /> </p><p>Address<br /> <textarea name="address" cols="30" rows="4"></textarea> </p> <p>Phone number <br /> <input name="phone" type="text" size="30" maxlength="40" /> </p> <p>Email <br /> <input name="email" type="text" size="30" maxlength="40" /> </p> <p>Pref date of party <br /> <input name="date" type="text" size="30" maxlength="40" /> </p> <p>Reason for party <br /> <textarea name="reason" cols="30" rows="4"></textarea> </p> <p>Do you require a stripper (* price on application) <br /> Yes <input name="stripper" type="radio" value="yes" /> No <input name="stripper" type="radio" value="no" /> </p> Is the party for a..<p>Housewarming <input type="checkbox" name="party" value="house"/> </p> <p>Birthday <input type="checkbox" name="party" value="birthday"/> </p> <p>Hen night <input type="checkbox" name="party" value="hennight"/> </p> <br /><input type="submit" name="submit" id="submit" value="Send Email"/> </form> php <?php $name = $_POST['name']; $address = $_POST['address']; $phone = $_POST['phone']; $email = $_POST['email']; $date = $_POST['date']; $reason = $_POST['reason']; $stripper = $_POST['stripper']; $party = $_POST['party']; if (eregi('http:', $notes)) { die ("Do NOT try that! ! "); } if(!$address == "" && (!strstr($address,"@") || !strstr($address,"."))) { echo "<h2>Use Back - Enter valid e-mail</h2>\n"; $badinput = "<h2>Feedback was NOT submitted</h2>\n"; echo $badinput; die ("Go back! ! "); } if(empty($name) || empty($phone) || empty($reason )) { echo "<h2>Use Back - fill in all fields</h2>\n"; die ("Use back! ! "); } $todayis = date("l, F j, Y, g:i a") ; $attn = $attn ; $subject = $attn; $notes = stripcslashes($notes); $message = " $todayis [EST] \n Name: $name \n Address: $address \n Phone: $phone \n $email = $email \n $date = $date \n $reason = $reason \n $stripper = $stripper \n $party = $party \n Additional Info : IP = $ip \n Browser Info: $httpagent \n Referral : $httpref \n "; $from = "From: $name\r\n"; mail("liam@reloaddesign.co.uk", $name, $address, $phone); ?> <p align="center"> Date: <?php echo $todayis ?> <br /> Thank You : <?php echo $name ?> ( <?php echo $name ?> ) <br /> Attention: <?php echo $address ?> <br /> Message:<br /> <?php $notesout = str_replace("\r", "<br/>", $reason); echo $notesout; ?> <br /> <?php echo $ip ?> <br /><br /> <a href="contact.php"> Next Page </a> </p> Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted September 30, 2009 Author Share Posted September 30, 2009 my emails are coming through when i remove the IF email is empty statement, only not all my fields are coming through... ive noticed this and changed it $message = " $todayis [EST] \n Name: $name \n Address: $address \n Phone: $phone \n $email = $email \n $date = $date \n $reason = $reason \n $stripper = $stripper \n $party = $party \n Additional Info : IP = $ip \n Browser Info: $httpagent \n Referral : $httpref \n "; yet im only receiving the name and telephone number (address) Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted September 30, 2009 Author Share Posted September 30, 2009 ive just noticed this mail("liam@reloaddesign.co.uk", $name, $address, $phone); and replaced it with mail("liam@reloaddesign.co.uk", $name, $address, $phone, $email, $date, $reason, $stripper, $party); only now nothings coming through :\ Quote Link to comment Share on other sites More sharing options...
cags Posted September 30, 2009 Share Posted September 30, 2009 You can't pass completely random information to the mail function and expect it to know what to do with it. You mail call should be of the form... <?php mail('liam@reloaddesign.co.uk', 'A Subject', $message); ?> Where $message is the string you created a few posts back. There is an optional 4th parameter but I recommend you ignore that untill you get everything else working. I suspect that the validation your doing on your form doesn't quite work exactly as you planned also, but thats another matter. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 30, 2009 Share Posted September 30, 2009 All of the php functions have a very specific list of parameters that they accept. These are documented in the php programming manual that is available in several formats on php.net. In order to use any php function effectively, you must make use of the documentation for that function. The mail() function does not accept a generic list of the items you want to place in the message body. See this link for what the mail() function requires and actual examples - http://www.php.net/manual/en/function.mail.php Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted September 30, 2009 Author Share Posted September 30, 2009 so by random information do you mean where I have the likes of $address, $phone, $email, $date, $reason, $stripper etc, that these values/arrays/parameters (not sure what there called sorry) are predefined in php and you cant create your own? sorry to sound so amateur Quote Link to comment Share on other sites More sharing options...
cags Posted September 30, 2009 Share Posted September 30, 2009 No we mean your passing the mail function lots of different $variables that aren't applicable to it. PFMaBiSmAd has helpfully linked to the official documentation explaining all this. But as a simple breakdown, in it's simplest format the mail function should be of this format.... mail ( string $to , string $subject , string $message) I.e. in laymans terms, you must pass it a target email address, a subject and an actually message to send. Quote Link to comment Share on other sites More sharing options...
pankajnagarkoti84 Posted October 10, 2009 Share Posted October 10, 2009 my emails are coming through when i remove the IF email is empty statement, only not all my fields are coming through... Quote Link to comment Share on other sites More sharing options...
cags Posted October 10, 2009 Share Posted October 10, 2009 And your code now looks like? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.