I know how to make a simple form that mails to my Email Address, but my server doesnt alow it. So i need some kind of way to post the info to a .txt file or some other way to store the info they submit. Can you please prvide the basic code. thank you!
Do you have mysql? I think that would be the ideal solution. Create a db table w/ the following fields: ID (set to auto-increment), from (VARCHAR), body (TEXT). Then, just use a simple INSERT query.
i have PHPmyAdmin- and i know absolutley nothing about it. Its really hard to navigate. so if theres another way id appreciate someone sharing it.
If you don't have access to mysql or text file is the only way you want to go... Make a php page called formprocess.php (or whatever name you want) with this code in it. foreach ($_POST as $key=>$value){ $received .= "$key = $value\r\n"; } $printout = fopen('formvariables.txt', 'w'); fwrite($printout, $received); fclose($printout); //Add your thank you text, etc. here. PHP: Then post your form to formprocess.php.
On your formprocess.php page you'll need to start it with <?php and end it with ?> instead of your html tags. IE: <?php foreach ($_POST as $key=>$value){ $received .= "$key = $value\r\n"; } $printout = fopen('formvariables.txt', 'w'); fwrite($printout, $received); fclose($printout); //Thankyou. ?> Don't need the <html> tags in there.
I have never scripted php before, but I have started to learn: This will fix your problems: <?php foreach ($_POST as $key=>$value){ $received .= "$key = $value\r\n"; } !$printout = fopen('saved.txt', 'a'); fwrite($printout, $received); fclose($printout); //Thanks! header("location: http://your-url.com/thankyou.html"); ?> Code (markup): I edited the last line to redirect to a "thank you" type page, just change the "your-url" to your url. Like 2 minor changes, and it will do exactly what your looking for.
Yes, when changing the switch in the fopen function to "a" it will "append" to your file and not replace the previous posts. Just make sure you have the text file there already. (which you should by now) $printout = fopen('formvariables.txt', 'a'); fwrite($printout, $received); fclose($printout); echo "Thank you for using our form. Somebody will get with you shortly."; ?> And like affihq was showing, there are different approaches you can take as to what to do next. I personally use a "thankyou" page and have this "formprocess" page redirect to our "thankyou" page like affihq's example. But going further this is something you'll need to decide on what you want to do. There are also "checks" that you'd like to perform to make sure your function is getting processed before it goes any further, etc. etc., etc. It can ge quite in depth. But for the most part, your coding above should do the trick for what you're needing.