I have a form
<form
method="post"
class="c-form"
action="mail.php"
id="contactform"
>
<div class="row">
<div class="col-lg-12">
<div class="error-alert"></div>
</div>
<div class="col-lg-12">
<input
type="text"
id="subject" name="subject"value="<?php echo $deviceType['device_type_name']; ?> Repair"
/>
</div>
<div class="col-lg-12">
<input
type="text"
placeholder="NAME"
id="name"
name="name"
/>
</div>
<div class="col-lg-12">
<input
type="text"
placeholder="EMAIL"
id="email"
name="email"
/>
</div>
<div class="col-lg-12">
<input
type="text"
placeholder="PHONE NUMBER"
name="phone"
/>
</div>
<div class="col-lg-12">
<textarea
rows="5"
placeholder="YOUR MESSAGE"
id="message"
name="message"
></textarea>
</div>
<div class="col-lg-12">
<input
type="submit"
class="submit"
value="Contact Us"
id="submit"
/>
<img
src="images/ajax-loader.gif"
class="loader"
alt=""
/>
</div>
</div>
</form>
But when I submit the form two fields (subject and message) isn't showing in the $_POST or $_REQUEST array (other 3 fields name, phone and email is present in the array). (the variable $deviceType['device_type_name']; has value, so there is no issue there)
Can anyone please tell me what am I missing here.
mail.php file (nothing much here just for debugging):
<?php
print_r($_POST);
die();?>
Related
I am recently getting into php and am running it locally on Xampp. I have created the following simple form followed by a few lines of php. It seems that no data is being passed through from the html form to the php page.
<form method="post" action="emailform.php" enctype="text/plain" class="form-horizontal">
<div class="row input">
<div class="col-md-1"></div>
<div class="col-md-10">
<div class="form-group">
<input type="text" name="subject" id="subject" class="form-control" placeholder="subject">
</div>
</div>
</div>
<div class="row input">
<div class="col-md-1"></div>
<div class="col-md-4">
<div class="form-group">
<input type="text" name="name" id="name" class="form-control" placeholder="full name">
</div>
<div class="form-group">
<input type="email" name="subject" id="email" class="form-control" placeholder="email">
</div>
</div>
<div class="col-md-1"></div>
<div class="col-md-5 textarea">
<textarea class="form-control" name="message" id="message" rows="4" placeholder="message"></textarea>
</div>
</div>
<br>
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-10">
<button type="submit" class="btn" id="submit">Send</button>
</div>
</div>
</form>
This is the simple php code I am using to test:
<?php
$subject = 'No subject was set';
if (isset($_POST['subject'])) {
$subject = ($_POST['subject']);
}
echo "This is the subject:$subject";
?>
I appreciate any help as I have been struggling with this simple code for the past week now.
Two subject names!
<input type="email" name="subject" id="email" class="form-control" placeholder="email">
^
and
<input type="text" name="subject" id="subject" class="form-control" placeholder="subject">
^
Also remove enctype="text/plain" from the form
It's because PHP doesn't handle it
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 in the form 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!
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
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" />
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>
I'm using the HTML5 input date type. After posting, I see this input empty, and all the other inputs (HTML4 types) are OK.
What could be the reason?
This is my form:
<form action="/SGM/index.php?r=manager/addcoach_post" method="post">
<div class="registerFeildArea2">
<div class="registerTxtP2">Family name</div>
<div class="registerFeild">
<input name="lname" type="text" value="" size="" class="registerFeildValue" />
</div>
</div>
<div class="registerFeildArea">
<div class="registerTxtP2">First name</div>
<div class="registerFeild">
<input name="fname" type="text" value="" size="" class="registerFeildValue" />
</div>
</div>
<div class="registerFeildArea2">
<div class="registerTxtP2">Address</div>
<div class="registerFeild">
<input name="address" type="text" value="" size="" class="registerFeildValue" />
</div>
</div>
<div class="registerFeildArea">
<div class="registerTxtP2">City</div>
<div class="registerFeild">
<input name="city" type="text" value="" size="" class="registerFeildValue" />
</div>
</div>
<div class="registerFeildArea2">
<div class="registerTxtP2">Birthdate</div>
<div class="birthDayFeild">
<input name="bdate" id="meeting" type="date" value="2011-01-13"/>
</div>
</div>
<div class="AddBtn"><input name="Next" type="submit" value="הוסף" class="AddBtnValue" /></div>
</form>
And when I get to the actionAddcoach_post(), all the fields are OK except for the bdate.
What could be the reason?
This question already has an answer here:
Making an Email Form Send Email
(1 answer)
Closed 9 years ago.
I have the following code for an email form from an HTML template. I'd like to make it send email, as the moment I think it doesn't and I need to add some PHP to process the form. Any tips on how to do that for this form?
Thank you!
<!-- Email -->
<article id="email" class="panel">
<header>
<h2>Email Me</h2>
</header>
<form action="#" method="post">
<div class="5grid">
<div class="row">
<div class="6u">
<input type="text" class="text" name="name" placeholder="Name" />
</div>
<div class="6u">
<input type="text" class="text" name="email" placeholder="Email" />
</div>
</div>
<div class="row">
<div class="12u">
<input type="text" class="text" name="subject" placeholder="Subject" />
</div>
</div>
<div class="row">
<div class="12u">
<textarea name="message" placeholder="Message"></textarea>
</div>
</div>
<div class="row">
<div class="12u">
<input type="submit" class="button" value="Send Message" />
</div>
</div>
</div>
</form>
</article>
You should read http://php.net/manual/es/function.mail.php
so you get your data with $_POST and then treated data, to use something like this:
$message = wordwrap($message, 70, "\r\n");
mail('myMail#example.com', 'subject', $message);
I'm trying to get a Formmail form to re-direct back to it's own page. For example, if I'm on the page, http://www.rightfittech.com/paincenter/contact-us.html, I would like the re-direct to go back to http://www.rightfittech.com/paincenter/contact-us.html, which is the same page.
I searched Google like crazy, and no worthwhile results. The forums keep saying to create a hidden input field
BUT THIS IS NOT WORKING!!!
My code below, and note that I didn't modify formmail, except for email addresses!
<form action="http://www.rightfittech.com/paincenter/formmail.php" name="Contact" method="post"
id="form1">
<input type="hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER" >
<input type="hidden" name="redirect" value="http://www.rightfittech.com/paincenter/contact-us.html"/>
<input type="hidden" name="recipients" value="robertmyrick#hotmail.com" >
<input type="hidden" name="mail_options" value="FromAddr=robertmyrick#hotmail.com" >
<input type="hidden" name="subject" value="New Contact" >
<div class="wrapper row-2">
<div class="col-1">
<div class="form">
<label>First Name:</label>
<input type="text" />
</div>
<div class="form">
<label>Last Name:</label>
<input type="text" />
</div>
<div class="form">
<label>E-mail:</label><br/>
<input type="text" />
</div>
<div class="form">
<label>Phone Number:</label>
<input type="text" />
</div>
</div>
<div class="col-2">
<div>
<label>Enter Your Message:</label>
<textarea cols="1" rows="1"></textarea>
</div>
<div class="wrapper">
<div class="alignright" style="float:left">
<em><b>Clear</b></em>
<div style="width:20px; float:left"> </div>
<em><b>Submit</b></em></div>
</div>
</form>
Try setting the value good_url instead of redirect.
Like so:
<input type="hidden" name="good_url"
value="http://www.rightfittech.com/paincenter/contact-us.html"/>