Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

<?php mail.. position question

Engaged ,
Mar 22, 2007 Mar 22, 2007
Fairly standard question that I have noticed lots of .asp comments on forum.

I have a registration form that inserts a record and then re-directs to a register success page.

I also want the registersuccess page (or alternatively form page) to automatically send an e-mail to me, including certain information entered into the form fields - namely the unique identifier (email address). This I can set as a hyperlink to allow me to connect directly to that record on-line.

I've sussed that this is the line I want to use in the registersuccess page:

<?php mail ("me@work.co.uk", "There is a new Site Registration", $email);?>

Call me stupid but I cannot work out how to propogate "$email" from a form field variable in the previous page if no information is being passed from the previous page.

I have tried to include ?EMAIL=<?php echo $POST_VARS['emailtextfield'];?> into the redirection address when the form is submitted but I get an error.

I am now trying to find out where I can put my "mail" code in the first form page but am having great difficulty as it is now complicated by form checks and duplicate checks.

Can anyone help?
TOPICS
Server side applications
356
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 22, 2007 Mar 22, 2007
On 22 Mar 2007 in macromedia.dreamweaver.appdev, RichardODreamweaver
wrote:

> I am now trying to find out where I can put my "mail" code in the
> first form page but am having great difficulty as it is now
> complicated by form checks and duplicate checks.

In the script which processes the form (<form method="POST"
action="thisisthefileyouwant.php">), find where the insert behavior
ends. Just after that, you put your code to send the email to you.
The visitor's entered email will still be ...
Translate
LEGEND ,
Mar 22, 2007 Mar 22, 2007
On 22 Mar 2007 in macromedia.dreamweaver.appdev, RichardODreamweaver
wrote:

> I am now trying to find out where I can put my "mail" code in the
> first form page but am having great difficulty as it is now
> complicated by form checks and duplicate checks.

In the script which processes the form (<form method="POST"
action="thisisthefileyouwant.php">), find where the insert behavior
ends. Just after that, you put your code to send the email to you.
The visitor's entered email will still be in $_POST['emailFieldName'].
So:

<?php
// ...
// Code to insert data ends here
$to = 'me@example.com';
$subject = 'Record inserted';
$body = 'This record was inserted: EMail: ' . $_POST['emailFieldName'];

mail($to, $subject, $body);
?>

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/contact.php
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 26, 2007 Mar 26, 2007
Thanks Joe

I put it as you can see below and it seems to work but DW has a funny and says that the insert behaviour was partially deleted! The insert behaviour in the behaviour panel has now also dissapeared.

Is the position correct?

.........
$insertGoTo = "/regsuccess.php";

$BODY= 'This record was inserted -EMail: ' . $HTTP_POST_VARS['textfieldemail'];
mail ("me@work.co.uk", "There is a new Site Registration", $BODY);

if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));

etc. etc....
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 26, 2007 Mar 26, 2007
LATEST
On 26 Mar 2007 in macromedia.dreamweaver.appdev, RichardODreamweaver
wrote:

> I put it as you can see below and it seems to work but DW has a
> funny and says that the insert behaviour was partially deleted! The
> insert behaviour in the behaviour panel has now also dissapeared.

DW gets funny about you playing with its behaviors. If it works, go with
it. Understand, though, that from now on, you're stuck editing the
insert behavior by hand.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/contact.php
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines