Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have this form:
<form class="contact-form" method="post" action="mailto:dre4311#gmail.com">
<p class="input-block">
<input type="text" name="name" id="name" placeholder="Name *" />
</p>
<p class="input-block">
<input type="email" name="email" id="email" placeholder="Email *" />
</p>
<p class="input-block">
<button class="button turquoise submit" type="submit" id="submit"><i class="icon-paper-plane-2"></i></button>
</p>
</form>
I would like to know, when people fill it how can I send the same filled details in the email?
<?PHP
$email = $_POST["emailaddress"];
$to = "you#youremail.com";
$subject = "New Email Address for Mailing List";
$headers = "From: $email\n";
$message = "A visitor to your site has sent the following email address to be added to your mailing list.\n
Email Address: $email";
$user = "$email";
$usersubject = "Thank You";
$userheaders = "From: you#youremailaddress.com\n";
$usermessage = "Thank you for subscribing to our mailing list.";
mail($to,$subject,$message,$headers);
mail($user,$usersubject,$usermessage,$userheaders);
?>
i wish may it's will help you .
Try this method
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$website = $_POST['website'];
$type = $_POST['type'];
$message = $_POST['message'];
$formcontent=" From: $name \n Website: $website \n Message: $message";
$recipient = "YOUREMAIL#HERE.COM";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
?>
Related
I've found some similar questions to my query, but none that fully match my situation.
I had a basic mail() PHP setup for use on the contact form on my website but, turns out this is blocked on my hosting server to avoid spam/abuse.
The web host recommends using SMTP as a workaround, but the tutorial they link to doesn't seem to provide a working solution for me!
This is my HTML:
<form action="php/mail.php" method="POST">
<p class="form-field-title">Name</p>
<input class="contact-field focus-hide" type="text" id="name" name="name" required autocomplete="off">
<p class="form-field-title">Email Address</p>
<input class="contact-field focus-hide" type="email" id="email" name="email" required autocomplete="off">
<p class="form-field-title">Phone</p>
<input class="contact-field focus-hide" type="text" id="number" name="number" autocomplete="off">
<p class="form-field-title">Message</p>
<textarea class="contact-field focus-hide" id="message" name="message" data-gramm_editor="false" required autocomplete="off"></textarea>
<input class="contact-button" type="submit" value="Send Message">
</form>
And this is my original (non-SMTP) mail.php code:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$number = $_POST['number'];
$message = $_POST['message'];
$formcontent="Name: $name \nEmail: $email \nPhone Number: $number \nMessage: $message";
$recipient = "email#email.com";
$subject = "Website Contact Form Enquiry";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
header('Location: ../thanks.html');
exit();
?>
I have the email server details for my web hosting, but none of the SMTP solutions I've found are working for me!
Is anyone able to help me? I've seen a few things about using PEAR, but their website doesn't seem to be working...?
Thanks!
If your form is in an email, I think you can't post data (maybe I'm wrong). But you can send it to your script with method get.
<form action="php/mail.php" method="GET">
</form>
Then update your php :
<?php
$name = $_GET['name'];
$email = $_GET['email'];
$number = $_GET['number'];
$message = $_GET['message'];
$formcontent="Name: $name \nEmail: $email \nPhone Number: $number \nMessage: $message";
$recipient = "email#email.com";
$subject = "Website Contact Form Enquiry";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
header('Location: ../thanks.html');
exit();
?>
It should do the job.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I created an email form and after the submit button is pressed I want a pop up to appear, not open a new tab.
This is the form:
<form name="contactform" method="post" action="send_form_email.php">
<input class="inputForm" type="text" name="name" id="nameInput" placeholder="name*">
<input class="inputForm" type="text" name="email" id="emailInput" placeholder="email*">
<textarea name="message" placeholder="message*"></textarea>
<input id="submitButton" type="submit" name="submit">
</form>
And here is the php for it:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = "myemail#gmail.com";
$subject = "New message";
mail ($to, $subject, $message, "From: " . $name);
echo "Your message has been sent!";
?>
This is technically an alert, but here you go!
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = "myemail#gmail.com";
$subject = "New message";
mail ($to, $subject, $message, "From: " . $name);
echo('<script>
alert("Your message has been sent!")
</script>')
?>
I think this is what you were asking for, but if you were asking for something else, I hope you find it!
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
Hope you can help, I am trying to knock up a contact form for my website which is HTML, styled with CSS and the email sent with PHP.
Website: Evan Ciniello
Issue One: When a message is submitted through the contact form it does not redirect, or refresh (ends up at www.evanciniello.ca/php/submit.php)
Issue Two: The body of the message itself is not visible in my inbox (i.e I can see who sent the email but can not read the message).
Contact HTML form
<div id="container" class="clearfix">
<div class="element clearfix col2-3 contact">
<form id="contact-us" action="/php/submit.php" method="post">
<h1>Contact Us!</h1>
<input type="text" name="first_name" placeholder="NAME" required>
<input type="email" name="email" placeholder="MAIL" required>
<textarea name="message" placeholder="MESSAGE" required ></textarea>
<input id="button" type="submit" class="submit"></button>
</form>
<div id="error" style="display:none;"> Please Provide Valid Information</div>
</div>
</div>
PHP Form
<?php
if(isset($_POST['submit'])) {
$to = "contact#evanciniello.ca";
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
$success = mail($to, $subject, $body);
}
?>
This is normal. In your /php/submit.php
if (isset($_POST['submit'])) {
if (empty($_POST["message"]) || empty($_POST["first_name"]) || empty($_POST["email"])) {
//Set up some error messages here and show that to the users.
} else {
$to = "contact#evanciniello.ca";
$subject = "Form Tutorial";
$name_field = $_POST['first_name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
$success = mail($to, $subject, $body);
if ($succes) {
//Now we need to redirect
$url = "http://www.evanciniello.ca/WHEREYOUWANTTOREDIRECT";
Header("Location: " . $url);
} else {
//Set up error message, that message can not be setn
die("Message can not be sent");
}
}
}
Add a name to the submit:
<input id="button" type="submit" class="submit" name="submit"></button>
My form is sending a blank email (field data empty) to me every time i visit my site or refresh it.
I had a look at a few posts mentioning 'Post/Redirect/Get', but that confused me more than helped, and im not sure if it pertains to my exact issue.
This was a basic responsive form i found online and had to find the PHP to actually send the form data. (Changing it to suit my needs)
I'm hoping there's just an error i've missed somewhere but i cant seem to find it.
Any help would be greatly appreciated. Thanks in advance.
Here is the basic form (minus css):
PHP:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent=" From: $name \n Phone: $phone \n Email: $email \n Message: $message";
$recipient = "MY EMAIL HERE";
$subject = "Portfolio Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
HTML:
<form id="contact-form" action="/" method="post">
<h3>Say Hello!</h3>
<h4>Fill in the form below, and I'll get back to you as soon as i can. Thanks!</h4>
<div>
<label>
<span>Name: (required)</span>
<input placeholder="Please enter your name" type="text" name="name" tabindex="1" required autofocus>
</label>
</div>
<div>
<label>
<span>Email: (required)</span>
<input placeholder="Please enter your email address" type="text" name="email" tabindex="2" required>
</label>
</div>
<div>
<label>
<span>Telephone: (required)</span>
<input placeholder="Please enter your number" type="text" name="phone" tabindex="3" required>
</label>
</div>
<div>
<label>
<span>Message: (required)</span>
<textarea placeholder="Include all the details you can" type="text" name="message" tabindex="5" required></textarea>
</label>
</div>
<div>
<button name="submit" type="submit" id="contact-submit">Send Email</button>
</div>
</form>
use isset
<?php
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent=" From: $name \n Phone: $phone \n Email: $email \n Message: $message";
$recipient = "MY EMAIL HERE";
$subject = "Portfolio Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
}
?>
it will post your email only when it submitted by any ..
i have post this one for other in stackoverflow link code link
this is my code.let try , i wish it will help you
<?PHP
$email = $_POST["emailaddress"];
$to = "you#youremail.com";
$subject = "New Email Address for Mailing List";
$headers = "From: $email\n";
$message = "A visitor to your site has sent the following email address to be added to your mailing list.\n
Email Address: $email";
$user = "$email";
$usersubject = "Thank You";
$userheaders = "From: you#youremailaddress.com\n";
$usermessage = "Thank you for subscribing to our mailing list.";
mail($to,$subject,$message,$headers);
mail($user,$usersubject,$usermessage,$userheaders);
?>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am writing a contact form for a website and am having trouble getting it to send the fields of my form on the actual e-mail.
The e-mails are sent and received successfully though.
Here is my HTML
<form action="mail.php" method="post" style="font-size:12px;">
<p>Name</p> <input type="text" name="name">
<p>Telephone</p><input type="text" name="phone" size="30" />
<p>Email</p> <input type="text" name="email">
<p>Message</p><textarea name="comments" rows="6" cols="25"></textarea><br />
<p>Best time to Contact You</p><input type="text" size="15" name="time" />
<input type="submit" value="Send"><input type="reset" value="Clear">
</form>
and my PHP
<?php
$to = "myemailaddress";
$subject = "New Website Enquiry";
$message = "You have recieved a new enquiry";
$from = $_POST['email'];
$name = $_POST['name'];
$message = $_POST['comments, phone, time'];
$headers = "From:" . $from;
$url = 'index.html';
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
mail($to,$subject,$message,$headers);
?>
You need to learn basic PHP syntax.
$message = $_POST['comments, phone, time'];
is outright wrong. You cannot specify multiply array keys in a comma-separated list like that, let along within a STRING. The code should be more like:
$message = $_POST['comments'] . $_POST['phone'] . $_POST['time'];
Note that what you have is NOT a php-level syntax error. You're using a perfectly acceptable array key, which simply happens to not exist.
I found an syntax error in your code:
Change
$message = $_POST['comments, phone, time'];
to
$message = $_POST['comments'] . . $_POST['phone'] . $_POST['time'];
What else do you have a problem with?
<?php
$to = "myemailaddress";
$subject = "New Website Enquiry";
$message = "You have recieved a new enquiry";
$from = $_POST['email'];
$name = $_POST['name'];
$headers = "From:" . $from;
$url = 'index.html';
echo '<META HTTP-EQUIV=Refresh CONTENT="0;URL='.$url.'">'; mail($to,$subject,$message,$headers);
?>