Somebody help me!!

Looking for volunteers to join your project? Need help with a script but can't afford to pay? Want to offer your services as a volunteer to build up your portfolio? This is the place for you...

Moderator: General Moderators

ali
Forum Newbie
Posts: 15
Joined: Tue Nov 18, 2003 9:05 pm
Location: Pakistan

Somebody help me!!

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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 } ?>
ali
Forum Newbie
Posts: 15
Joined: Tue Nov 18, 2003 9:05 pm
Location: Pakistan

Post 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.
User avatar
Saethyr
Forum Contributor
Posts: 182
Joined: Thu Sep 25, 2003 9:21 am
Location: Wichita, Kansas USA
Contact:

Post by Saethyr »

The porn popups are little much......
ali
Forum Newbie
Posts: 15
Joined: Tue Nov 18, 2003 9:05 pm
Location: Pakistan

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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.
ali
Forum Newbie
Posts: 15
Joined: Tue Nov 18, 2003 9:05 pm
Location: Pakistan

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Then I can't help you 'cause my knowledge of php3 is less to zero.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post 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
ali
Forum Newbie
Posts: 15
Joined: Tue Nov 18, 2003 9:05 pm
Location: Pakistan

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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

&lt;form action="..............." method="GET"&gt;
...............................
ali
Forum Newbie
Posts: 15
Joined: Tue Nov 18, 2003 9:05 pm
Location: Pakistan

Post 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?
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

<input type=hidden name="redirect" value=
"http://www.digitaldummies.coolfreehost.com/1.html">

whats that for?
ali
Forum Newbie
Posts: 15
Joined: Tue Nov 18, 2003 9:05 pm
Location: Pakistan

Post 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.
ali
Forum Newbie
Posts: 15
Joined: Tue Nov 18, 2003 9:05 pm
Location: Pakistan

Post 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?
Post Reply