Web Hosting Talk







View Full Version : I'm genuinely confused and really need help


WoodShedd
09-07-2003, 11:58 PM
I had the following script working some time ago, but today when I went to set it up again, it would not work

I get no error messages, and the script will not write to file that which is input through the form.

in short I really am stumped, and any help at all would be extremely welcome :)

Thanks


<?ob_start();
define('FILENAME','/var/www/html/reglist.dat');
define('IPLOG','/var/www/html/iplog.dat');
define('FREQ', 30);
define('REDIR','http://site.com/thankyou.html');

$diff = time() - @filemtime(FILENAME);
if ($diff < FREQ) die('You may only submit a form once in 30 seconds.');

if ($errors)die('An error occured while processing your input.');

$s = sprintf("%s|%s|0\n",$_POST['username'],$_POST['password']);
$s2 = sprintf("%s -- %s\n",date('r'),$_SERVER['REMOTE_ADDR']);

$fd = fopen(FILENAME,'a+');
fputs($fd,$s); fflush($fd); fclose($fd);

$fd2 = fopen(IPLOG,'a+');
fputs($fd2,$s2); fflush($fd2); fclose($fd);

header('Location: '.REDIR);
ob_end_flush();
?>

elitehst
09-08-2003, 12:54 AM
try this.......


<?
ob_start();
define('FILENAME','/var/www/html/reglist.dat');
define('IPLOG','/var/www/html/iplog.dat');
define('FREQ', 30);
define('REDIR','http://site.com/thankyou.html');

$diff = time() - @filemtime(FILENAME);
if ($diff < FREQ) die('You may only submit a form once in 30 seconds.');

if ($errors)die('An error occured while processing your input.');

$s = sprintf("%s|%s|0\n",$_POST['username'],$_POST['password']);
$s2 = sprintf("%s -- %s\n",date('r'),$_SERVER['REMOTE_ADDR']);

$fd = fopen(FILENAME,'a+');
fputs($fd,$s); fflush($fd); fclose($fd);

$fd2 = fopen(IPLOG,'a+');
fputs($fd2,$s2); fflush($fd2); fclose($fd);

header('Location: '.REDIR);
ob_end_flush();
?>


Make sure that 'ob_start();' is on a new line from '<?'

WoodShedd
09-08-2003, 01:22 AM
Thanks for the help.

still no luck... I'm beginning to believe it's something with my server. I rather quickly wrote one in a different style, and it didn't work either:


<?

if($username != "" && $password != ""){
if ($BeenSubmitted) {

$post = "Name: $username Pass: $password\n";

$file = "reglist.dat";

$fh1 = fopen ($file, "r");
$data1 = fread ($fh1, filesize ($file));
fclose ($fh1);

$data = $post.$data1;

$fh2 = fopen($file,"w");
fwrite($fh2,$data);
fclose($fh2);

}
};
?>


I'm really not sure.

Burhan
09-08-2003, 05:28 AM
Any error messages from the interpreter? Try adding error_reporting(E_ALL); in your script.

Also, make sure that your script has write access to the file. Check to make sure that $fp is valid before you start writing to it.

if(!($fp = fopen(FILENAME,"a+"))) { die("Cannot open file"); }

WoodShedd
09-08-2003, 02:08 PM
thanks for the help, fyrestrtr, but still no luck :(

I get no errors, and still nothing written to file

Reptilian Feline
09-12-2003, 09:17 AM
<? is called a short tag, if I'm not mistaken.
Try using <?php instead. Short tags can have been disabled on the server.

I always use <?php and ?> instead of <? and ?> so I know it always work.