473,326 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Form data to email

I have following php file which I am placing as a form action,the coding seems right as i get all variables value when I echo the statements,but I dont know what happen to this,I am not getting this to email-id. Also my form tag is like
Expand|Select|Wrap|Line Numbers
  1.     <form action="enquiry.php" method="POST" name="form" id="form" onSubmit="return valid_form()" target="_self">
  2.  <input type="hidden" name="success_page" value="enquiry.html" />
  3. ................
  4. .............
  5. .......
  6. <input name="submit" value="Submit Enquiry" type="submit"
  7. </form>
Please help.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $nature=$_POST['nature'];
  3. $enquiry=$_POST['enquiry'];
  4. $quantity=$_POST['quantity'];
  5. $company=$_POST['company'];
  6. $name=$_POST['name'];
  7. $email=$_POST['email'];
  8. $phone_country_code=$_POST['phone_country_code'];
  9. $phone_area_code=$_POST['phone_area_code'];
  10. $phone=$_POST['phone'];
  11. $fax=$_POST['fax'];
  12. $addr=$_POST['addr'];
  13. $city=$_POST['city'];
  14. $code=$_POST['code'];
  15. $country=$_POST['country'];
  16.  
  17.  
  18. # Email to Form Owner
  19.  
  20. $emailSubject = "Online Enquiry";
  21.  
  22. $emailBody = "Nature of Business:$nature\n"
  23.  . "Requirement : $enquiry\n"
  24.  . "Quantity : $quantity\n"
  25.  . "Company name : $company\n"
  26.  . "Name : $name\n"
  27.  . "Email : $email\n"
  28.  . "Country Code : $phone_country_code\n"
  29.  . "Area Code : $phone_area_code\n"
  30.  . "Phone : $phone\n"
  31.  . "Fax : $fax\n"
  32.  . "Address : $addr\n"
  33.  . "City : $city\n"
  34.  . "Zip code : $code\n"
  35.  . "Country Name: $country\n"
  36.  . "";
  37.  
  38.  $emailTo ="user1@example.com";
  39.  $emailFrom="Enquiry";
  40.  $emailHeader = "From: $emailFrom\n"
  41.   . "MIME-Version: 1.0\n"
  42.   . "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
  43.   . "Content-transfer-encoding: 7bit\n";
  44.  
  45. mail($emailTo, $emailSubject, $emailBody, $emailHeader);
  46. header("Location: enquiry.html"); 
  47.  
  48.  //include("coupon.php");
  49. $successpage=$_POST{"success_page"};
  50. ?>
Jan 31 '10 #1
3 2101
realin
254 100+
What server are you using, are you trying to send email from localhost.
Just a note remove your email address from the above code. You might get lotsa spam emails.
Jan 31 '10 #2
kovik
1,044 Expert 1GB
The mail() function only works if the server knows what e-mail to send from and what SMTP server to use for sending. As ~realin suggested, if you are trying to do this from localhost, you likely haven't set up these variables. Otherwise, it's a matter of whether your host has set them up for you. I'd suggest using a more capable mailing library for PHP like SwiftMailer.
Jan 31 '10 #3
Dormilich
8,658 Expert Mod 8TB
The mail() function only works if the server knows what e-mail to send from and what SMTP server to use for sending.
that’s true for the windows implementation of mail(). the unix implementation uses the local sendmail programme.
Jan 31 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Du | last post by:
I'm trying to automate the upload process to yousendit.com, but the file size doesn't add up and yousendit.com keep rejecting my upload (it accepts the upload until the very end) I don't know...
0
by: pd123 | last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error " The name 'Peter' is...
13
by: deko | last post by:
I have a basic feedback form with a submit button. After the "send" button is clicked, I want the user to be redirected to a different page that says "Your message has been sent." How do I do...
7
by: h7qvnk7q001 | last post by:
I'm trying to implement a simple server-side form validation (No Javascript). If the user submits a form with errors, I want to redisplay the same form with the errors highlighted. Once the form...
2
by: FayeC | last post by:
Can anybody point me to a good tutorial/manual on advanced server-side form validation including validation of fields against unwanted strings such as the use of "http://". Thank you in advance,...
6
by: Boldgeek | last post by:
I am trying to develop an app that will allow automatic updating of a web form which uses multipart/form-data enctype (as it MIGHT be sending an image) I have an example form, which when...
1
by: fugaki | last post by:
Hi everyone I'm learning asp, and i downloaded this script to teach me how to post form data from a webpage to an access database. I put it on the server so i could make sure that it worked, and...
7
by: Dave Kelly | last post by:
There has to be a name for what I want to do and I don't know what words to google for. I have a form here: http://www.texasflyfishers.org/firstpage.htm I want to submit it to the server and...
1
by: ColebyA | last post by:
Hi I am using ASP and HTML to process a form. The first form calls another page to process the data. When the page processes it redirects to a page confirming submission. I want to display the...
1
by: chromis | last post by:
Hi, I'm having trouble fully implementing the edit section of a contact admin system, so far I have written the following: - Bean (Contact.cfc) - Data Access object (ContactDAO.cfc) - Gateway...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.