Forums

PHP

This topic is locked

form to email and mysql

Posted 18 Nov 2002 00:14:54
1
has voted
18 Nov 2002 00:14:54 Adam Davies posted:
Hi i've found plenty of tutorials of using php to send email from a form and obviously writing from a form to a mysql database, but nothing on writing to mysql and then emailing the results as well. any help please as im doing a user registration page and want to keep the details on the database but send the details via email to an admin as well.

Replies

Replied 18 Nov 2002 11:56:01
18 Nov 2002 11:56:01 Michael O'Neill replied:
Hi, do you want to mail the admin all the reg details, or just notification that someone has registered?

Mike.
Replied 18 Nov 2002 13:29:20
18 Nov 2002 13:29:20 Aurel Sorin Cirstoiu replied:
Hello,

You can do this and many other things using ImpAKT 2(commercial product) extension for PHP.
More informations about it:

www.interakt.ro/products/ImpAKT/index.php

-----------------------
Cirstoiu Aurel Sorin
InterAKT Support
www.interakt.ro
-----------------------
Replied 18 Nov 2002 15:08:15
18 Nov 2002 15:08:15 Adam Davies replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi, do you want to mail the admin all the reg details, or just notification that someone has registered?

Mike.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

All details, i just want it in the database so it's handy and if I want to do something later with it, it will already be in the database

Replied 18 Nov 2002 15:10:24
18 Nov 2002 15:10:24 Adam Davies replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hello,

You can do this and many other things using ImpAKT 2(commercial product) extension for PHP.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I would use it but im using tim greens ultracart for dmx which won't work with impakt, I could develop the e-commerce section using impakt but im so far ahead in development now it wouldn't be feasible.

Replied 19 Nov 2002 00:22:19
19 Nov 2002 00:22:19 Tim Green replied:
If you want to email all the contents of a form to an admin email address, then it isn't difficult. Cirstoiu's recommendation, while valid perhaps, is not really helpful.

In your form, insert a hidden field called 'formSeen' and set it's value to true... then create a PHP Code block towards the top of your document, and use the following code:-

if (phpversion() &gt; "4.0.6" {
$HTTP_POST_VARS = &$_POST;
}
if (isset($HTTP_POST_VARS\["formSeen"\])) { // note: remove the \ characters on this line.
// create the mail information
$to = " ";
$subject = "Registration Info";
$from = "From: MySite Registration System\r\n";
$body = "The following information was submitted:-\n\n";
while (list($key,$value) == each($HTTP_POST_VARS)) {
$body.= $key . " = " . $value . "\n";
}

// now send the mail
mail($to,$subject,$body,$from);

// then redirect to another page
header("Location: registrationSent.php";
}

This will send a plain text email containing the form information to Hopefully this is what you were wanting <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>

NB: The \ characters on the line in the code with the square brackets, are there simply to stop the forum from messing about with the code. Please ensure they are removed prior to using the code.

I hope it helps

All the best,

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>

Edited by - rawveg on 19 Nov 2002 00:28:11
Replied 19 Nov 2002 02:32:32
19 Nov 2002 02:32:32 Adam Davies replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
If you want to email all the contents of a form to an admin email address, then it isn't difficult. Cirstoiu's recommendation, while valid perhaps, is not really helpful.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Cheers Tim, does your advanced php for DMX book cover this sort of stuff, I've already got the first one but it didn't answer a lot of questions I had but it was great to get started.

Replied 19 Nov 2002 03:28:19
19 Nov 2002 03:28:19 Tim Green replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Cheers Tim, does your advanced php for DMX book cover this sort of stuff, I've already got the first one but it didn't answer a lot of questions I had but it was great to get started.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Glad you liked the first book! Dreamweaver MX: Advanced PHP Web Development has a dedicated chapter on email within PHP and it's use. While this particular scenario isn't covered, you will get a better idea of how to use email within PHP, and there are also a few little-used methods so that you can create perfectly formatted emails with ease <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>



Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 20 Nov 2002 11:35:39
20 Nov 2002 11:35:39 Adam Davies replied:
Hi Tim,
it worked fine thanks, I did have to remove a = from "while (list($key,$value) == each($HTTP_POST_VARS)) {" for it to work though as it through up an error otherwise.

But it's working perfectly now, much appreciated.

Replied 29 Mar 2007 19:56:18
29 Mar 2007 19:56:18 Dan O replied:
Mr. Green

You seem to be a nice person. This subject touches base with what I need. I am a newbie when it comes to php and functionality. I am more of a designer. I get a lot of this type of request.

My situation is this: I am setting up a form and would like it sent via e-mail. I am not really sure if I need to go the SQL route. With the codes above, could I just have form information sent via email only using code with-in that html document?

If I can what would I need to set my fields to-be here\\ &lt;form action="?" method="?" name="?"&gt;
& for my button, will this work? \\ &lt;input name="submit" type="button" value="SUBMIT"&gt;
Also do I need to put your script in-between this to make it work \\ &lt;script language="php"&gt; (your script) &lt;/script&gt;

I know people get paid to do this, but if there is a fairly simple way to do this w/o going into SQL and all that, I would be indebt to you Mr.Green. I appreciate any response at all. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Edited by - C70.HEEB on 29 Mar 2007 19:59:39

Edited by - C70.HEEB on 29 Mar 2007 20:04:12

Reply to this topic