Jump to content

[SOLVED] can't seem to get mail form working


generic

Recommended Posts

Hi, I'm a graphic designer with very limited programming experience and this is just not working for me. When I try to submit the form using the following code, the form does nothing. It doesn't even submit at all. Anyone spot anything that might be causing this (aside from the general sloppiness of the code itself)? Thanks in advance!

 

Gen

 

<?php

if (isset($_POST['submit'])){
        
        $to = "me@mysite.com";
        $subject = "website contact";
    
        $name = $_POST['name'];
        $phone = $_POST['phone'];
        $email = $_POST['email']; 
        $query = $_POST['query'];
$strbody="Name:".$name."\r\n Phone :".$phone."\r\n Email :".$email."\r\n Query :".$query."\r\n"; 

mail($to, $subject, $strbody); 
        
        echo "<p>Success!</p>";
    
    } else {
    
        echo "<form id=\"contact\" name=\"contact_form\" method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">
	<p class=\"contact_label\">Your Name:<br />
            <input name=\"name\" type=\"text\" /><br />
            Your Email:<br />
            <input name=\"email\" type=\"text\" /><br />
            Your Phone Number:<br />
            <input name=\"phone\" type=\"text\" /><br />
            Question/Comment:<br />
            <textarea name=\"query\" cols=\"\" rows=\"4\"></textarea>
          </p>
          <p>
            <input name=\"submit\" id=\"submit\" type=\"button\" value=\"Send It\" style=\"width: auto;\" />
          </p>
	 </form>";
}
        
    ?>

Link to comment
Share on other sites

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.