Page 1 of 2
Somebody help me!!
Posted: Thu Nov 20, 2003 12:30 am
by ali
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.
Posted: Thu Nov 20, 2003 12:01 pm
by Weirdan
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 } ?>
Posted: Thu Nov 20, 2003 8:38 pm
by ali
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.
Posted: Thu Nov 20, 2003 9:26 pm
by Saethyr
The porn popups are little much......
Posted: Fri Nov 21, 2003 7:16 am
by ali
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.
Posted: Fri Nov 21, 2003 10:28 am
by Weirdan
please post the php code here. And post phpinfo() results, seems like your host is running php3 instead of php4 as I thought.
Posted: Fri Nov 21, 2003 6:05 pm
by ali
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.
Posted: Fri Nov 21, 2003 6:13 pm
by Weirdan
Then I can't help you 'cause my knowledge of php3 is less to zero.
Posted: Fri Nov 21, 2003 6:36 pm
by d3ad1ysp0rk
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
Posted: Fri Nov 21, 2003 8:20 pm
by ali
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.
Posted: Fri Nov 21, 2003 8:41 pm
by Weirdan
no, it doesn't allow POSTs to your script. You can use GET as workaround:
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!";
}
?>
and modify your form to use GET method:
Code: Select all
<form action="..............." method="GET">
...............................
Posted: Fri Nov 21, 2003 9:03 pm
by ali
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?
Posted: Fri Nov 21, 2003 9:29 pm
by d3ad1ysp0rk
<input type=hidden name="redirect" value=
"
http://www.digitaldummies.coolfreehost.com/1.html">
whats that for?
Posted: Sat Nov 22, 2003 8:23 pm
by ali
A script I previously used wanted me to put this line so that it can redirect it to the page I want.I forgot to remove this line.However now I have removed it.Let me try it now.
Posted: Sat Nov 22, 2003 8:31 pm
by ali
Well I removed that line but that script still didn't work.It still just showed up a page that showed my script.And no data was written to the file.What do I do now?