madox Posted September 30, 2008 Share Posted September 30, 2008 Guys, I am new to php and I am sure this question has come up, I don't see why it is not working. I have this in two parts: Here is my html code for the form <form action="contact.php" method="get"> <div class="container1"> <div class="col-3"> <div class="h"><input type="your_name" value="name" /></div> <div class="h"><input type="your_email" value="e-mail" /></div> <div class="h"><input type="your_phone" value="phone" /></div> <div class="h"><input type="your_address" value="address" /></div> </div> <div class="col-4"> <textarea name="message" cols="35" rows="35">message</textarea><br /> <div class="fright"> <div class="link-2"><em><b><a href="#" onclick="document.getElementById('contact.php').submit()">Send</a></b></em></div> <div class="indent"><div class="link-2"><em><b><a href="#" onclick="document.getElementById('contact.php').reset()">Clear</a></b></em></div></div> </div> </div> <br class="clear" /> </div> </form> contact.php <? $subject="from ".$_GET['your_name']; $headers= "From: ".$_GET['your_email']."\n"; $phone="from: ".$_GET['your_phone']; $address="from: ".$_GET['your_address']; $headers.='Content-type: text/html; charset=iso-8859-1'; mail("my-emailaddress@here" <html> <head> <title>Contact letter</title> </head> <body> <br> ".$_GET['message']." </body> </html>" , $headers); echo ("Your message was successfully sent!"); ?> <script> resizeTo(300, 300) //window.close() </script> Any help would be great. Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/ Share on other sites More sharing options...
Maq Posted September 30, 2008 Share Posted September 30, 2008 What are you trying to do? What errors are you getting? Have you tried echoing out values to make sure they're correct. Also, please use the code tags, makes life a lot easier. Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-653960 Share on other sites More sharing options...
madox Posted September 30, 2008 Author Share Posted September 30, 2008 I don't get any errors that I can tell, no I did not echo error. This form will supply me with the info to my e-mail address Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-653965 Share on other sites More sharing options...
madox Posted September 30, 2008 Author Share Posted September 30, 2008 The e-mail never comes to my inbox. Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-653969 Share on other sites More sharing options...
Brian W Posted September 30, 2008 Share Posted September 30, 2008 Besides using the code tags and I'd like to hear what issues are arising, your form itself looks like it would never work... <div class="h"><input type="your_name" value="name" /></div> <div class="h"><input type="your_email" value="e-mail" /></div> <div class="h"><input type="your_phone" value="phone" /></div> <div class="h"><input type="your_address" value="address" /></div> "type" isn't what you want to name your input, its the tag for what type of form object to use. try: <input type="text" name="your_name" value="name" /> Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-653973 Share on other sites More sharing options...
Brian W Posted September 30, 2008 Share Posted September 30, 2008 no I did not echo error. Maybe you should then? any ways, your mail function is f'd up. see the manual about mail. http://us2.php.net/mail Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-653976 Share on other sites More sharing options...
Maq Posted September 30, 2008 Share Posted September 30, 2008 Brian W. is right the types you have should be the names. Do: One more question before we proceed, why don't you use POST rather than GET? It's easier and more secure. All you would have to do in your contact.php script would just use: //For your_name input field $_POST['your_name']; Also your code is all messed up. You don't use starting or ending php tags. For example you have: mail("my-emailaddress@here" First the here" is messed up, not even a finished line, second you're going from PHP to HTML without tags. Maybe they're not showing up because you didn't use the code tags like i suggested. Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-653980 Share on other sites More sharing options...
madox Posted September 30, 2008 Author Share Posted September 30, 2008 That didn't work. Nothing in my e-mail box. Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-653981 Share on other sites More sharing options...
Brian W Posted September 30, 2008 Share Posted September 30, 2008 Now that you've done some fixing, re post what you have (IN CODE TAGS ) Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-653984 Share on other sites More sharing options...
Maq Posted September 30, 2008 Share Posted September 30, 2008 You need to learn the basics of PHP first. There's a lot of fundamental mistakes in your script. For example: " , $headers); Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-653987 Share on other sites More sharing options...
madox Posted September 30, 2008 Author Share Posted September 30, 2008 I added the code to the contact.php file and it didn't give me any error's. Here is my contact.php code <? ini_set ("display_errors", "1"); error_reporting(E_ALL); $subject="from ".$_GET['your_name']; $headers= "From: ".$_GET['your_email']."\n"; $phone="from: ".$_GET['your_phone']; $address="from: ".$_GET['your_address']; $headers.='Content-type: text/html; charset=iso-8859-1'; mail("my-e-mail address" <html> <head> <title>Contact letter</title> </head> <body> <br> ".$_GET['message']." </body> </html>" , $headers); echo ("Your message was successfully sent!"); ?> <script> resizeTo(300, 300) //window.close() </script> <form action="contact.php" method="get"> <div class="container1"> <div class="col-3"> <div class="h"><input type="text" name="your_name" value="name"></div> <div class="h"><input type="text" name="your_address" value="name"/></div> <div class="h"><input type="text" name="your_phone" value="name"/></div> <div class="h"><input type="text" name="your_address" value="name" /></div> </div> <div class="col-4"> <textarea name="message" cols="35" rows="35">message</textarea><br /> <div class="fright"> <div class="link-2"><em><b><a href="#" onclick="document.getElementById('contact.php').submit()">Send</a></b></em></div> <div class="indent"><div class="link-2"><em><b><a href="#" onclick="document.getElementById('contact.php').reset()">Clear</a></b></em></div></div> </div> </div> <br class="clear" /> </div> </form> Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-654000 Share on other sites More sharing options...
madox Posted September 30, 2008 Author Share Posted September 30, 2008 yes. you are correct. I want to learn php and just start trying to learn it. Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-654002 Share on other sites More sharing options...
Maq Posted September 30, 2008 Share Posted September 30, 2008 Okay first thing, you need to learn when to use the <?php ?> tags. For example: ini_set ("display_errors", "1"); error_reporting(E_ALL); $subject="from ".$_GET['your_name']; $headers= "From: ".$_GET['your_email']."\n"; $phone="from: ".$_GET['your_phone']; $address="from: ".$_GET['your_address']; $headers.='Content-type: text/html; charset=iso-8859-1'; mail("my-e-mail address" Needs to be: ini_set ("display_errors", "1"); error_reporting(E_ALL); $subject="from ".$_GET['your_name']; $headers= "From: ".$_GET['your_email']."\n"; $phone="from: ".$_GET['your_phone']; $address="from: ".$_GET['your_address']; $headers.='Content-type: text/html; charset=iso-8859-1'; mail("my-e-mail address" //WTF is this!? ?> See the difference? Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-654006 Share on other sites More sharing options...
madox Posted September 30, 2008 Author Share Posted September 30, 2008 Sorry I fixed my code. I must have deleted it somehow. Here is the code again, plus I fix the tag. <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $subject="from ".$_GET['your_name']; $headers= "From: ".$_GET['your_email']."\n"; $phone="from: ".$_GET['your_phone']; $address="from: ".$_GET['your_address']; $headers.='Content-type: text/html; charset=iso-8859-1'; mail("my email address", $subject, " <html> <head> <title>Contact letter</title> </head> <body> <br> ".$_GET['message']." </body> </html>" , $headers); echo ("Your message was successfully sent!"); ?> <script> resizeTo(300, 300) //window.close() </script> Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-654020 Share on other sites More sharing options...
Brian W Posted September 30, 2008 Share Posted September 30, 2008 Maq, I told madox to read http://us2.php.net/mail It has a great example of what the mail() function should look like. You should also make the body of your email a string than have the string in the function. mail('youremail', $subject, $body, $headers) also, html doesn't always go well in emails, many email clients don't accept the tags. please some one inform me of how to change that if there is a way. line breaks can be accomplished with \n\r Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-654032 Share on other sites More sharing options...
Maq Posted September 30, 2008 Share Posted September 30, 2008 Kind of like what Brian W said, it's much easier to format the mail variables separate from the function (not tested!): $headers "whatever you need"; $subject = "Hello there"; $my_email = "tim@yahoo.com"; $message = " Contact letter ".$_GET['message']." "; mail("my email address", $subject, $message, $headers); Quote Link to comment https://forums.phpfreaks.com/topic/126476-help-please-on-a-form/#findComment-654095 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.