0

I have gone searched the net and tried many ways of creating and validating a form which sends info to an email but I can't get my head around it. This is what I have done and it seems to work (have not been able to test if it sends), but every time I submit it comes up with "all fields required error" even with all boxes filled/empty. I looked on this site through similar questions and tried to fix it by them but no luck.

What am I missing? Should I use the php on another page? Once the error is fixed, will it send and keep the information submitted by the user?

In case it helps - I'm using foundation 5 for the site. Beginner at PHP.

<?php
$action=$_REQUEST['action'];
if ($action=="") 
{
?> 
<form action="" method="post">
<div class="row">
<div class="large-12 columns">
<input type="hidden" name="action" value="submit">
<label>Name
<input name"name" type="text" placeholder="Your name"/>
</label>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<label>Email
<input name"email" type="text" placeholder="Your email" />
</label>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<label>Your Message
<textarea name="message" type="text" placeholder="Comment here"/></textarea>
</label>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<input id="submit" type="submit" value="Send Message">
</div>
</div>
</form>
<?php
} 
else 
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields required! Please fill <a href=\"\">in the form</a> again.";
}
else{ 
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Hire";
mail("myemail", $subject, $message, $from);
// back to homepage - will add send confirm when fixed. header( "Location: ");
}
} 
?>

Thanks in advance for any help!

asked Mar 17, 2014 at 3:51
1
  • 2
    You are missing = on name"name" and name"email" Commented Mar 17, 2014 at 3:55

3 Answers 3

2

You're missing = to assign value for your name attribute:

<input name="name" type="text" placeholder="Your name"/>
<!------- ^ here

and:

<input name="email" type="text" placeholder="Your email" />
<!-------- ^ and here
answered Mar 17, 2014 at 3:59
Sign up to request clarification or add additional context in comments.

1 Comment

Don't I feel stupid for not noticing this, it works and receiving email. Thank you for your help!
1

You are giving input attribute name for name and email like this :

 <input name"name" type="text" placeholder="Your name"/> 
<input name"email" type="text" placeholder="Your email" />

Change it to

 <input name="name" type="text" placeholder="Your name"/> 
<input name="email" type="text" placeholder="Your email" />
answered Mar 17, 2014 at 3:59

Comments

0

check this ..Add= to email and name

 <input name="name" type="text" placeholder="Your name"/>
 </label>
 </div>
 </div>
 <div class="row">
 <div class="large-12 columns">
 <label>Email
 <input name="email" type="text" placeholder="Your email" />
 </label>
answered Mar 17, 2014 at 3:59

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.