nzGoner Posted September 21, 2009 Share Posted September 21, 2009 i bought this template and going well, but i am stuck with the contact page, i want the user to be able to fill the contact form and send it to my mailbox.. yes i have tried it myself and also build my own contact.php . But the template coding is a bit confusing for me i need some help please :'( <div id="content"> <div class="bg-cont png"> <div class="indent-main"> <div class="container"> <div class="col-1"> <div class="box"> <form action="" id="form2"> <div class="indent-box"> <img alt="" src="images/6page_title1.gif" class="title1" /><br /> <div class="h1"><input type="text" class="input1" value="Name: " /></div> <div class="h1"><input type="text" class="input1" value="E-Mail: " /></div> <div class="h1"><input type="text" class="input1" value="Phone:" /></div> <div class="h1"><input type="text" class="input1" value="State:" /></div> <textarea rows="40" class="textarea" cols="30" value="Message:">Message:</textarea><br /> <div class="fright"> <a href="#" class="link-1" onclick="document.getElementById('form2').reset()"><em><b>Reset</b></em></a> <div class="indent-2"><a href="#" class="link-1" onclick="document.getElementById('form2').submit()"><em><b>Send</b></em></a></div> </div> <div class="clear"></div> </div> </form> </div> so lets say i make a contact.php and i will change it to <form action="contact.php" id="form2"> how about this line: what should i replace with "a href?????? " <div class="fright"> <a href="#" class="link-1" onclick="document.getElementById('form2').reset()"><em><b>Reset</b></em></a> <div class="indent-2"><a href="#" class="link-1" onclick="document.getElementById('form2').submit()"><em><b>Send</b></em></a></div> and here is my contact.php page... it doesn't work properly <?php $name = $_POST['Name']; $email = $_POST['E-Mail']; $phone = $_POST['Phone']; $state = $_POST['State']; $Message = $_POST['Message']; $to = "gilbylu@gmail.com"; $subject; $message = ""; foreach($_POST as $key=>$value) { $message .= $key.": ".$value."\n\r"; } mail($to,$subject,$message); ?> <html> <head> <title> Contact - Message Sent</title> <body> Message Sent Succesfully. </body> </html> thanks ~ Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/ Share on other sites More sharing options...
MadTechie Posted September 21, 2009 Share Posted September 21, 2009 <form action="" id="form2"> should be <form action="" method="POST" id="form2"> Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922619 Share on other sites More sharing options...
nzGoner Posted September 22, 2009 Author Share Posted September 22, 2009 tried it , still doesnt work !! <form action="" id="form2"> should be <form action="" method="POST" id="form2"> Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922647 Share on other sites More sharing options...
MadTechie Posted September 22, 2009 Share Posted September 22, 2009 define doesnt work !! it doesn't work properly Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922651 Share on other sites More sharing options...
nzGoner Posted September 22, 2009 Author Share Posted September 22, 2009 define doesnt work !! it doesn't work properly sorry, it doesnt send me the email Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922652 Share on other sites More sharing options...
nzGoner Posted September 22, 2009 Author Share Posted September 22, 2009 define doesnt work !! it doesn't work properly Hey ya, i have been trying and somehow it sent an email to my junk box and a message from nobody , cant see the message i type,no subjet, no email address Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922725 Share on other sites More sharing options...
ozestretch Posted September 22, 2009 Share Posted September 22, 2009 Subject is not defined.. well you need to make it defined with what you want anyways. <?php $subject = 'Now the email has a subject'; // edit with own subject line next, blank message case sensitive perhaps! <?php $message = $_POST['Message']."\r\n"; // change to lowercase and remove $message=''; //$message = ""; remove this, now the message will be in the email before the other details of the contact form want a from? add headers. <?php $headers = "From: ".$name."<".$email.">\r\n"; mail($to,$subject,$message,$headers); // add $headers into mail function ?> Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922727 Share on other sites More sharing options...
nzGoner Posted September 22, 2009 Author Share Posted September 22, 2009 Subject is not defined.. well you need to make it defined with what you want anyways. <?php $subject = 'Now the email has a subject'; // edit with own subject line next, blank message case sensitive perhaps! <?php $message = $_POST['Message']."\r\n"; // change to lowercase and remove $message=''; //$message = ""; remove this, now the message will be in the email before the other details of the contact form want a from? add headers. <?php $headers = "From: ".$name."<".$email.">\r\n"; mail($to,$subject,$message,$headers); // add $headers into mail function ?> it is getting better, it appears on my mail box now... but i still dont see any message this is what it looks like From Nobody <nobody@shuttle.dnsprotect.com> to gilbylu@gmail.com date Tue, Sep 22, 2009 at 6:10 PM subject Tour and here is the code for the contact.php <?php $headers = "From: ".$name."<".$email.">\r\n"; mail($to,$subject,$message,$headers); $subject = 'Tour'; $name = $_POST['Name']; $email = $_POST['E-Mail']; $phone = $_POST['Phone']; $state = $_POST['State']; $message = $_POST['Message']."\r\n"; $to = "gilbylu@gmail.com"; $subject; foreach($_POST as $key=>$value) { $message .= $key.": ".$value."\n\r"; } mail($to,$subject,$message); ?> <html> <head> <title> Contact - Message Sent</title> <body> Message Sent Succesfully. </body> </html> and my html code <div id="content"> <div class="bg-cont png"> <div class="indent-main"> <div class="container"> <div class="col-1"> <div class="box"> <form action="contact.php" method="POST" id="form2"> <div class="indent-box"> <img alt="" src="images/6page_title1.gif" class="title1" /><br /> <div class="h1"><input type="text" class="input1" value="Name: " /></div> <div class="h1"><input type="text" class="input1" value="E-Mail: " /></div> <div class="h1"><input type="text" class="input1" value="Phone:" /></div> <div class="h1"><input type="text" class="input1" value="State:" /></div> <textarea rows="40" class="textarea" cols="30" value="Message:">Message:</textarea><br /> <input type="reset" value="reset" /> <input type="submit" value="submit" /> <div class="clear"></div> </div> </form> </div> thanks alot man :'( Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922736 Share on other sites More sharing options...
ozestretch Posted September 22, 2009 Share Posted September 22, 2009 <?php $subject = 'Tour'; $name = $_POST['Name']; $email = $_POST['E-Mail']; $phone = $_POST['Phone']; $state = $_POST['State']; $message = "Name: $name\r\n"; $message.= "Email: $email\r\n"; $message.= "Phone: ".$_POST['Phone']."\r\n"; $message.= "State: ".$_POST['State']."\r\n"; $message.= "Message: ".$_POST['Message']."\r\n"; $to = "gilbylu@gmail.com"; $headers = "From: ".$name."<".$email.">\r\n"; if(!mail($to,$subject,$message,$headers)){ $err = 'Message Not Sent.'; }else{ $err = 'Message Sent Succesfully.'; } ?> <html> <head> <title> Contact - Message Sent</title> <body> <?php echo $err; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922739 Share on other sites More sharing options...
nzGoner Posted September 22, 2009 Author Share Posted September 22, 2009 <?php $subject = 'Tour'; $name = $_POST['Name']; $email = $_POST['E-Mail']; $phone = $_POST['Phone']; $state = $_POST['State']; $message = "Name: $name\r\n"; $message.= "Email: $email\r\n"; $message.= "Phone: ".$_POST['Phone']."\r\n"; $message.= "State: ".$_POST['State']."\r\n"; $message.= "Message: ".$_POST['Message']."\r\n"; $to = "gilbylu@gmail.com"; $headers = "From: ".$name."<".$email.">\r\n"; if(!mail($to,$subject,$message,$headers)){ $err = 'Message Not Sent.'; }else{ $err = 'Message Sent Succesfully.'; } ?> <html> <head> <title> Contact - Message Sent</title> <body> <?php echo $err; ?> </body> </html> its getting better but when i check my email geeez i am still researching ... man it is hard from to gilbylu@gmail.com date Tue, Sep 22, 2009 at 6:40 PM subject Tour hide details 6:40 PM (0 minutes ago) Name: Email: Phone: State: Message: Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922742 Share on other sites More sharing options...
ozestretch Posted September 22, 2009 Share Posted September 22, 2009 ermmm, sorry for not seeing this before, I will let you add this (some homework ) no names given to form fields.... <div id="content"> <div class="bg-cont png"> <div class="indent-main"> <div class="container"> <div class="col-1"> <div class="box"> <form action="contact.php" method="POST" id="form2"> <div class="indent-box"> <img alt="" src="images/6page_title1.gif" class="title1" /><br /> <div class="h1"><input type="text" class="input1" name="Name" value="Name: " /></div> <div class="h1"><input type="text" class="input1" name="E-Mail" value="E-Mail: " /></div> <div class="h1"><input type="text" class="input1" name="Phone" value="Phone:" /></div> <div class="h1"><input type="text" class="input1" name="State" value="State:" /></div> <textarea rows="40" class="textarea" cols="30" name="Message">Message:</textarea><br /> <input type="reset" value="reset" /> <input type="submit" value="submit" /> <div class="clear"></div> </div> </form> </div> Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922745 Share on other sites More sharing options...
nzGoner Posted September 22, 2009 Author Share Posted September 22, 2009 ermmm, sorry for not seeing this before, I will let you add this (some homework ) no names given to form fields.... <div id="content"> <div class="bg-cont png"> <div class="indent-main"> <div class="container"> <div class="col-1"> <div class="box"> <form action="contact.php" method="POST" id="form2"> <div class="indent-box"> <img alt="" src="images/6page_title1.gif" class="title1" /><br /> <div class="h1"><input type="text" class="input1" name="Name" value="Name: " /></div> <div class="h1"><input type="text" class="input1" name="E-Mail" value="E-Mail: " /></div> <div class="h1"><input type="text" class="input1" name="Phone" value="Phone:" /></div> <div class="h1"><input type="text" class="input1" name="State" value="State:" /></div> <textarea rows="40" class="textarea" cols="30" name="Message">Message:</textarea><br /> <input type="reset" value="reset" /> <input type="submit" value="submit" /> <div class="clear"></div> </div> </form> </div> i did muck around with it before, is it to do with name=""? and i just add them myself before they only have <div class="h1"><input type="text" class="input1" value="Name: " /></div> this is what they look like before :S or textarea rows="40" class="textarea" cols="30" >Message:</textarea><br /> Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922750 Share on other sites More sharing options...
nzGoner Posted September 22, 2009 Author Share Posted September 22, 2009 u make my day!! thanks man ... it works, i will try some more !! another thanks for u _b ermmm, sorry for not seeing this before, I will let you add this (some homework ) no names given to form fields.... <div id="content"> <div class="bg-cont png"> <div class="indent-main"> <div class="container"> <div class="col-1"> <div class="box"> <form action="contact.php" method="POST" id="form2"> <div class="indent-box"> <img alt="" src="images/6page_title1.gif" class="title1" /><br /> <div class="h1"><input type="text" class="input1" name="Name" value="Name: " /></div> <div class="h1"><input type="text" class="input1" name="E-Mail" value="E-Mail: " /></div> <div class="h1"><input type="text" class="input1" name="Phone" value="Phone:" /></div> <div class="h1"><input type="text" class="input1" name="State" value="State:" /></div> <textarea rows="40" class="textarea" cols="30" name="Message">Message:</textarea><br /> <input type="reset" value="reset" /> <input type="submit" value="submit" /> <div class="clear"></div> </div> </form> </div> Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922754 Share on other sites More sharing options...
ozestretch Posted September 22, 2009 Share Posted September 22, 2009 value="" with inputs will make that the value, the actual data in the field itself. with textarea, the value is the data within <textarea> this is the data which is the value </textarea> name="" is what is used when 'identifying', the key, of each value. (I am no good at explaining ) so where <input type=text" name="email" value="me@ohmy.com" /> or what value is entered by the user you would retrieve it on your process form with $email = $_POST['email]; <-- where ['this value=the name of the field'], assuming the method used in the form was method="POST" I stop now, I confusing me Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922764 Share on other sites More sharing options...
nzGoner Posted September 22, 2009 Author Share Posted September 22, 2009 value="" with inputs will make that the value, the actual data in the field itself. with textarea, the value is the data within <textarea> this is the data which is the value </textarea> name="" is what is used when 'identifying', the key, of each value. (I am no good at explaining ) so where <input type=text" name="email" value="me@ohmy.com" /> or what value is entered by the user you would retrieve it on your process form with $email = $_POST['email]; <-- where ['this value=the name of the field'], assuming the method used in the form was method="POST" I stop now, I confusing me nah, it is all good, i learnt alot from ya. ok now i figure some problem.... i recievied the email fine and works well but i click reply it shows sdfs@gamil.com Name: 222asdsa <E-Mail:> as in fulll i try modify $headers = "From: ".$name."<".$email.">\r\n"; to $headers = "From: ".$email."\r\n"; is that right? and i wana modify the $err = 'Message Sent Succesfully.'; do i just do it from there. i mean make the text go mid and insert a picture etc thanks~ Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922772 Share on other sites More sharing options...
ozestretch Posted September 22, 2009 Share Posted September 22, 2009 i try modify $headers = "From: ".$name."<".$email.">\r\n"; to $headers = "From: ".$email."\r\n"; is that right? Yes and i wana modify the $err = 'Message Sent Succesfully.'; do i just do it from there. i mean make the text go mid and insert a picture etc You can output any html or text in $err eg: $err='<p class="message"><img src="mailsent.jpg" alt="Email Sent" /></p>'; Quote Link to comment https://forums.phpfreaks.com/topic/175051-template-contact-form-help/#findComment-922778 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.