Jump to content

Recommended Posts

Posted (edited)

Greetings and salivations, um - salutations? Yea - that's it. :oops:

 

I have a basic form on a site that uses php to put the info into a mysql table. Form gets filled out, click to submit ( <form .... method="post" action="/dothis.php" onsubmit="return checkform(this) && checkCheckBoxes(this) && isValid();"...etc> )and no further action is required on the users part. The info reappears on the thankyou page and the info goes into database for display elsewhere. I know - nothing new here.

 

Or here, but my question : is there an easy method to get an email sent to me when that form is submitted? (I'm having one of those "I know I've seen it somewhere.." moments...)

 

 

Thanks

 

[edit] I should say easy and safe method

Edited by boxturt
Posted

Since the info is sent to a thank you page

why not use php mail() to send the info to yourself just before going to the thank you page

 

<?php

mail($myemail, $subject, $message, $from);

?>

 

You can set $message equal to all the data you need to see.

Posted

Thanks Don

 

You can set $message equal to all the data you need to see.

 

I'm having trouble making this work. Defining $message that is. I tried putting everything in here first (predefining $myemail and $subject earlier) :

><?php
mail($myemail, $subject, $first_name, $last_name, $phone, $email);
?>

 

but it ceased to work after adding the 5th ($last_name) element. I tried predefining $message as an array also (which is probably just wrong anyway :shocking: ) and that didn't work either.

 

I shuld mention though that it does indeed work up to that point. :)

Posted

No you need to keep the format

<?php

mail($myemail, $subject, $message, $from);

?>

 

 

So try this using Heredoc to build the $message

><?php
$myemail ="me@mysite";
$subject = "new database entry";

$message = <<< EOF
New entry to database
Name: $first_name  $last_name 
Phone: $phone 
email: $email
EOF;

$from = "From: $email\r\n";

// send mail
mail($myemail, $subject, $message, $from);
?>

Posted

Thanks - I'll try that. This is sooooo close to what I kept calling "predefining". This is page 74 of my O'Reilly's too. Sitting right here next to me and I didn't find it. Durr :shocking:

 

Thanks for the suggestion Steve, I'm not sure UFM would work for this but I may end up revisiting the option. (I think only the paid version writes to database, not sure)

Posted

You're welcome - thank you!! I'm glad he's giving it a try :shocking:

 

BTW - the ' HEREDOC ' did the trick, thank you. I like php and I know I'll be better at it once I learn what things are called!!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...