btr2007 Posted December 19, 2007 Share Posted December 19, 2007 Is there anyway for a form to have two actions? Example: Visitor selects a file to upload and when they click upload it calls the upload script and also sends an email to a recipient using a form-to-mail script. Or is there some code that can be included in the upload script to send an email? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 19, 2007 Share Posted December 19, 2007 You only need one form action. Here is an example <?php //check if they pressed the submit button if (isset($_POST['submit'])){ //put upload code here //put email code here } ?> If you don't understand that, post your code and we can help you put it together. Quote Link to comment Share on other sites More sharing options...
btr2007 Posted December 19, 2007 Author Share Posted December 19, 2007 Will that still work when I'm using that Formmail script to send the email? <?php // Where the file is going to be placed $var1 = $_GET["leadon"]; //$path = mysql_real_escape_string('leadon'); $target_path = $var1; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file " . basename( $_FILES['uploadedfile']['name']) . " has been uploaded"; /*Add email code here? - can it be a call to formmail or could i use some other script?*/ } else{ echo $target_path; echo "There was an error uploading the file, please try again!"; } ?> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 19, 2007 Share Posted December 19, 2007 Yes, that should work. If you would rather keep the formmail script separate, you can just use an include. so right where you have that comment, just put this code include "formmail.php"; //or whatever that file is called Quote Link to comment Share on other sites More sharing options...
btr2007 Posted December 19, 2007 Author Share Posted December 19, 2007 Ok I've decided to use some php code to send the email instead. The script i was using is in a pl file and gets stored in the bin. If i can get the php email code to work i will mark this topic as solved but if i don't i will use this topic for questions. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.