Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,227,719 members, 8,071,388 topics. Date: Wednesday, 05 February 2025 at 09:45 PM |
Nairaland Forum / Science/Technology / Webmasters / Php Help (1290 Views)
Socket Programming In Php Help Hints ? / Php Help! Urgent / Email Retrieval With Php - Help Anyone? (2) (3) (4)
Php Help by tolu93: 12:54pm On Jun 29, 2012 |
please i need help with my contact page. am developing a website for my company and this code aint working
thanks in anticipation |
Re: Php Help by DualCore1: 2:18pm On Jun 29, 2012 |
Post the HTML part of your contact form. Meanwhile here's my review of your code. What's the essence of this: $username = $_POST['Name']; $email = $_POST['Email']; $message = $_POST['Message']; $to = "setin@yahoo.com"; $subject = "Contact Us"; $email = $_REQUEST['Email'] ; $message = $_REQUEST['Message'] ; You define a variable twice. This is not wrong but useless in this context and it may be part of your problem(s). Clean this up. I cant do the cleaning for you without the HTML. ============ What is the essence of this? header("Location: contactus.php" ; before this? $sent = mail($to, $subject, $message, $headers) ; This may be the major part of your problem. You are redirecting the flow to a different location before it executes the mail function. That header() line should be removed from where it is and placed inside the if($sent){} block. Post your html as requested earlier and you will get a fix for your code. Not the entire html, just place all within the <form></form> tags. 1 Like |
Re: Php Help by Afam4eva(m): 3:25pm On Jun 29, 2012 |
Listen to dualcore oo. In PHP, codes are excetuted from the top and it's not right for you to put a redirect function before a code that you want executed because as soon as the server sees "header("Location: contactus.php)", then off it goes. Meanwhile, let's see your html form. |
Re: Php Help by switchmax8: 7:53pm On Jun 29, 2012 |
//Send EMail Script// $name = $_POST['name'] ; $email = $_POST['email'] ; $phone = $_POST['phone'] ; $message = $_POST['message'] ; $message = "Name: $name\nEmail: $email\nPhone: $phone\nMessage: $message\n"; $extra = "From: $Name\r\nReply-To: $Email\r\n"; mail("web@nairaland.com", "Web Development", $message, "From: $email" ); echo"<h1>Thanks,response will get to you as soon as possible.<h1>"; } ?> This is what it should look i used this most of the times for my website 1 Like |
Re: Php Help by sarutobi: 7:57pm On Jun 29, 2012 |
Everything should work fine until the interpreter gets to the line that contains the header statement. There you have instructed PHP to forget everything done so far and go straight to "contact.php". Something tells me you want to redirect the user to the contact page AFTER the mail has been sent which means the header statement should be the LAST line. Another scenario is that you wanted to INCLUDE the "contact.php" file as an helper class to the current script, in this case you use "REQUIRE" or "INCLUDE" and this statement should be at the very top. All this is as a result of 'copy and paste' Dual core and afam were spot on. |
Re: Php Help by tolu93: 12:50pm On Jul 09, 2012 |
Dual Core: Post the HTML part of your contact form.this is the form </head> <body> <table> <tr> <td> flash tinz </td> </tr> </table> <br/> <br/> <table width="463" align="center"> <tr><div align="center" id="menu"> <td width="65"><div align="center"><a href="pages/about us.php">About us</a></div></td> <td width="50"><div align="center"><a href="pages/partners.php">Partners</a></div></td> <td width="38"><div align="center"><a href="pages/board of dir.php">Board</a></div></td> <td width="41"><div align="center"><a href="pages/clients.php">Clients</a></div></td> <td width="78"><div align="center"><a href="pages/mgt.php">Management</a></div></td> <td width="48"><div align="center"><a href="pages/product.php">Product</a></div></td> <td width="42"><div align="center"><a href="pages/career.php">Career</a></div></td> <td width="65"><div align="center"><a href="pages/contact us.php">Contact us</a></div></td> </div> </tr> </table> <br/> <br/> <br/> <table width="126" height="160" align="left" bordercolordark="#000000"> <tr dir="rtl"> <td width="157" height="150"><p align="center"><strong>Head Office</strong> </p> <p align="center"> 2/4,Abimbola way, <br>Industrial Estate, <br>Isolo, Lagos State, <br>Nigeria</p></td> </tr> </table> <table> <div align="center"> <tr align="center" valign="middle"> <td width="742" height="247" align="center"><p align="center" class="style4 ">Please Contact us today to find out more about the services that we offer and how we can help you:</p> <p align="center" class="style4 "> Service Enquiries Tel:</p> <p align="center" class="style4 "> Email: </p> <p align="center" class="style4 ">Technical Complaints & Support Tel: </p> <p align="center" class="style4 ">Email:</p> <p align="center" class="style4 "> Enquiry/Feedback Form If you'd like us to contact you or would like to drop a feedback, please complete the form below: </p> <form action="contactsub.php" method="post" name="form1" id="form1"> <label> <div align="center">Name * <input type="text" name="Name" /> </div> </label> <p align="center"><label>Phone number * <input type="text" name="Phone number" /> </label> </p> <p align="center"> <label>Email * <input type="text" name="Email" /> </label> </p> <p align="center"> <label>Location * <input type="text" value="country" name="Location" /> </label> </p> <p align="center"> <label>Message: <textarea name="textarea"></textarea> </label> </p> <p align="center"> <label> <input type="submit" value="Submit" /> </label> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> </form> <p align="center" class="style4 "> </p></td> </tr> </div> </table> <table width="749" height="84"> <div> <tr> <td width="149" height="78"><p>2/4,Abimbola way, <br>Industrial Estate, <br>Isolo,Lagos State, <br>Nigeria</p></td> <br/> <br/> <td width="224">phone number,Email add</td> <br/> <br/> <td width="169"><div align="center"> <p>Copyright©2012 <br>Developed and Designed <br>by ladekids</p> </div></td> </tr> </div> </table> </body> </html> |
Re: Php Help by yawatide(f): 12:58pm On Jul 09, 2012 |
hmmm, e b like say d html worse pass the php o! At any rate, dual has said it all. Also, for form input, consider using REQUEST as opposed to POST. Good luck! 1 Like |
Re: Php Help by tolu93: 1:05pm On Jul 09, 2012 |
sarutobi: Everything should work fine until the interpreter gets to the line that contains the header statement.am new to php and reading it on my own. |
Re: Php Help by tolu93: 1:14pm On Jul 09, 2012 |
yawa-ti-de:if its cos of the css part that's another page and not yet include it to my html page,until i get my php code.its just a practice project cos am new to php |
Re: Php Help by DualCore1: 1:53pm On Jul 09, 2012 |
Apply the suggestions given above and let us know where you are having problems. |
Re: Php Help by tolu93: 2:27pm On Jul 09, 2012 |
Dual Core: Apply the suggestions given above and let us know where you are having problems.thanks all the way,the error is stated below Warning: mail() [function.mail]: Failed to connect to mailserver at "" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\dame\pages\contactsub.php on line 17 We encountered an error sending your mail. line 17 is: $sent = mail($to, $subject, $message, $body); thank you guys |
Re: Php Help by Murphy7h4: 2:30pm On Jul 09, 2012 |
Thanks a lot[img]http://www.50centloseweight.com[/img] |
Re: Php Help by Afam4eva(m): 2:41pm On Jul 09, 2012 |
tolu93:This error signifies that you've not set yourt mail variable in the php.ini file to be able to send mail from your localhost. |
Re: Php Help by tolu93: 2:45pm On Jul 09, 2012 |
afam4eva:Changed my SMTP to blank,then sendemail_from to my mail address,now its on my mail()function. this is the code <?php $name = $_POST['name'] ; $email = $_POST['email'] ; $phone = $_POST['phone'] ; $message = $_POST['message'] ; $country = $_POST['country']; $message = "Name: $name\nEmail: $email\nPhone: $phone\nLocation: $country\nMessage: $message\n"; $body = "From: $name\r\nReply-To: $email\r\n"; $to ="tolulope_odumosu@yahoo.com"; $subject = "Contact Us"; $sent = mail($to, $subject, $message, $body); if($sent) { print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ?> |
Re: Php Help by Afam4eva(m): 2:49pm On Jul 09, 2012 |
tolu93:You have to get the SMPT settings for the mail server that you want to use eg gmail etc. |
Re: Php Help by DualCore1: 4:37pm On Jul 09, 2012 |
tolu93: If this is the only warning (problem) you are having then its not a big issue. Just upload the script to its location on the internet and run it from there. You won't have this issue. As explained above the reason you are having that error is because you did not configure SMTP settings for your WAMP installation on your local webserver. Sadly I can't help with that as i have never had the patience to do that (its useless IMHO, cuz I know the mail function will work when I put it online... I don't need to be testing that offline). |
Re: Php Help by yawatide(f): 7:07pm On Jul 09, 2012 |
OP: My comment about your bad code has nothing to do with CSS but the fact that you are using tables and table cells, making the code barely readable. I will end with a story. I won't explain the moral so you better get it at the end: Many moons ago, I took a class in lawn tennis. During practice, we would serve the ball slow and vice versa during a game. One day, it ticked off the teacher so bad that he came to us yelling. Paraphrasing him, he said in so many words, "if you serve slow during practice, you will eventually get used to that and serve slow during a real game. True professionals play the same in practice as they do when in a real game." 1 Like |
Re: Php Help by Nobody: 9:28pm On Jul 10, 2012 |
Dual Core: That's the solution. |
(1) (Reply)
How Can One Change Or Alter IP Address? / Take Advantage Of Facebook Timeline To Boost Your Visibility / Joomla Bulksms Template Spc4(help)
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2025 Oluwaseun Osewa. All rights reserved. See How To Advertise. 59 |