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

New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understan

Help a newbee save my job !
Hey guys i am dying here i am new to php and would like for someone to help me with this problem

Reading Most Recent CSV File in Directory
I thought I had wrapped this project up, but found out that the program I use to FTP a csv file to m

Ten Operator Syntax
Hi Guys,

I can't figure out why i am getting a parse error with this basic ten op code:

Sales orders ans reservations not taken into account on MPS / MRP
Hello,

I am implementing the MPS / MRP and I have the following problem:

I ha

All possible combinations of Strings from table in PL/SQL
Hi,

I am trying to figure out how to build a list of all possible string combinations fro

Strange php code found on my website
I got hacked and the following code was placed within my files:

Code: [Select]<?
/*

Not Inserting into DB
I can't get my Add new Division form to submit to the database. Anyone see my issue?

Code: &a

Need help urgant
why down my code ony return one item instead of all the items selected.

$arr = array($date,$

I apologise! It's a newbie to PHP feedback form problem!
Hi,

I am a total newbie to PHP. I am also a unemployed and need to get a job. So after 100% r

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