email confirmation after submit

good morning,
I am trying to add an email notification ( to myself ) after user has submitted an image to our db.

have tried several of the scripts and snippets found when googling, none of them seem to work for me.

the submit.php I’m using is as follows:

<?php include("header.php");?>

Submit Images

Category

--Select a Category-- <?php $submitcat = $mysqli->query("SELECT id, c_name FROM categories ORDER BY c_name ASC"); while ($subcat = mysqli_fetch_array ($submitcat)){

?>

<?php echo $subcat['c_name'];?> <?php } ?>

Image File

Your Email address

Submit

<?php include("footer.php");?>

any help would be greatly appreciated …

Well, your submit code is JQuery, not PHP. So, not sure how this would be done with your code.
But, here is some sample PHP code to send out an email. It is designed to pull a couple fields
from your form and send them inside of an HTML email. Note, since the email is an HTML version and
not just a TEXT email, you can program in a lot of nice graphics and the such. Note that the logo
is a graphic and must be stored on your server. This is just sample code, you need to work up your
own version and post your form with the correct data…
[php]

<?PHP // Set up email and mail to one address for testing... // Grab data from the input fields on the form... $name = $_POST['name']; $address = $_POST['address']; // Just two fields for testing... Not yours I made this page up... // Email Subject $subject = 'Important message from Ernie...'; // Email Address $email = '[email protected]'; // Email Message $message = ' Welcome to our new website, ' . $name . ' !

We have your address as: ' . $address . '

'; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'To: ' . $email . '\r\n'; $headers .= 'From: Important Message the world of Ernie! ' . "\r\n"; // Mail it mail($email, $subject, $message, $headers); ?>

[/php]
I used this same code to explain to another newbie on the site. It should give you an idea how to send
an email with many of the common options that you might need. Hope that helps…

thanks Ernie, couldn’t quite work out how to use your code, but thanks anyway.

I found a very simple solution working, but it emails me upon loading of the page, what I really need is it to email me upon clicking of submit button ( so an “if” statement ) plus a value from the form ( “img-title” )

see below the code of the page - the email code is at the bottom and I have added where I need what.

I have looked at how to use the “if” statement but just cannot it to work for me, any help appreciated

page code :

<?php include("header.php");?>

Submit Images

Category

--Select Create Embroidery or Estimate Only-- <?php $submitcat = $mysqli->query("SELECT id, c_name FROM categories ORDER BY c_name ASC"); while ($subcat = mysqli_fetch_array ($submitcat)){

?>

<?php echo $subcat['c_name'];?> <?php } ?>

Please zoom into design as much as possible.

Your Email address

Submit

<?php include("footer.php");?> <?php // the message $msg = "here I need the value added at "img-title""; (here I need an "if" statement - "if submit button clicked") // send email mail("***********@gmail.com","--",$msg); ?>

dolf

“SOLVED”

realised I was trying to do this from the wrong page - changed to the actual submit page. php containing upload to database and therefor the variable I needed - working now…

dolf

Well, sorry I didn’t help more. But, very glad you solved it on your own. Feels good, doesn’t it! ? !

Congrats! See you in your next post…

thanks ErnieAlex

yes, it feels good, but also stupid that I didn’t work it out a little faster.
it turned out to be pretty simple and straightforward in the end, (once I was on the correct page of course :smiley: )
dolf

Just one last tidbit with the jquery. You might have issues with users using chrome. I’ve found that using .on hasn’t worked for me in the past. I had to switch to .click() to get the code to work. Though with the form library, u might want to use .submit instead.

thanks for your input richei, no complaints from users so far, so I’m going to leave it for the time being, but I have saved your suggestion just in case I do get problems… thanks again.

dolf

Sponsor our Newsletter | Privacy Policy | Terms of Service