604htq Posted February 14, 2010 Share Posted February 14, 2010 Hi there, I'm pretty familiar with html and basics, but by no means can code or write php (or any other scripting language for that matter) haha... I am working on a small/quick project and was hoping someone might be able to help out. Basically what I have is a form that allows someone to upload a file to my server, and it also asks them for some information that I would like to be e-mailed to myself and the person who uploaded/submitted the form... Here is the HTML page: <form enctype="multipart/form-data" action="upload.php" method="POST"> <p align="center">Please choose a file: <input name="uploaded" type="file" /> </p> <p align="center">Your Name: <label>Name: <input type="text" name="Name" id="Name" /> </label> </p> <p align="center">Your E-mail Address: <label>email <input type="text" name="email" id="email" /> </label> </p> <p align="center">Your Paypal E-mail Address: <label>paypal <input type="text" name="paypal" id="paypal" /> </label> <br /> <span class="style1">(if your paypal address is the same as your e-mail address, please write here as well)</span></p> <p align="center">By clicking the "Upload" button below you are agreeing to the following terms (note this will also be e-mailed to you)</p> <p align="center"> <label> <textarea name="agree" id="agree" cols="45" rows="5" readonly>I agree.</textarea> </label> </p> <p align="center">Please be patient after clicking "Upload" do not close this window, the screen will change when video has been succesfully uploaded to our server.</p> <p align="center"><br /> <input type="submit" value="Upload" /> </p> </form> Here is the contents of upload.php <?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 35000000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } ?> as you can see, simple php -- but that part of the script works, the file gets uploaded fine... But I'd also like an email with all of the values in it (minus the file) sent to their e-mail address and an e-mail address I specify.. I realize, time is money,, just hoping someone might have some time to take a look at this! thanks in advance! Link to comment https://forums.phpfreaks.com/topic/192074-simple-e-mailing-script-form/ Share on other sites More sharing options...
Stuie_b Posted February 15, 2010 Share Posted February 15, 2010 Php has built in functions which allows you to do just that, see here for more info. try the following, <?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 35000000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { $to = addslashes($_POST['email']); $name = addslashes($_POST['name']); $pp = addslashes($_POST['paypal']); $from = "[email protected]"; //set this to your email address or the servers address $msg = "New File Upload From: $to Name: $name Paypal: $pp File:".$_FILES['uploadedfile']['name']; //Change the above to the message you would like to send. echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; mail($to,$subject,$message,"FROM: $from"); //Send the Email to them mail($from,$subject,$message,"FROM: $to"); //Send the email to you } else { echo "Sorry, there was a problem uploading your file."; } } ?> Stuie Link to comment https://forums.phpfreaks.com/topic/192074-simple-e-mailing-script-form/#findComment-1012398 Share on other sites More sharing options...
604htq Posted February 15, 2010 Author Share Posted February 15, 2010 thanks this worked!!! Link to comment https://forums.phpfreaks.com/topic/192074-simple-e-mailing-script-form/#findComment-1012410 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.