Jump to content

Recommended Posts

I have a contact form that I want to send to my email. this is the code for the form:

<form method="post" action="contact_us.php" enctype="multipart/form-data" accept-charset="UTF-8">
  <p><img src="assets/images/Notes_rule_small.jpg" alt="notes" width="388" height="23" id="Image2"></p>
  <p class="style5"> </p>
  <p class="style5">Please Complete the Form Below and We Will Get Back to You Very Soon!</p>
  <p class="style5"><span class="text"><br>
    </span><span class="style21">* Indicates a required field.</span></p>
  <p class="style5"><span class="NEW">WE ARE CURRENTLY WORKING ON OUR CONTACT FORMS..<br>
PLEASE EMAIL US AT <a href="mailto:leydigital@hotmail.com">leydigital@hotmail.com</a> WITH YOUR QUESTIONS/INFORMATION</span><br>
    <br>
    <br>
  </p>
  <table border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF">
    <tr valign="top"> <td align="right" nowrap><font face="Verdana" size="2" color="#000000">* Full Name</font></td> 
  <td><input type="text" name="FieldData0" size="40">
    <br>
    <br></td></tr><tr valign="top"> <td align="right" nowrap><font face="Verdana" size="2" color="#000000">* Email Address</font></td> 
    <td><input name="FieldData1" type="text" size="40">
      <br>
      <span class="text">Please make sure you typed it correctly.    </span><br>
    <br></td>
    </tr><tr valign="top"> <td align="right" nowrap><font face="Verdana" size="2" color="#000000">Phone Number</font></td> 
    <td><input type="text" name="FieldData2" size="40">
    <br>
    <br></td></tr><tr valign="top"> <td align="right" nowrap><font face="Verdana" size="2" color="#000000">Preferred Contact Method</font></td> 
    <td><input type=checkbox name="FieldData3-0" value="Phone" id="check30"><font face="Verdana" size="2" color="#000000"><label for="check30">Phone</label></font><br>
    <input type=checkbox name="FieldData3-1" value="Email" id="check31"><font face="Verdana" size="2" color="#000000"><label for="check31">Email</label></font><br>
    <input type=checkbox name="FieldData3-2" value="Carrier Pigeon" id="check32"><font face="Verdana" size="2" color="#000000"><label for="check32">Carrier Pigeon</label></font><br>
    <input type=checkbox name="FieldData3-3" value="ESP" id="check33"><font face="Verdana" size="2" color="#000000"><label for="check33">ESP</label></font><br>
    <br> </td></tr><tr valign="top"> <td align="right" nowrap><font face="Verdana" size="2" color="#000000">* Type of Event</font></td> 
    <td><input type="text" name="FieldData4" size="40">
    <br>
    <br></td></tr><tr valign="top"> <td align="right" nowrap><font face="Verdana" size="2" color="#000000">* Event Location</font></td> 
    <td><textarea name="FieldData5" cols="35" rows="6"></textarea>
        <br>        <br> </td></tr><tr valign="top"> <td align="right" nowrap><font face="Verdana" size="2" color="#000000">* Event Date</font></td> 
        <td><input type="text" name="FieldData6" size="40">
        <br>
<br></td></tr><tr valign="top"> <td nowrap><font face="Verdana" size="2" color="#000000">* How Did You Hear About Us?</font></td> <td>
<select name="FieldData7"><option value="Grace Referral">Grace Referral</option>
<option value="Matt Referral">Matt Referral</option>
<option value="Friend Referral">Friend Referral</option>
<option value="Wedding Site">Wedding Site</option>
<option value="Google">Google</option>
<option value="Yahoo">Yahoo</option>
<option value="Bing">Bing</option>
<option value="Facebook">Facebook</option>
<option value="Other">Other</option>
<option value="" selected></option>
</select>    <br>
  <br>
  <span class="text">If you found us through a wedding website or some other method,<br>
    please indicate which one below with your message, thanks!</span><br> </td>
</tr> 
<td align="right" valign="top" nowrap><font face="Verdana" size="2" color="#000000">* Message</font></td> 
<td><textarea name="FieldData8" cols="35" rows="7"></textarea>
      <br>      <br> </td></tr><tr> <td colspan="2"><table cellpadding=5 cellspacing=0 bgcolor="#CCCCCC" width="100%"><tr bgcolor="#666666"><td colspan="2"><font color="#FFFFFF" face="Verdana" size="2"><b>Image Verification</b></font></td></tr><tr><td width="175" align="right" style="padding: 2px;"><img src="http://www.emailmeform.com/turing.php" id="captcha"></td><td width="270" valign="top" bgcolor="#999999" class="style35"><font color="#000000">Please enter the text from the image</font>   <br>
      <input type="text" name="Turing" value="" maxlength="100" size="10"> 
    [ <a href="#" onclick=" document.getElementById('captcha').src = document.getElementById('captcha').src + '?' + (new Date()).getMilliseconds()">Refresh Image</a> ]</td></tr></table></td></tr><tr> <td> </td> <td align="left">
    <input type="text" name="hida2" value="" maxlength="100" size="3" style="display : none;">
    <input type="submit" class="btn" value="Submit" name="Submit">   
     <input type="reset" class="btn" value="Clear Form" name="Clear"></td></tr><tr><td colspan=2 align="center"><p> </p>
        <p><br>
      </p></td></tr></table></form>

 

and for the action page: contact_us.php

 <?php
// Validate the name and combat Magic Quotes, if necessary.
if (!empty($_REQUEST['FieldData0'])) {
   $name = stripslashes($_REQUEST['FieldData0']);
} else {
   $name = NULL;
echo '<p><font color="red">Please enter your name!</font></p>';
}

// Validate the email and combat Magic Quotes, if necessary.
if (!empty($_REQUEST['FieldData1'])) {
   $email = $_REQUEST['FieldData1'];
} else {
   $email = NULL;
echo '<p><font color="red">Please enter your email address!</font></p>';
}

// If everything was filled out, print the message.
if ($name && $email) {

   echo "<center>Thank you, <b>$name</b>.</center>"; 
   
} else { // One form element was not filled out properly.
   echo '<p><font color="red">Please go back and fill out the form again.   
   </font></p>';
}
echo '<br><br><br><br><br><br><br><br><br><br><br><br><br><br>';
ob_start();
// The message
$message = "";
$subject = "Contact Form";
$to = "kristinakent@gmsil.com";
$headers .= 'From: Ley Digital Music' . "\r\n";

$message .=  $_REQUEST['hFieldData0'] . " " . $_REQUEST['FieldData0'] . "\n";
$message .=  $_REQUEST['hFieldData1'] . " " . $_REQUEST['FieldData1'] . "\n";
$message .=  $_REQUEST['hFieldData2'] . " " . $_REQUEST['FieldData2'] . "\n";
$message .=  $_REQUEST['hFieldData3-0'] . " " . $_REQUEST['FieldData3-0'] . "\n";
$message .=  $_REQUEST['hFieldData3-1'] . " " . $_REQUEST['FieldData3-1'] . "\n";
$message .=  $_REQUEST['hFieldData3-2'] . " " . $_REQUEST['FieldData3-2'] . "\n";
$message .=  $_REQUEST['hFieldData3-3'] . " " . $_REQUEST['FieldData3-3'] . "\n";
$message .=  $_REQUEST['hFieldData4'] . " " . $_REQUEST['FieldData4'] . "\n";
$message .=  $_REQUEST['hFieldData5'] . " " . $_REQUEST['FieldData5'] . "\n";
$message .=  $_REQUEST['hFieldData6'] . " " . $_REQUEST['FieldData6'] . "\n";
$message .=  $_REQUEST['hFieldData7'] . " " . $_REQUEST['FieldData7'] . "\n";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

// Send
$ret = mail($to, $subject, $message);
echo '<br><br>';

?> 

 

That's as far as I got, I don't know how to do the dropdown menu options on the contact_us.php page. Can anyone help? And I would like to make this more secure.

Link to comment
https://forums.phpfreaks.com/topic/186753-php-contact-form-problems/
Share on other sites

I need to know how to code it on the php response page, contact_us.php. As you can see I already have it coded in the html form on contact_us.html. and that is not my email address, this is for a client of mine. my email address is krazykrisi@hotmail.com

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.