472,967 Members | 2,021 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

send data form to an e-mail!!

i want to know how to send a form data to a mail
that form ,the user enters its data and when pressing submit it sends that data to a mail
Sep 24 '06 #1
13 3867
4,258 Expert 4TB
Question now is: do you want to send just the entered data or do you want to send html to your user? Remember that some users (like myself) don't like html in their emails, so I'll just assume that you want to send text.

Next question is: do you have mail configured in your php.ini file? This is a different definition for Windows and Unix, so you'll have to know that before you start.

Having all that, you can simply create and send an email message using php's mail function (there are plenty of mailo classes around on the net, but I assume you want to use simple php for this).
The following code will show you how to accomplish this. For a more detailed explanation on the mail() function see the php documentation at PHP mail reference and mail() function

The following code shows a simple email script.
// email address of the adressee
$To = 'JohynDoe@hisnet.com';
// email address of the sender
$From = 'MyId@mynet.com';
// the subject of your message
$Subject = 'This is the subject text';
// the text of the message
$Message = 'Here comes the message text for the mail';
// send the mail
if (mail($To, $Subject, $Message, "From: $From")) {
echo 'Mail sent successfully';
// whatever else you want to do here
else {
echo 'Error when sending mail';
// whatever else you want to do now
Ronald :cool:
Sep 25 '06 #2
thanx vry much 4 that replay

but i wanna to tell u that this form contains text items that the user enters data
in it, i wanna when pressing submit send these information to the mail for example info@comp.net
Sep 25 '06 #3
Could you please put the contents of your form here and maybe the structure in which you want your e-mail to look like.
Sep 26 '06 #4
firstly thanx for the script
it is working
but i want to send
$message in a spicific format
how to do that??
when i make "<br>" to print new line it appears as html in the sent message
plz i need that urgently
Oct 1 '06 #5
4,258 Expert 4TB
The mail fields should not contain <br> because that is html, and you want to send plain text.
Insert a newline at the place you want to break the text into a new line, as follows (remember to put the \n within double quotes, otherwise it will generate a separate backslash and a separate 'n'):
[PHP]$message = "This is my first text line.\nAnd this is the second.";[/PHP]
Ronald :cool:
Oct 1 '06 #6
firstly thanx for help,

i want to make the mail function sends html code
how t let it support that??
i looked at the php manual but the function used don't work
i want to let the
$Message=<a href="http://site.com">The Site</a>

but it prints the html code too not just the "The Site"

thanx in advance
Oct 3 '06 #7
when i looked at the php manual i found that headers that enabled the html code
but i face error
Warning: mail(): SMTP server response: 501 Syntax error in parameters or arguments
that is the headers i used
[PHP]$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";[/PHP]
Oct 3 '06 #8
104 100+
I use www.FormToEmail.com.
Oct 5 '06 #9
4,258 Expert 4TB
The To: field is not to be stored in the headers. Why don't you see if the following very simple example (without any special headers but inclding a link reference ) works for you. It does for me. And then build it up.
// send simple mail text with link
$to = "you@yoursite.nl";
$subject = "test example";
$message = "This is my text example.\n
Test of second line.\n
Click on http://wwww.MySite.com to notify me.";
$headers = "From: me@mysite.nl";

if (mail($to, $subject, $message, $headers))
echo 'Mail sent';
echo 'Error in mail function';

Ronald :cool:
Oct 5 '06 #10
thanx ronald but i need to enable html code
as i said b4 there was error!!!!!!!!!!

how to handle that error
Oct 7 '06 #11
4,258 Expert 4TB
Sorry I misunderstood. The following sample works for me. Try it out and when it works for you, add your extra addresses etc.
$headers = "MIME-Version: 1.0\n" .
"Content-Transfer-Encoding: 8bit\n" .
"Content-type: text/html; charset='iso-8859-1'\n" .
"From: MySite@mycom.com";
$to = "you@yoursite.com";
$subj = "Here is your html";
$body = "hi <b>my friend</b>! \n\n this message uses <i>html entities</i> !";
if (!mail($to, $subj, $body, $headers))
echo 'Error';
echo 'Message sent';

Ronald :cool:
Oct 7 '06 #12
I use www.FormToEmail.com.
Thank you

I think www.FormtoEmail.com is simple to use.

Thank you very much for the recommendation. Do you have any other recommendations for forms? I need a form to collect data from the user like first name, address and email. Are you able to help?

Thank you
Oct 29 '06 #13
4,258 Expert 4TB
Well, you can copy the recommended code and adapt it to your needs. It is not that difficult for a programmer to just add a couple of more text fields to that form.

Also, there is another free PHP form and email script. Look at Charles Reace's site for the source at PHP Email Contact Form

Ronald :cool:
Oct 29 '06 #14

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

Similar topics

by: Fatih BOY | last post by:
Hi, I want to send a report from a windows application to a web page like 'report.asp' Currently i can send it via post method with a context like local=En&Username=fatih&UserId=45&Firm=none...
by: Jim H | last post by:
I have a UDP socket that sends out a request on a multicast socket and waits for a response. This client is not listening on a multicast IP but the local IP. The server (UNIX) responds to the...
by: Dave S | last post by:
I have a lot of forms on our web site that require the user to fill out information and submit it back to us. currently the information comes back as name value pair. The our employee's then has to...
by: John Doe | last post by:
I've written many pages that emails the content of a web form, but the data formatted very nicely. Is there a way to have the content of the submitted form data via email in XML?
by: olersquared | last post by:
Hello ! Please i need a php script that can collect and send data to a specified email address using textfield and radio button and anyother form field. thank you
by: YMPN | last post by:
Hi Everyone, I'm deen from Riyadh. Please do help me with some problem i have. I have this formview control setup to recieved inputs from user (textbox, dropdownlist, others). After...
by: trig | last post by:
Please help! I am an ICT teacher at a secondary school and my year 12 (AS Level) group need to create a website where data can be sent from a form to a Microsoft Access database. I am trying...
by: steinwaygirl | last post by:
Hi all, I have been searching so hard for the answer to this, hopefully some of you all can help. I have created an HTML file with various forms - also included CSS and some javascript for...
by: ssmeshack85 | last post by:
Hai there, Im newbie here. Im creating a form that can be send it data to email when click submit. Im using C# as programming language. Check wheter the coding that I keyin. Here is the coding....
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.