PDA

View Full Version : FIXED: Would like to mail on submit button



Dirt_Diver
08-25-2008, 12:29 PM
I have a PHP page that users can upload an image to the site. I wanted to get an email everytime a user uploads an image so I added ;


mail('myemail@host.com', 'New Uploaded Feature Image', 'a user has uploaded an image to be reviewed for a featured image.

Which is all fine and dandy but now everytime the page loads I get an email. What I would like to is see if I can add it to the value section of my upload button.


<input name="Submit" type="submit" value="Upload Image">

Can I add the mail function to something like this?


<input name="Submit" type="submit" value="Upload Image", "<?php mail('myemail@host.com', 'New Uploaded Feature Image', 'a user has uploaded an image to be reviewed for a featured image.?> ">

JShor
08-25-2008, 02:19 PM
you need to further elaborate on your code . try something like this :



<?php

if(isset($_POST['MY_FILE_UPLOAD'])) {

mail('myemail@host.com', 'New Uploaded Feature Image', 'a user has uploaded an image to be reviewed for a featured image. ');

}

?>


you need to put this mail function where the code calls the page once it's submitted.

good luck

Dirt_Diver
08-25-2008, 04:50 PM
Hey thanks I got it, I saw that my error was where I had it located.

Here is the code


if(isset($_POST['Submit']) && !$errors)
{

echo "<center><h2>Test goes here</h2></center>";
echo '<a href="'.$newname.'"rel="lightbox" title="<center><strong>Your Submission Image</strong></center>"> <img src="'.$thumb_name.'"></a>';
mail('email@host.com', 'Subject', 'content. ');
}