Somebody help me!!
Moderator: General Moderators
Somebody help me!!
Hi everyone.Well I desperately need help.I want a script that would log the output of my form to a text file.Can someone please write down this script for me?Believe me,I have gone half crazy trying to find this script I have been wandering around all the internet for 3 MONTHS! And now this forum is my only hope.Please help me.
Thanks.
@li.
Thanks.
@li.
Code: Select all
<?
if(isset($_POST['submit'])){
$file="/somewhere/lies/a/file";//where you want to add
$fields=array('name','address','text'); //place the field names you want to save into the file here
$fp=fopen($file,"a") or die("Couldn't open file");
foreach($_POST as $name=>$value)
if(in_array($name,$fields))
fwrite($fp,"$name: $value\n") or die("Couldn't write to file");
echo "Thanks for your input!";
}else{ ?>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="POST">
//................. place here your form fields
</form>
<?php } ?>Hi and thanks a lot for your help.But that script is still not working.Visit http://www.digitaldummies.coolfreehost.com(soon digitaldummies.com).On the bottom left there is a small form that says "Enter your email address to sucscribe for our free newsletter" or something like that.It just asks for your email address.Type any fake value in and click submit.Then you'll see.It just displays a blank page.And no data is written to the file.You can view the source code of my page.Now please tell me what is wrong?And is there anyway I can redirect the user to a page instead of displaying a thankyou message?
thanks a heaps.
@li.
thanks a heaps.
@li.
I am really sorry for the pop ups.I have got nothing to do with them.The host pops them up itself.And my domain name is still being transfered.So I have to use a free host till it has been transfered.Coolhost.com is the only free host that I know of that provides free php support.If you know of any other one than please tell me.As for everyone else,if you visit my website then don't forget to close the pop ups.I am terribly sorry for the inconvenience.
Yeah that's right.My host is running php3 because in the FAQ they say that whenever uploading your script,always give it the file extension oh php3.Here's the code:
<?
if(isset($_POST['submit'])){
$file="/l.txt";//where you want to add
$fields=array('add'); //place the field names you want to save into the file here
$fp=fopen($file,"a") or die("Couldn't open file");
foreach($_POST as $name=>$value)
if(in_array($name,$fields))
fwrite($fp,"$name: $value\n") or die("Couldn't write to file");
echo "Thanks for your input!";
}else{ ?>
<?php } ?>
And the function phpinfo() is disabled on that host.Because of security reasons,they say.
<?
if(isset($_POST['submit'])){
$file="/l.txt";//where you want to add
$fields=array('add'); //place the field names you want to save into the file here
$fp=fopen($file,"a") or die("Couldn't open file");
foreach($_POST as $name=>$value)
if(in_array($name,$fields))
fwrite($fp,"$name: $value\n") or die("Couldn't write to file");
echo "Thanks for your input!";
}else{ ?>
<?php } ?>
And the function phpinfo() is disabled on that host.Because of security reasons,they say.
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
http://www.coolfreehost.com/
read the site.. it's meant for adult sites..
I'd suggest you try a free PHP host that ISN'T meant for porn.. maybe spaceports? ( http://www.spaceports.com )
they make you put a banner and have an index.htm/html/shtml file (meaning yoursite/ won't direct to index.php), so you could always make a splash page, and include their banner there too
read the site.. it's meant for adult sites..
I'd suggest you try a free PHP host that ISN'T meant for porn.. maybe spaceports? ( http://www.spaceports.com )
they make you put a banner and have an index.htm/html/shtml file (meaning yoursite/ won't direct to index.php), so you could always make a splash page, and include their banner there too
Ok so now I have this account on space ports.Here's my address:
http://scorpius.spaceports.com/~digitald
But this time it gives this error when I try to run the script:
Method Not Allowed
The requested method POST is not allowed for the URL /~digitald/add.php.
Anyone has any idea what I should do?I think that this host doesn't allow php scripts to run.
http://scorpius.spaceports.com/~digitald
But this time it gives this error when I try to run the script:
Method Not Allowed
The requested method POST is not allowed for the URL /~digitald/add.php.
Anyone has any idea what I should do?I think that this host doesn't allow php scripts to run.
no, it doesn't allow POSTs to your script. You can use GET as workaround:
and modify your form to use GET method:
Code: Select all
<?
if(isset($_GET['submit'])){
$file="/l.txt";//where you want to add
$fields=array('add'); //place the field names you want to save into the file here
$fp=fopen($file,"a") or die("Couldn't open file");
foreach($_GET as $name=>$value)
if(in_array($name,$fields))
fwrite($fp,"$name: $value\n") or die("Couldn't write to file");
echo "Thanks for your input!";
}
?>Code: Select all
<form action="..............." method="GET">
...............................Hi and thanks for all your help.Now it comes with another problem,when I submit the email address,it comes with a page that displays nothing but all the code of that script.Just go to
http://scorpius.spaceports.com/~digitald/
and see it for yourself.Now what?
http://scorpius.spaceports.com/~digitald/
and see it for yourself.Now what?
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
<input type=hidden name="redirect" value=
"http://www.digitaldummies.coolfreehost.com/1.html">
whats that for?
"http://www.digitaldummies.coolfreehost.com/1.html">
whats that for?