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

Posting Serialized Data Not Working
I am trying to send an object from one PHP file to another using POST. I serialize the object and th

I need help on this PHP code
Hi everybody, I made some kind of mistake while editing the code below. As you see, at the 3 row my

array_combine() trouble w/csv file
I have a problem with a piece of code I wrote to import some records from a csv file into mysql. I h

HELP with mysql_real_escape_string
I'm looking to remove apostrophes completely when someone enters lyrics but don't have a clue how to

Weird Problem with curl while sending data
I am facing a weird problem with sending data to a site via curl.

If i send the value by this

Else statement screws up all css
Does anyone know what goes wrong in the process with this php code?
This code seems to be causing

What am I missing here? Help!
Hello all!. I can't seem to get this working right. Well - it renders right, but something is goin

PHP4 to PHP5 Conversion
Hi Everyone,

I am working on a site that is built up on PHP4 and each page is being started f

explode() function problem maybe
Hi I'm having trouble searching my database. When I type two words in the search field it only searc

Image loading
Hi Developers,

I'm trying to display an image from images/image.gif getting the url from mysq

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