473,511 Members | 16,110 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Emailing Form Data

I have a form that writes to an MySQL database just fine but would
like to email people to give them a heads up that an entry was made
under their name (1 of 6 names on writing to the database). This
server exists on an intranet and would have no 'web' function other
than using possibly the existing email server.

Is all that I need to do to make this happen, to change php.ini as
follows:

[mail function]
; For Win32 only.
SMTP = mail.servername.com
smtp_port = 25

; For Win32 only.
;sendmail_from = wh*****@servername.com

My input form is as follows:
<form action="process2.php" method="post">
From: <input type="text" name="from" size="20" maxlength="20" /><br />
To: <input type="text" name="to" size="30" maxlength="30" /><br />
Subject: <input type="text" name="subject" size="30" maxlength="30"
/><br />
Message:<textarea name="text" name="message" cols="50"
rows="10"></textarea><br />
<input type="submit" name="submit" value="Send" />
</form>

and passes data to process2.php as shown in form 1:
<?php
@extract($_POST);
$from = stripslashes($from);
$to = stripslashes($to);
$subject = stripslashes($subject);
$message = stripslashes($message);
mail('$to',$from,$subject,$message);
header("location:process.php");
?>

This worked through my testbed on my SMTP 'once' and only sort of,
once so I might be missing something. :-) TIA for any help.
Jan 24 '06 #1
7 1569
cover wrote:

<?php
@extract($_POST);
/* > $from = stripslashes($from); */
$from = stripslashes($from)."\r\n";
$to = stripslashes($to);
$subject = stripslashes($subject);
$message = stripslashes($message);
/* > mail('$to',$from,$subject,$message); */
mail($to,$subject,$message,$from);
header("location:process.php");
?>
//Aho
Jan 24 '06 #2
On Tue, 24 Jan 2006 09:59:22 +0100, "J.O. Aho" <us**@example.net>
wrote:

Did the trick - thanks :-)
<?php
@extract($_POST);
/* > $from = stripslashes($from); */
$from = stripslashes($from)."\r\n";
$to = stripslashes($to);
$subject = stripslashes($subject);
$message = stripslashes($message);
/* > mail('$to',$from,$subject,$message); */
mail($to,$subject,$message,$from);
header("location:process.php");
?>
//Aho

Jan 24 '06 #3
cover wrote:
On Tue, 24 Jan 2006 09:59:22 +0100, "J.O. Aho" <us**@example.net>
wrote:

Did the trick - thanks :-)
<?php
@extract($_POST);
/* > $from = stripslashes($from); */
$from = stripslashes($from)."\r\n";
$to = stripslashes($to);
$subject = stripslashes($subject);
$message = stripslashes($message);
/* > mail('$to',$from,$subject,$message); */
mail($to,$subject,$message,$from);
header("location:process.php");
?>


Before you rest on your laurels, please read up on email header injection.
Your script is a potential spam factory.

<http://securephp.damonkohler.com/index.php/Email_Injection>

You might also want to replace "\r\n" with "\n" in the additional headers. I
know this isn't what it says in the RFCs, but it's the de facto standard now.
If you put carriage returns into the header of an email, it's more likely to
be flagged as spam.

--
philronan [@] blueyonder [dot] co [dot] uk

Jan 24 '06 #4
A follow up question:

Writing values to the db with the MySQL query INSERT INTO code doesn't
like sharing with the code that initiates the email so, is it common
practice to initiate TWO actions from the input form shown below? i.e.
to use <form action="process2.php" method="post"> twice in a row on
the input form? Once for example to initiate INSERT INTO the database
and the second <form action="process3.php" method="post"> right below
it to initiate the email code on process3.php? Seems like a pretty
clean way of dealing with it, thoughts anyone? Otherwise I need to
figure out how to do the INSERT INTO and then continue on to
initiating the email code. Thanks very much.

On Mon, 23 Jan 2006 20:54:34 -0800, cover
<co****************@yahoo.com> wrote:

My input form is as follows:
<form action="process2.php" method="post">
From: <input type="text" name="from" size="20" maxlength="20" /><br />
To: <input type="text" name="to" size="30" maxlength="30" /><br />
Subject: <input type="text" name="subject" size="30" maxlength="30"
/><br />
Message:<textarea name="text" name="message" cols="50"
rows="10"></textarea><br />
<input type="submit" name="submit" value="Send" />
</form>

Jan 25 '06 #5
cover wrote:
A follow up question:

Writing values to the db with the MySQL query INSERT INTO code doesn't
like sharing with the code that initiates the email so, is it common
practice to initiate TWO actions from the input form shown below? i.e.
to use <form action="process2.php" method="post"> twice in a row on
the input form? Once for example to initiate INSERT INTO the database
and the second <form action="process3.php" method="post"> right below
it to initiate the email code on process3.php? Seems like a pretty
clean way of dealing with it, thoughts anyone? Otherwise I need to
figure out how to do the INSERT INTO and then continue on to
initiating the email code. Thanks very much.

On Mon, 23 Jan 2006 20:54:34 -0800, cover
<co****************@yahoo.com> wrote:
My input form is as follows:
<form action="process2.php" method="post">
From: <input type="text" name="from" size="20" maxlength="20" /><br />
To: <input type="text" name="to" size="30" maxlength="30" /><br />
Subject: <input type="text" name="subject" size="30" maxlength="30"
/><br />
Message:<textarea name="text" name="message" cols="50"
rows="10"></textarea><br />
<input type="submit" name="submit" value="Send" />
</form>


Rather, I'd look into what problem you're having with both sending the
email and inserting into the database. It should work OK.

Having two different forms means the user would have to click on two
buttons in order. What if he only clicks on one of them?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jan 25 '06 #6
Actually what I'm wanting to do is input the data into a MySQL
database (which I have done successfully) and also email data off that
form through a mail server at the same time (which I have done
successfully separately - in other words, I haven't achieved both
results off a single click of the 'submit' button). BUT...

Shouldn't doing a form action / method="post" twice in the same form
send the info in both directions as below?

<form action="process2.php" method="post">
<form action="process3.php" method="post">
From: <input type="text" name="from" size="20" maxlength="20" /><br />
To: <input type="text" name="to" size="30" maxlength="30" /><br />
Subject: <input type="text" name="subject" size="30" maxlength="30"
/><br />
Message:<textarea name="text" name="message" cols="50"
rows="10"></textarea><br />
<input type="submit" name="submit" value="Send" />
</form>

Also in taking the model to work, I discovered severe security over
the email system so I'm looking to set up an SMTP mail server onto the
server I've been working with - the work one will accept from this one
if I can get it going. Am using Apache on a Windows server. Thanks
for the reply Jerry...

Chris
On Wed, 25 Jan 2006 12:47:09 -0500, Jerry Stuckle
<js*******@attglobal.net> wrote:

Rather, I'd look into what problem you're having with both sending the
email and inserting into the database. It should work OK.

Having two different forms means the user would have to click on two
buttons in order. What if he only clicks on one of them?

Jan 26 '06 #7
cover wrote:
Actually what I'm wanting to do is input the data into a MySQL
database (which I have done successfully) and also email data off that
form through a mail server at the same time (which I have done
successfully separately - in other words, I haven't achieved both
results off a single click of the 'submit' button). BUT...

Shouldn't doing a form action / method="post" twice in the same form
send the info in both directions as below?

<form action="process2.php" method="post">
<form action="process3.php" method="post">
From: <input type="text" name="from" size="20" maxlength="20" /><br />
To: <input type="text" name="to" size="30" maxlength="30" /><br />
Subject: <input type="text" name="subject" size="30" maxlength="30"
/><br />
Message:<textarea name="text" name="message" cols="50"
rows="10"></textarea><br />
<input type="submit" name="submit" value="Send" />
</form>

Nope, it will only send it to one page.
There should be no problem doing an insert and then mailing the data.
Post your code so we can have a look at wots up.

cheers
Barry
Also in taking the model to work, I discovered severe security over
the email system so I'm looking to set up an SMTP mail server onto the
server I've been working with - the work one will accept from this one
if I can get it going. Am using Apache on a Windows server. Thanks
for the reply Jerry...

Chris
On Wed, 25 Jan 2006 12:47:09 -0500, Jerry Stuckle
<js*******@attglobal.net> wrote:

Rather, I'd look into what problem you're having with both sending the
email and inserting into the database. It should work OK.

Having two different forms means the user would have to click on two
buttons in order. What if he only clicks on one of them?

Jan 26 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2538
by: jdph40 | last post by:
I developed a small database for my supervisor that tracks the dates employees wish to schedule for vacation, how many days they are eligible for, how many they have taken, etc. He asked me if it...
2
1957
by: Chuck | last post by:
I have a database that has a table in it with employee information (name, dob, email, etc). This is joined to a table that has tasks that are assigned to each individual that has a recurring date....
5
7363
by: Colin Anderson | last post by:
I discovered, with great excitement, this article http://www.davison.uk.net/vb2notes.asp when researching methods for emailing from Access via Notes. Unfortunatly, when I run this I get a...
3
2340
by: Strasser | last post by:
In Access2000 mass emailing worked perfectly (very powerful tool!). Doesn't work when using XP version of both Access and Outlook, even though I checked the box to ensure that I was sending the...
3
3019
by: tafs7 | last post by:
My code below is supposed to email me when an error occurs on the application, but it's not emailing anything. Am I missing something? I know the smtp servers I've tried work. I even added a...
1
1138
by: dman | last post by:
Hi, I am a total newbie to asp.net. I have spent the last week or so trying to find a good tutorial that would show me how to create a form that would be entered into a SQL database and then...
4
1583
by: BernardNem via AccessMonster.com | last post by:
Hi, I am trying to work on an employee database. The tables and fields that I am working on are listed below. I created a query because I wanted to separate the employees by department (selected...
0
1137
by: rarkin | last post by:
I'd like to find out the best way to have a customized Outlook Contact form be programmed to email a summary of all the Contact fields data to someone's email address. If the Contact form doesn't...
20
1895
by: paul814 | last post by:
I've been working on this for some time now and have gotten nowhere...hoping someone here can help. I want to take and email all records in a database for the current date when this php page is...
0
7242
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
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7353
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7075
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
7508
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...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.