Preventing blank or already entered values


Posted on 16th Feb 2014 07:03 pm by admin

Im trying to learn how to place a read file line by line and prevent duplicate entries and also BLANK entries, into my process php script,

using feof, I have failed many times and get so many errors such as syntax expecting . or , and so forth
this is my process.php
<?php
$File = "links.txt";
$Handle = fopen($File, 'a');
$Data = "".$_POST['ID'];
fwrite($Handle, $Data."n");
print "Data Addedn";
fclose($Handle);
?>


<?php
countLines("links.txt");
function countLines($filepath)
{
$handle = fopen( $filepath, "r" );
$count = 0;
while( fgets($handle) )
{
$count++;
}
fclose($handle);
return $count;
}

?>
<head>
<meta http-equiv="REFRESH" content="5;test1.php"></HEAD>

please wait... navigating back!



I got fed up and deleted all my work, to start from scratch,

if feof($_POST['ID'])
{
alert 'Already entered';
return;
}
that was just one of my attempts
also im unsure if putting in /n would make it look for /n or new line, if it looks for new line and every file has the new line marker would it always return as the data was already entered?

Thanks in advance for assistance/teaching

No comments posted yet

Your Answer:

Login to answer
241 Like 9 Dislike
Previous forums Next forums
Other forums

INSERT for date range
Hi all

I have the following table

Code: [Select] `date` date
`day` int(2)
`

Update data to upper case in parent/child tables
Hi Gurus!

In production we have a product table and which is being reference by many tabl

some query on multilingual website
Hi all,

Which is the simplest and easiest method to make a website multilingual,
is it put

isset undefined variable
Hi all,

Hope someone can point out the obvious. I've a log in script, if you dont enter a use

dynamic table with forms
I have a table that is populated with mysql data and in teh first column there is a raido button tha

Business Health Check
Hello

I need to create an online business health check for a client it will be multiple choi

PHP/Database issue
My friend is helping me make a database where you go to a certain webpage of my site and the page wi

duplicate record notification
In my database, after insertion of records, I want to know if the record inserted is duplicate or no

checkbox update
I am having a brain fart right now and i cant remember how to do this. if anyone could help that wou

Problem in String replace program's output
Hi all,
I was trying to make a program which accepts a string and replaces it with another stri

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash