Looking for coding help to save form input data (an email address) from http://www.leaseown.org/firstpage.php
to file in cpanel rather than sending it to email address as is now the case.
Thanks
Roger
Looking for coding help to save form input data (an email address) from http://www.leaseown.org/firstpage.php
to file in cpanel rather than sending it to email address as is now the case.
Thanks
Roger
I need to know what kind of file you want to save the data in: .csv. .tab, or .txt. Let's suppose that you wnat to save the form submitted email in a .txt file, with a comma used as separator, and a \r\n as line end. Your script should be something like:
<?
// Receiving variable email
@$email = addslashes($_POST['email']);
//saving record in a text file
$file_name = "emailfile.txt"; // emailfile.txt is the name of the file, you can change it to what you want.
$first_raw = "email\r\n";
$values = "$email\r\n";
$is_first_row = false;
if(!file_exists($file_name))
{
$is_first_row = true ;
}
if (!$handle = fopen($file_name, 'a+')) {
die("Cannot open file ($file_name)");
exit;
}
if ($is_first_row)
{
if (fwrite($handle, $_first_raw ) === FALSE) {
die("Cannot write to file ($file_name)");
exit;
}
}
if (fwrite($handle, $values) === FALSE) {
die("Cannot write to file ($file_name)");
exit;
}
fclose($handle);
header("Location: thankyou_page.html");
?>
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!
Thanks for the help. The form is in a php page and I do want to use a txt file. Does the above code go in the body of my "action.php" page? Any additional code necessary?
Roger
Naveldesign,
Everything seems to be working well except an error warning appears on my action1 page. It reads "Warning: Cannot modify header information - headers already sent by (output started at /home/vvisucax/public_html/action1.php:in /home/vvisucax/public_html/action1.php on line 40"
Any suggestions for fixing this?
Roger
Yes, it would go in the body of the "action.php". In that case, delete the
header("Location: thankyou_page.html");
line. Your action.php is infact your thankyou (or confirmation page).
This script was a standalone version, which would update the file and then redirect to the thankyou page. Just delete the line and you will be ok.
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!
Thanks verymuch. All is working great now!
Roger
Navaldesign
I now need emaillest.txt in my public_html of leaseown.org to be in a password protected subfolder. I haven't figured out how to do this. Suggestions?
Roger
YOU cannot password protect a file. You can password protect the FOLDER that it is in. But keep in mind- this will prevent the script from running as it needs the password to access the folder before it can open the file.
Why do you need it password protected? Simply change the name of the file given in this thread as an example to a file name only you know. Then make sure to change it in the corresponding parts in the script. You will be the only one who knows it's there.
Just a thought.
Andy
PHP- is a blast!
Andy is correct, you CANNOT password protect a file. However, you can do this: create a script that will allow you and ONLY you to open and view the file contents. Set the file permissions to be 600. This way, only the site owner has permissions to view or edit the file (that's why you need the server side script), whilst the public has no permission to do so.
Ofcourse, the above requires some coding abilities on your part. If you want to keep things simple, just go the way Andy has suggested.
However, i do NOT beleive in file storing. I prefer DB storing, and a DB admin interface that allows browsing the info sent, and eventually also exporting the info in Excel, word, csv or xml format for further work. However, this also requires a custom made script, which has a certain cost. If you are interested, contact me
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!
There are currently 1 users browsing this thread. (0 members and 1 guests)