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
9
Other forums
error help - Dynamic Image
I've been working on making my site less cluttered in the directories and more secure lately. In an
SQL Query/echo not working
Hey all,
I'm trying to run (what I thought) was a simple operation and it isn't working. I h
mysql timestamp manipulation
How could I use a timestamp (e.g 2009-10-30 13:20:35 ), and with php find out if it is:
from
Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :
preg-match with a string and numbers
Hi, I can't get the expression to work for my preg_match, what I'd like is for it to match the strin
Perplexing problem showing a .jpg
Please disregard..........I figured it out
Insert data in Mysql and move to another page
I'm stuck with this simple problem. I need to insert data in Mysql and then hit submit and move to a
PHP and Javascript
Hi Guys,
Im trying to load the contents of an html file into a text area for editing, this is
Executing an exe
Hi. I have some bizarre problem with exec (other any other method) to launch exe's. I am making a ga
Cache PHP Objects/Classes?
Does anyone have ideas about caching PHP objects using something like: http://memcached.org/