473,395 Members | 1,377 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,395 software developers and data experts.

send data form to an e-mail!!

hello,
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
thanx.
Sep 24 '06 #1
13 3892
ronverdonk
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.
[PHP]
<?php
// 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
}
?>
[/PHP]
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
ronverdonk
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
heay,
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
moishy
104 100+
I use www.FormToEmail.com.
Oct 5 '06 #9
ronverdonk
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.
[PHP]<?php
// 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';
else
echo 'Error in mail function';
?>[/PHP]

Ronald :cool:
Oct 5 '06 #10
hello,
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
ronverdonk
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.
[PHP]<?php
$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';
else
echo 'Message sent';
?>[/PHP]

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
ronverdonk
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

2
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...
10
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...
0
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...
2
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?
1
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
3
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...
5
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...
1
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...
5
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....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.