I'm using Ajax contact form where my contactform.php is something like this :
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$subject = "Contact Form";
$message .= $_POST['name'] . "\n\r";
$message .= $_POST['email'] . "\n\r";
$message .= $_POST['message'];
mail("your#domain.com", $subject, $message, "From: ".$email);
?>
This form script works perfect But My problem is that, My value for "your#domain.com" is dynamic.. So I modified contactform.php to this :
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$emailto = $qc2_options['qc2_form_heading'];
$subject = "Contact Form";
$message .= $_POST['name'] . "\n\r";
$message .= $_POST['email'] . "\n\r";
$message .= $_POST['message'];
mail($emailto, $subject, $message, "From: ".$email);
?>
But this modified script isn't working.. I do get correct value for $qc2_options['qc2_form_heading']; on echo But this form dosn't work.
Where I'm going wrong ?
Related
Error:
the code:
<?php
$name = $_POST['name'];
$mail = $_POST['mail'];
$message = $_POST['message'];
$to ="bejidev27#gmail.com";
$subject = "New contact from " .$name;
$body = "";
$body .= "Name : " .$name. "\r\n";
$body .= "Email : " .$mail. "\r\n";
$body .= $message. "\r\n";
if($mail !=NULL){
mail($to, $subject, $body);
header("Location: index.html") ;
header("Location: done.html") ;
}
?>
It's not sending the mail nor the page is working i need help ,thanks in advance :D
First, check if your servers are running properly. Then, for the following
$name = $_POST['name'];
$mail = $_POST['mail'];
$message = $_POST['message'];
There need to be values for each you. If you are getting the values from a form, then you have to handle the form first using the 'isset' function, to be able to pass the values to each variables.
I have a fully working form that sends emails on submit, I would like to have some kind of alert if the email is sent successfully. I saw a lot of solutions with jquery or other libraries but I wanna do it with php
<?php
if(isset($_POST['name']) && $_POST['email'] !='') {
$userName = $_POST['name'];
$lastName = $_POST['surname'];
$email = $_POST['email'];
$phoneNumber = $_POST['phonenumber'];
$messageSubject =$_POST['subject'];
$catalog =$_POST['select_catalog'];
$inputsValue =$_POST['radioSet1'];
$inputsValue2 =$_POST['radioSet2'];
$inputsValue3 =$_POST['radioSet3'];
$inputsValue4 =$_POST['radioSet4'];
$to = "levchegochev#gmail.com";
$body = "";
$body = "Akademija Za dizajn"."\r\n";
$body .= "Ime: ".$userName. "\r\n";
$body .= "Prezime: ".$lastName. "\r\n";
$body .= "Email: ".$email. "\r\n";
$body .= "Telefonski broj:".$phoneNumber."\r\n";
$body .= "Nacin na plakanje: ".$catalog. "\r\n";
$body .= "Opcii: ".$inputsValue. "\r\n".$inputsValue2. "\r\n" .$inputsValue3. "\r\n" .$inputsValue4."\r\n";
mail($to,$messageSubject, $body);
if(mail = true ) {
echo 'test'
}
}
?>
You can write:
if(mail == true ) {
echo '<script>alert("Email send!");</script>';
}
you can try this
if(mail) echo '<script>alert("message")</script>';
I want to add "This message came from etcetc.com" in the e-mail form in the e-mail body itself. Hope this make sense..
my sent_email.php
<?php
$email_to = 'test#test.org';
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers = 'From: ' . $name . ' <' . $email . '>' . "\r\n" . 'Reply-To: ' . $email;
if(mail($email_to, $subject, $message, $headers)) {
echo 'sent'; // we are sending this text to the ajax request telling it that the mail is sent..
} else {
echo 'failed'; // ... or this one to tell it that it wasn't sent
}
?>
Like this:
<?php
$email_to = 'test#test.org';
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = "This message came from etcetc.com \r\n".$_POST['message'];
$headers = 'From: ' . $name . ' <' . $email . '>' . "\r\n" . 'Reply-To: ' . $email;
if(mail($email_to, $subject, $message, $headers)) {
echo 'sent'; // we are sending this text to the ajax request telling it that the mail is sent..
} else {
echo 'failed'; // ... or this one to tell it that it wasn't sent
}
?>
All you need to do is add your text to the end of $message.
Change:
$message = $_POST['message'];
to
$message = $_POST['message'] . "\n\nThis message came from etcetc.com";
Add message before and after as you wish by
$message = "This is before posted message\r\n";
$message .= $_POST["message"];
$message .= "\r\nthis is after the posted message";
I have created a contact form and I would like for the details be sent to my inbox once the submit button is clicked. Clicking the submit button opens up a new mail page (see getfreepack.org). I have been advised I need a PHP script. I copied one off the web but no too sure how to use it to my advantage. I would appreciate your help.
$Name= $_REQUEST["Name"];
$Email = $_REQUEST["Email"];
$Phone = $_REQUEST["Phone"];
$JobTitle = $_REQUEST["Jobtitle"];
$KeySkills = $_REQUEST["Keyskills"];
$Attachment = $_REQUEST["Attachment"];
$to = "my email address#mail.com";
$subject = "Contact Form";
$message = "Name: " . $Name $message .= "\Email: " . $Email: $message .= "\n Phone: " . $ Phone;
$message .= "\nSubject: " . $Subject; $message .= "\nCover Letter: " . $CoverLetter;
$message .= "\n Attachment: " . $Attachment; $message .= "\nIP Adress: " . $_SERVER['REMOTE_ADDR'];
$message .= "\nBrowser: " . $_SERVER['HTTP_USER_AGENT'];
$message .= "\n\nMessage: " . $theMessage;
$headers = "From: $theEmail";
$headers .= "\nReply-To: $theEmail";
$sentOk = mail($to,$subject,$message,$headers);
echo "sentOk=" . $sentOk;
A very basic one would be :
<?php
$to = "someone#example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse#example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
If you want to go one step more check out the manual : http://php.net/manual/en/function.mail.php
Cheers
You don't need the php to get a form to send to your email address make the form tag like this:
>>action="mailto:youremailaddress#whatever.com">
Input
Input
Im creating a contact form for my website using Actionscript 3.0 with Flash CS6, I have my code written down perfectly but in order to receive my messages towards my email ain't working :( Here is my code
<?php
$emailTo = "myemail#myemail.com";
$name = $_POST["Patrick"];
$emailFrom = $_POST["myemail#myemail.com"];
$message = $_POST["Hello"];
$subject = "From Contact Form";
if(!empty($_POST)) {
$body = "Name: " . $name . "\n\n";
$body .= "Email: " . $emailFrom . "\n\n";
$body .= "Message:\n" . $message;
$body = wordwrap($body, 70);
$header = "From: " . $emailFrom . "\nReply-To: " . $emailFrom. "\n\n";
if(mail($emailTo, $subject, $body, $header)) {
echo("result=Successful");
} else {
echo("result=Unsuccessful");
}
}
?>
Thanks and hope I you guys can help me
I think the problem lies in how you try to retrieve the $_POST variables.
You're code suggests that you post fields with the names Patrick, myemail#myemail.com and Hello. That wouldn't be logical.
So I guess that your code should be something like the following:
$emailTo = "myemail#myemail.com";
$name = $_POST["name"];
$emailFrom = $_POST["emailFrom"];
$message = $_POST["message"];
$subject = "From Contact Form";
Or for testing purposes (just to see if your mail script is working):
$emailTo = "myemail#myemail.com";
$name = "Patrick";
$emailFrom = "myemail#myemail.com";
$message = "Hello";
$subject = "From Contact Form";