I need help creating a "Contact" form like the one on http://www.vellephant.com/contact.html Can someone please do it for me? Thanks so much!
Hey, you don't need to pay anybody for such a simple form. You need to use the following code in the html page. <form method="POST" name="contactform" action="mail.php"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="right">Name: </td> <td align="right"> <input type="text" id="TxtName" name="name" onkeypress="clearText();" size="33" /></td> <td rowspan="11" align="center" valign="middle"> <input id="btnSubmit" type="image" src="images/submitbtn.png" value="Submit" name="submit" /> </td> </tr> <tr> <td colspan="2" class="minirowspacer"></td> </tr> <tr> <td align="right">Email id :</td> <td align="right"><input type="text" id="TxtEmail" name="email" size="33" /></td> </tr> <tr> <td colspan="2" class="minirowspacer"></td> </tr> <tr> <td align="right">Contact No:</td> <td align="right"> <input type="text" id="TxtPhone" name="Phone" size="33" /> </td> </tr> <tr> <td colspan="2" class="minirowspacer"></td> </tr> <tr> <td align="right">Address:</td> <td align="right"><input type="text" id="TxtAddress" name="Address" size="33" /> </td> </tr> <tr> <td colspan="2" class="minirowspacer"></td> </tr> <tr> <td align="right">Write your Query:</td> <td align="right"> <textarea id="txtMessage" name="message" cols="25" ></textarea></td> </tr> </table> </form> Code (markup): You need to create a php file named mail.php and put the following code in it <?php //new function $to = "info@yourdomain.com"; $nameto = "SalesManager"; $from = $_POST["Email"]; $namefrom = $_POST["Name"]; $subject = "Message/Query"; $phone = $_POST["Phone"]; $address= $_POST["Address"]; if($address == NULL) $address= " "; $comment= $_POST["Message"]; if($comment == NULL) $comment= " "; //Construct Message $message = "Name: $namefrom" ; $message .= "<br />" . "Email: $from" . PHP_EOL; $message .= "<br />" . "Phone: $phone" . PHP_EOL; $message .= "<br />" . "Address: $address" . PHP_EOL; $message .= "<br />" . "<br />" ."Question/Comment: $comment" . PHP_EOL; try { echo 'Mail sending is in progress...' ; authSendEmail($from, $namefrom, $to, $nameto, $subject, $message) ; echo "Mail Sent Successfully"; echo '<script type="text/javascript">window.location.href = "http://yourdomain.com/index.html?msg=yes" </script>'; } catch(Exception $e) { echo $e->getMessage(); echo "Mail Send failure"; echo '<script type="text/javascript">window.location.href = "http://yourdomain.com/index.html?msg=no" </script>'; } ?> <?php /* * * * * * * * * * * * * * SEND EMAIL FUNCTIONS * * * * * * * * * * * * * */ //This will send an email using auth smtp and output a log array //logArray - connection, function authSendEmail($from, $namefrom, $to, $nameto, $subject, $message) { //SMTP + SERVER DETAILS /* * * * CONFIGURATION START * * * */ $smtpServer = "mail.yourdomain.com"; $port = "25"; $timeout = "30"; $username = "info@yourdomain.com"; $password = "your password"; $localhost = "localhost"; $newLine = "\r\n"; /* * * * CONFIGURATION END * * * * */ //Connect to the host on the specified port $smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout); $smtpResponse = fgets($smtpConnect, 515); // fgets( filenam, length ) if(empty($smtpConnect)) { $output = "Failed to connect: $smtpResponse"; throw $output; } else { $logArray['connection'] = "Connected: $smtpResponse"; } //Request Auth Login fputs($smtpConnect,"AUTH LOGIN" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authrequest'] = "$smtpResponse"; //Send username fputs($smtpConnect, base64_encode($username) . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authusername'] = "$smtpResponse"; //Send password fputs($smtpConnect, base64_encode($password) . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authpassword'] = "$smtpResponse"; //Say Hello to SMTP fputs($smtpConnect, "HELO $localhost" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['heloresponse'] = "$smtpResponse"; //Email From fputs($smtpConnect, "MAIL FROM: $from" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['mailfromresponse'] = "$smtpResponse"; //Email To fputs($smtpConnect, "RCPT TO: $to" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['mailtoresponse'] = "$smtpResponse"; //The Email fputs($smtpConnect, "DATA" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['data1response'] = "$smtpResponse"; //Construct Headers $headers = "MIME-Version: 1.0" . $newLine; $headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine; $headers .= "To: $nameto <$to>" . $newLine; $headers .= "From: $namefrom <$from>" . $newLine; fputs($smtpConnect, "To: $to\nFrom: $from\nSubject: $subject\n$headers\n\n$message\n.\n"); $smtpResponse = fgets($smtpConnect, 515); $logArray['data2response'] = "$smtpResponse"; // Say Bye to SMTP fputs($smtpConnect,"QUIT" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['quitresponse'] = "$smtpResponse"; } ?> Code (markup):
forgot to tell you that you need to change the url and email address to your email address wherever required
If you do a search for free PHP contact form, you will find tons.. I wish I knew the name of the One I am using but can't seem to find it on any of the documentation I have found
They're not trying to rip you off. I'm confident that if you payed somebody to design a form for you, it would be much more advanced and sleek than a basic <form>. But as others have said, there are many free scripts, plugins, etc. out there that will suffice for what you're needing.