Mafia Posted March 25, 2009 Share Posted March 25, 2009 Can Anyone Make me a simple contact form in php a quick simple one so i understand how its done please. Link to comment https://forums.phpfreaks.com/topic/151136-contact-page/ Share on other sites More sharing options...
AdRock Posted March 25, 2009 Share Posted March 25, 2009 http://www.ibdhost.com/contact/ Look there Link to comment https://forums.phpfreaks.com/topic/151136-contact-page/#findComment-794005 Share on other sites More sharing options...
unska Posted March 25, 2009 Share Posted March 25, 2009 Here's a simple script. You may need to configure your PHP ini files to get this to work. <? if ($_POST['text']) { $senderName = "The Sender"; // The name of the sender $senderEmail = "[email protected]"; // The email of the sender $receiverEmail = "[email protected]"; // The address where you want to send email $emailSubject = "Hello!"; // The subject of the email $emailMessage = $_POST['text']; // The message on the email $emailHeader = "From: ". $senderName . " <" . $senderEmail . ">\r\n"; // Header fields mail($receiverEmail, $emailSubject, $emailMessage, $emailHeader); // The command that sends the email } ?> <html> <head> </head> <body> <form action="thisfile.php" method="post"> <textarea name="text"></textarea> <br> <input type="submit" name="submit" value="Submit!"> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/151136-contact-page/#findComment-794009 Share on other sites More sharing options...
br0ken Posted March 25, 2009 Share Posted March 25, 2009 It should be pointed out that while that script should work, it creates a security whole. The $_POST['text'] variable should sanitized before being used in the email. Link to comment https://forums.phpfreaks.com/topic/151136-contact-page/#findComment-794047 Share on other sites More sharing options...
unska Posted March 25, 2009 Share Posted March 25, 2009 It should be pointed out that while that script should work, it creates a security whole. The $_POST['text'] variable should sanitized before being used in the email. Yeah, the user should defend the script from injections. Link to comment https://forums.phpfreaks.com/topic/151136-contact-page/#findComment-794057 Share on other sites More sharing options...
Mafia Posted March 26, 2009 Author Share Posted March 26, 2009 Thanks Guys So what you mean by configure your PHP ini files to get this to work. Am Confused Link to comment https://forums.phpfreaks.com/topic/151136-contact-page/#findComment-794376 Share on other sites More sharing options...
br0ken Posted March 26, 2009 Share Posted March 26, 2009 Your INI file stores configuation values for PHP. There are two in particular which relate to your code. ini_set("SMTP", "localhost"); ini_set("smtp_port", 25); You'll only have to modify these if your SMTP server isn't running on localhost or using the default port 25. Your code will probably work, depending on your host. Try it and if you get any errors post them here. Link to comment https://forums.phpfreaks.com/topic/151136-contact-page/#findComment-794451 Share on other sites More sharing options...
redarrow Posted March 26, 2009 Share Posted March 26, 2009 See my sig. <?php /* < delete this only to activate...... //Please use this code to send a email with html format. //only set your email address cal the page mail.php //ini_set("SMTP", "your ip address"); // if needed to set ur ip address ........ //ini_set("smtp_port", "25"); // port your sending smtp from if needed........... $Full_Name='redarrow'; // This is in the message body of the email. $Email='[email protected]'; // This is in the message body of the email. $Messages='hi i am redarrow love php'; // This is in the message body of the email. $to = 'me@what_ever.com'; // set the email address.......... $subject = 'Testing mail!'; //subject of the email //$mes is using caternation . << a dot $mes = "Hello; $Full_Name <br><br> You have recieved an email from $Email <br><br>"; $mes .= "This message below is for your convenience. <br><br> ****************************** <br><br> Full Name: "; $mes .= $Full_Name; $mes .= "<br><br>"; $mes .= "Email: "; $mes .= $Email; $mes .= "<br><br>"; $mes .= "Message: "; $mes .= $Messages; $mes .= "<br><br>****************************** <br><br>This Is An Automatically Generated Message, Do Not Repond!"; $message = $mes; //This is turning a varable to another for the email function. // These are the headers for the email function very inportant... $headers = 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; // we are saying if the email is ent tell us using the email function. if(mail($to, $subject, $message, $headers)){ // message was sent. echo " MAIL WAS SENT TO $to!"; }else{ // message was not sent. echo " SORRY NO MESSAGE SENT TO $to"; } /* < delete this only to activate. ?> Link to comment https://forums.phpfreaks.com/topic/151136-contact-page/#findComment-794453 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.