I have a few contact forms on my website. 1 is the main one they there are a few small ones. How do I setup the send.php file for this? First code is the main form, second code, is the small one. <form id="sumbitForm" method="post" action="sendEmail.php"> <span class="smallerText">First Name:</span> <span class="errorMessage" id="nameError"></span><br /> <input type="text" id="nameTextBox" class="input" name="FirstName" /> <br /> <br /> <span class="greyTitle smallerText">Contact Us:</span> <span class="errorMessage" id="nameError"></span><br /> <input type="text" id="nameTextBox" class="input" name="LastName" /> <br /> <br /> <span class="greyTitle smallerText">Company:</span> <span class="errorMessage" id="nameError"></span><br /> <input type="text" id="nameTextBox" class="input" name="Company" /> <br /> <br /> <span class="greyTitle smallerText">City:</span> <span class="errorMessage" id="nameError"></span><br /> <input type="text" id="nameTextBox" class="input" name="City" /> <br /> <br /> <span class="greyTitle smallerText">State:</span> <span class="errorMessage" id="nameError"></span><br /> <input type="text" id="nameTextBox" class="input" name="State" /> <br /> <br /> <span class="greyTitle smallerText">Zip code:</span> <span class="errorMessage" id="nameError"></span><br /> <input type="text" id="nameTextBox" class="input" name="Zipcode" /> <br /> <br /> <span class="greyTitle smallerText">Daytime Phone:</span> <span class="errorMessage" id="nameError"></span><br /> <input type="text" id="nameTextBox" class="input" name="DaytimePhone" /> <br /> <br /> <span class="greyTitle smallerText">Email Address:</span> <span class="errorMessage" id="emailError"></span><br /> <input type="text" id="emailTextBox" class="input" name="EmailAddress" /> <br /> <br /> <span class="greyTitle smallerText">Type of Business:</span> <span class="errorMessage" id="emailError"></span><br /> <input type="text" id="emailTextBox" class="input" name="TypeofBusiness" /> <br /> <br /> <span class="greyTitle smallerText">Locations Desired:</span> <span class="errorMessage" id="emailError"></span><br /> <input type="text" id="emailTextBox" class="input" name="LocationsDesired" /> <br /> <br /> <span class="greyTitle smallerText">Comments:</span> <span class="errorMessage" id="questionError"></span><br /> <textarea id="questionTextArea" class="textArea input" cols="" rows="7" name="questionTextArea"></textarea> <br /> <br /> <input type="button" id="sendButton" value="Send" /> </form> Code (markup): <table width="231" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td> <input type="text" style="background-image:url(images/5StarOutdoor_20.png);background-repeat:repeat-x;border:1px solid #9f9f9f;width: 150px;color:#333333;padding:3px;margin-right:4px;margin-bottom:8px;font-family:tahoma, arial, sans-serif;" size="16" maxlength="12" class="txtGITInput" name="txtname" id="txtname"> </td> </tr> <tr> <td> <input type="text" style="background-image:url(images/5StarOutdoor_20.png);background-repeat:repeat-x;border:1px solid #9f9f9f;width: 150px;color:#333333;padding:3px;margin-right:4px;margin-bottom:8px;font-family:tahoma, arial, sans-serif;" size="16" maxlength="12" name="txtemail" id="txtemail"> </td> </tr> <tr> <td> <textarea rows="3" style="background-image:url(images/5StarOutdoor_19.png);background-repeat:repeat-x;border:1px solid #9f9f9f;width: 230px;color:#333333;padding:3px;margin-right:4px;margin-bottom:8px;font-family:tahoma, arial, sans-serif;" cols="25" name="txtquote" id="txtquote" >Message</textarea> </td> </tr> <tr> <td> <input type="button" name="btnPreview" id="btnPreview" value="Send" title="Send" tabindex="3"> </td> </tr> </table> Code (markup):
This will get you started.... pass a hidden value in your form <input type="hidden" name="action" value="proccess" /> Have the form post to itself. At the top of the script include this code to process the form if ($_POST['action'] == 'process' ){ // validate data, check for requried files, proper data types.... code here.... // if valid, proceed // build email msg $body = 'The following information has been submitted on '. date("F j, Y, g:i a") .chr(10); $body .= 'Name: '. $_POST['FirstName'] . ' ' . $_POST['LastName']; .... // send email mail($to,$subject, $body, $headers); } // end process