Form process problems!

I am very, very new to using any sort of php, I am only somewhat experienced in html and css. I have a form I made in html, but am struggling with my process page. (php) The page works, it emails forms to me, however, I am not getting the drop down list selection (subject) nor am I receiving the (picture) attachment. I am looking to see if someone could help me out on this, I apologize if my code looks like butt, but it’s what I got. :slight_smile: ???

Thank you,

Jared

[php]
<?php

if(isset($_POST[‘email’])) {

$email_to = "support@******.com";

$email_subject = "Contact Form";

$name = $_POST['name'];

$email = $_POST['email'];

$tel = $_POST['tel'];

$subject = $_POST['subject'];

$attachment = $_POST['attachment'];

$description = $_POST['description'];

 

$email_message = "Contact request details below.\n\n";

 

function clean_string($string) {

  $bad = array("content-type","bcc:","to:","cc:","href");

  return str_replace($bad,"",$string);

}

 

$email_message .= "Name: ".clean_string($name)."\n";

$email_message .= "Email: ".clean_string($email)."\n";

$email_message .= "Phone: ".clean_string($tel)."\n";

$email_message .= "Subject: ".clean_string($subject)."\n";

$email_message .= "Picture: ".clean_string($attachment)."\n";

$email_message .= "Description: ".clean_string($description)."\n";

$headers = 'From: '.$email."\r\n".

'Reply-To: '.$email."\r\n" .

‘X-Mailer: PHP/’ . phpversion();

@mail($email_to, $email_subject, $email_message, $headers);

?>

Thank you <?php echo $_POST["name"]; ?> for contacting us. We will respond to your email as soon as possible.

<?php } ?>
      </p>

[/php]

Post your form.

          <form name="contact" id="contact" method="post" action="http://www.******.com/contact/contact.php">
          <table width="428" border="1" cellpadding="0" cellspacing="2" id="formtable">
            <tr>
              <td width="192">Name:</td>
              <td width="224"><input name="name" type="text" required id="name" maxlength="30"></td>
            </tr>
            <tr>
              <td>Email:</td>
              <td><input name="email" type="email" required id="email" maxlength="50"></td>
            </tr>
            <tr>
              <td>Email Confirmation:</td>
              <td><input name="emailConfirm" type="email" required id="confemail" onBlur="confirmEmail()" maxlength="50" />            
            </tr>
            <tr>
              <td>Phone:</td>
              <td><input name="tel" type="tel" id="tel" maxlength="12"></td>
            </tr>
            <tr>
              <td>Category:</td>
              <td><select name="subject" size="1" required id="subject">
                <option value="">Select Subject...</option>
                <option value="services">Services</option>
                <option value="support">Support</option>
                <option value="general">General Questions</option>
                <option value="previous work">Previous Job</option>
              </select></td>
            </tr>
            <tr>
              <td height="30">Picture of your property:</td>
              <td><input name="attachment" type="file" id="picture"></td>
            </tr>
            <tr>
             <td> Descrption:</td>            
              <td>
<textarea name="description" cols="33" rows="7" maxlength="500" id="description" placeholder="Please provide a thorough description of what you are wanting. Thank you for visiting our website, we will get back to you as soon as possible."></textarea>
             </td>
            </tr>
            <tr>
              <td colspan="2" style="text-align: center">
<p>&nbsp;</p>
                <p>
                  <input type="reset"  value="Reset" class="button" id="reset">
                  <input type="submit" value="Submit" class="button" id="submit">
              </p></td>
            </tr>
          </table>
          </form>

Here is an article to read. I am short on time, but you are missing some needed parts for the attachment to function. I would also recommend looking into PHPMailer for the ease of doing complex emails.

Sponsor our Newsletter | Privacy Policy | Terms of Service