boulder omen Posted December 31, 2005 Share Posted December 31, 2005 I have coded a script in HTML for one of the site I work at, and its a job application, I have programmed it so when they hit "Submit" it emails the filled out application to the manager. But what he asked me if I could have the filled out application saved to the server as a txt or anything. heres the source code to take a better look at things <html><head><title>Staff Application</title></head><body bgcolor="#232d35"><font face="Times New Roman, Times, serif" color="#ffffff" size="5"><strong>Staff Application Form </strong></font><br><form action="MAILTO:[email protected]" method="post"><font face="Arial, Helvetica, sans-serif" color="#ffffff" size="2">Name: <input type="text" size="30" value="" name="Your Name"> <br>Age: <input type="text" size="30" value="" name="Your Age"> <br>EG Username</font><font face="Arial, Helvetica, sans-serif" size="2">: <input type="text" size="30" value="" name="Dx Username"> <br><font color="#ffffff">AIM Screen Name</font>: <input type="text" size="30" value="" name="AIM Screen Name"> <br><font color="#ffffff">What posistion are you applying for?</font></font> <font face="Arial, Helvetica, sans-serif" size="2"><select size="1" name="Posistion"> <option value="">Designer</option> <option value="">Admin</option> <option value="" selected="selected">Staff</option></select> <br><font color="#ffffff">Why should we hire you?</font></font><font size="2">:</font> <textarea name="Why should I hire you?" rows="3" cols="40"> </textarea> <br><input type="submit" value="Submit Query" name="submit"> <input type="reset" value="Reset" name="reset"> <br><font color="#ffffff">Please allow a couple of days for response...</font> </font><font size="2">:</font> </form></body></html>so my Question is how do I get it saved to the server instead of Emailed. by the person filling out the app?thanks any help greatly appreciated. Link to comment Share on other sites More sharing options...
nsane Posted December 31, 2005 Share Posted December 31, 2005 first, change...<form action="MAILTO:[email protected]" method="post">to..<form action="http://mysite.com/action.php" method="post">then you'll need to setup a PHP script that uses the $_POST["Your Name"] global variable ("Your Name" can be changed for the other form fields). then just have it ouput the data with fwrite()...quite simple actually :lol:CODE<?php//Location for the TXT files, CHMOD to 777//NEVER store personal data within your /public_html/!$dir = "/home/username/private_data/";if(isset($_POST["Your Name"])){ $name = "Name: " . $_POST["Your Name"] . "n";} else { echo "Please go back a page and fill in your name."; exit;}if(isset($_POST["Your Age"])){ $age = "Age: " . $_POST["Your Age"] . "n";} else { echo "Please go back a page and fill in your age."; exit;}if(isset($_POST["Dx Username"])){ $dxname = "EG Username: " . $_POST["Dx Username"] . "n";} else { echo "Please go back a page and fill in your EG Username."; exit;}if(isset($_POST["AIM Screen Name"])){ $aim = "AIM Screen Name: " . $_POST["AIM Screen Name"] . "n";} else { //echo "Please go back a page and fill in your AIM Screen Name."; //exit;}if(isset($_POST["Posistion"])){ $position = "Position: " . $_POST["Posistion"] . "n";} else { echo "Please go back a page and fill in the position you wish to fill."; exit;}if(isset($_POST["Why should I hire you?"])){ $whyhire = "Reason for hire: " . $_POST["Why should I hire you?"] . "n";} else { echo "Please go back a page and tell us why we should hire you."; exit;}$data = $name . $age . $dxname . $aim . $position . $whyhire;$file = $dir . $position . " - " . $name . " - " . $age . ".txt";if(file_exists($file)){ $fp = fopen($file, "a"); if($fp){ fwrite($fp, "nnn" . $data); echo "Application submitted successfully!"; } else { echo "There was an error while submitting the application!"; } fclose($fp); exit;} else { $fp = fopen($file, "w"); if($fp){ fwrite($fp, $data); echo "Application submitted successfully!"; } else { echo "There was an error while submitting the application!"; } fclose($fp); exit;}?>NOTE: i wrote this off the top of my head as an example, dont know if it'll work or not. but i will test around with it when i have some more time ;) Link to comment Share on other sites More sharing options...
boulder omen Posted December 31, 2005 Author Share Posted December 31, 2005 thanks a million, you are a god Link to comment Share on other sites More sharing options...
boulder omen Posted January 2, 2006 Author Share Posted January 2, 2006 ok I tried it out and i got the "Please go back a page and fill in your name." I tried to fix it myself but my php is bad!, i get this error even when all fields are filled it or non at all Link to comment Share on other sites More sharing options...
nsane Posted January 2, 2006 Share Posted January 2, 2006 your right, it was the form value names, seems the can't uses spaces...even tho they're quoted :)any ways, here's a fully tested and working version, provided you have the proper directory set with the right permissions :Ppost.raroh, and i made a few tweaks since the one i posted ;) Link to comment Share on other sites More sharing options...
boulder omen Posted January 2, 2006 Author Share Posted January 2, 2006 Thanks a million again, hope you had a happy new year :) Link to comment Share on other sites More sharing options...
boulder omen Posted January 2, 2006 Author Share Posted January 2, 2006 sorry to bother you but what is the proper directory set? where do i need to make folders? do I make /home/username/applications/ ? because I did with the CHMOD to 777 and I got a failed to open stream error Link to comment Share on other sites More sharing options...
nsane Posted January 2, 2006 Share Posted January 2, 2006 run the following script and PM me the path it gives you...<?phpecho $_SERVER["SCRIPT_FILENAME"];?>also, when you login via ftp, do you have to upload site files into public_html or into your root folder (/)? :) Link to comment Share on other sites More sharing options...
boulder omen Posted January 2, 2006 Author Share Posted January 2, 2006 public_html Link to comment Share on other sites More sharing options...
boulder omen Posted January 2, 2006 Author Share Posted January 2, 2006 thanks I figured it out lol Link to comment Share on other sites More sharing options...
nsane Posted January 2, 2006 Share Posted January 2, 2006 then ignore my PM :) Link to comment Share on other sites More sharing options...
boulder omen Posted January 2, 2006 Author Share Posted January 2, 2006 Thanks for all your help, I got it working fine now with your help ofcourse :) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.