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
Did you know?Explore Trending and Topic pages for more stories like this.
<?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

Not capturing all the information we require in the form.......
Hi Guys,

I was wondering if you would share some more of your knowledge today, I'm hoping it

Give me all your tricks for minimizing jar file size

Hi, I'm coming close to releasing my J2ME game... I am kicking up against the 64k size barrier w

need help to creat database
Hello Team, please guys i am stuck from three days with paypal issue for IPN but no luck yet now i w

Modal Popup Help
Hi guys, I have a modal popup with an iframe. How can i send data from a label or textbox to the ifr

Need help Updating SQL Server Express DB from c# :(
Please can anyone help with:-
1 How to sructure the strSelect statement.
2 How to instruct

EXplanation help
Hey all,

I am still fairly new to PHP programming and I am trying to put together a page wher

Ajax Error since Upgrading to 3.5
Ever since upgrading my site to .NET 3.5 (I needed LINQ), I've been getting this annoying error on o

Sendmail.php - heading error following check_input
Hi,

I would greatly appreciate some help? I am brand new to PHP and have been searching and e

mySQL and PHP search
Hello,
I am trying to code a project and ran into a brick wall with one of my pages. I am pretty

help with variable
I've got a problem, i want to echo some images depending on the $id, however for me to get that id i

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