473,606 Members | 3,100 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*****@servern ame.com

My input form is as follows:
<form action="process 2.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:<textar ea 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($f rom);
$to = stripslashes($t o);
$subject = stripslashes($s ubject);
$message = stripslashes($m essage);
mail('$to',$fro m,$subject,$mes sage);
header("locatio n: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 1574
cover wrote:

<?php
@extract($_POST );
/* > $from = stripslashes($f rom); */
$from = stripslashes($f rom)."\r\n";
$to = stripslashes($t o);
$subject = stripslashes($s ubject);
$message = stripslashes($m essage);
/* > mail('$to',$fro m,$subject,$mes sage); */
mail($to,$subje ct,$message,$fr om);
header("locatio n:process.php") ;
?>
//Aho
Jan 24 '06 #2
On Tue, 24 Jan 2006 09:59:22 +0100, "J.O. Aho" <us**@example.n et>
wrote:

Did the trick - thanks :-)
<?php
@extract($_POS T);
/* > $from = stripslashes($f rom); */
$from = stripslashes($f rom)."\r\n";
$to = stripslashes($t o);
$subject = stripslashes($s ubject);
$message = stripslashes($m essage);
/* > mail('$to',$fro m,$subject,$mes sage); */
mail($to,$subj ect,$message,$f rom);
header("locati on:process.php" );
?>
//Aho

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

Did the trick - thanks :-)
<?php
@extract($_POST );
/* > $from = stripslashes($f rom); */
$from = stripslashes($f rom)."\r\n";
$to = stripslashes($t o);
$subject = stripslashes($s ubject);
$message = stripslashes($m essage);
/* > mail('$to',$fro m,$subject,$mes sage); */
mail($to,$subje ct,$message,$fr om);
header("locatio n:process.php") ;
?>


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

<http://securephp.damon kohler.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="process 2.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="process 3.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="process 2.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:<texta rea 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="process 2.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="process 3.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="process 2.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:<text area 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*******@attgl obal.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="process 2.php" method="post">
<form action="process 3.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:<textar ea 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*******@attg lobal.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="process 2.php" method="post">
<form action="process 3.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:<textar ea 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*******@attg lobal.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
2546
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 is possible for the employee to email the "form" he has completed to his supervisor, who in turn would approve or reject the dates requested, and email the "form" back to the employee. We would, of course, need some type of authentication...
2
1961
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. For example, Joe must take an annual CPR class, Bob needs to take his Hearing Test, Ann must take her Eye Exam. The task table keeps the completed date in it, while the form that displays it calculates the next due date (using dateadd). So, as...
5
7370
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 Run-time error. When I run it on an XP machine it crashes, but on an NT box it just generates an unknown error, handled by the error handler. I have debugged and stepped through the code and have narrowed the issue to the point at which the...
3
2358
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 email. Any ideas? Thanks in advance.
3
3028
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 App_Start handler to see if I could get emailed at all even from the first request of the app, but to no avail. Could someone please help me out? Thanks a lot! --Thiago Web developer AgniTEK
1
1142
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 once entered into the database would email me the results of the form. I found the tutorials on aspnet101.com (Emailing form results) and they really did not explain to well.
4
1588
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 query). The fields below are the ones I needed for the query. Then I created a form based on the query I created so that I can make use of a button that will prompt an event. That event will open Outlook and enter the emails from the form in the...
0
1144
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 have that capability built in, any suggestions for the VB script code that can grab that data and then put it into a email and prompt to send to an email address would be appreciated. If this isn't the appropriate forum for this question, let me...
20
1910
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 run. Now I have a number of tables in this database...looking like this: editorial editorialdate, editorialname, editorialcomments press
0
8036
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8461
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8448
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8317
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6796
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5470
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3948
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2454
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1313
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.