Code:
function get_position($file)
{
	while(!(feof($file)))
	{
		fseek($file,1,SEEK_CUR);
		$offset++;
		if(feof($file))
		break;
	}
	rewind($file);
	while(!(feof($file)))
	{
		fseek($file,1,SEEK_CUR);
		$total++;
		if(feof($file))
		break;
	}
		$position=$total-$offset;
		return($position);
}



function put_str_fp($file,$str){
	echo $str."
";
	$pos=get_position($file);
	while(!(feof($file)))
	{
		$buf.=fgetc($file);
	}
	echo $buf;
	fseek($file,$pos,"SEEK_SET");
	fwrite($file,$str);
	fwrite($file,$buf);
	return("Success");
}
I'm having a problem though, in my get_position statement, my while loop is infinite for some reason. Anyone know why?

That should be the only problem i have... if you want to test the script, go to dburg-php.bizhat.com, log in with tom password hhh go to classwork and submit something.

sdb.txt is where it will be written to.

my dbase mng ment file is

Code:
<html>
<body>
<?php

include "functions.php";

if(!($_SERVER['HTTP_REFERER']==='http://dburg-php.bizhat.com/teacher-consol.php'))
exit('You can not access this page.  Please log into your console and edit the database that way.');

switch($_POST[f_type]) {

	case school:
		
		if(!($s=fopen('sdb.txt','r+')))
		   exit('Unable to open schoolwork database file.');
		echo "Checking Database for username: ".$_COOKIE['uname']."
";
		while(!(feof($s)))
		{
			$name=stream_get_line($s,"2048","þ")."\n";
			echo "Comparing database name \"".$name."\"to username \"".$_COOKIE['uname']."\"
"; 
			if($name===$_COOKIE["uname"])
			{
			echo "Found ".$_COOKIE['uname']." in database, writing information.";
			fseek($s,1,SEEK_CUR);
			$t_input="|$_POST[month]-$_POST[day]|$_POST[topic]|$_POST[subject]|\n";
			echo put_str_fp($s,$t_input);
			break;
			}
			fgets($s);
		}

/*		while(!(ord(fgetc($s))==='254'))
		{
		   fseek($s,-1,SEEK_CUR);
		   fwrite($s,'');
		}
*/		break;
	case home:
		echo 'home right';
		   if(!($h=fopen('hdb.txt','r+')))
		      exit('Unable to open homework database file.');
		break;
	default:
		echo 'This page was not retrieved correctly. Please re-log into your console and try again.';
		break;
}


?>
</body>
</html>
[/code]