Joshua Adams Joshua Adams - 3 months ago 15
PHP Question

Mail not sending values PHP

For some reason when I try to send the values listed below, I get nothing in return. I'll appreciate some help on the matter. Thanks.

My form:

<form method="post" action="email_script.php">
<div class="row uniform 50%">
<div class="6u 12u$(xsmall)">
<input type="text" name="name" id="name" value="" placeholder="Name" />
</div>
<div class="6u$ 12u$(xsmall)">
<input type="email" name="email" id="email" value="" placeholder="Email" />
</div>
</div>
<div class="row uniform 50%">
<div class="12u$">
<input type="text" name="subject" id="subject" value="" placeholder="Subject" />
</div>
</div>
<div class="row uniform 50%">
<div class="12u$">
<textarea name="message" id="message" placeholder="Enter your message" rows="6"></textarea>
</div>
</div>
<div class="row uniform">
<div class="12u$">
<ul class="actions align-center">
<li><input type="submit" value="Send Message" class="special" /></li>
<li><input type="reset" value="Reset Form" /></li>
</ul>
</div>
</div>
</form>


My PHP Script (just echoing the data for debugging)

<?php
$to = 'myemail@domain.com';
$name=$_POST['name'];
$email=$_POST['email'];
$message=$_POST['message'];
$subject = $_POST['subject'];
$Body = "Name:\n$name\n\n";
$Body .= "subject :\n$subject \n\n";
$Body .= "email :\n$email \n\n";
$Body .= "message:\n$message\n\n";

echo $Body;

?>


Sorry guys. It was an .htaccess rule that was causing the issues.

# Resolve .php file for extensionless php urls
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://domain.com/$1 [R=301,L]

RewriteRule ^([^/.]+)$ $1.php [L]

Answer

use

<form method="post" action="email_script.php">    
    <div class="row uniform 50%">
        <div class="6u 12u$(xsmall)">
            <input type="text" name="name" id="name" value="" placeholder="Name" />
        </div>
        <div class="6u$ 12u$(xsmall)">
            <input type="email" name="email" id="email" value="" placeholder="Email" />
        </div>
    </div>
    <div class="row uniform 50%">
        <div class="12u$">
            <input type="text" name="subject" id="subject" value="" placeholder="Subject" />
        </div>
    </div>
    <div class="row uniform 50%">
        <div class="12u$">
            <textarea name="message" id="message" placeholder="Enter your message" rows="6"></textarea>
        </div>
    </div>
    <div class="row uniform">
        <div class="12u$">
            <ul class="actions align-center">
                <li><input type="submit" value="Send Message" class="special" /></li>
                <li><input type="reset" value="Reset Form" /></li>
            </ul>
        </div>
    </div>

    </form>

Check working script at http://main.xfiddle.com/7ffb488b/stackoverflow/contact.php or http://main.xfiddle.com/7ffb488b/stackoverflow/contact.html

Comments