PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 13th, 2002, 06:03 AM
harsha harsha is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: india
Posts: 17 harsha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to harsha
file handling help

i have stored data in a text file "data.txt" and i want to search a email address
form that file can i do like this

$filename="data.txt";
$fptr=fopen($filename,"r");
$content=fread($fptr,filesize ($filename));
fclose($fptr);
if(strstr($content,$email))
{
echo <<< THIS
<font color="red" size="+2" face="verdana">
You have already signed the guestbook
</font>
THIS;

will this work or there is any thing to be added or deleted

Reply With Quote
  #2  
Old July 13th, 2002, 06:12 AM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: file handling help

well i dont really know much about text files, but i'm thinkin it would be easier to use a database if you can get your hands on one.

Once again, not knowing much about text files, but from the looks of it, that doesnt even search the text file for an email address, it just opens it and reads the contents, theres no comparisons like i think you would need to do.

Reply With Quote
  #3  
Old July 13th, 2002, 07:55 AM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: file handling help



i'm not sure whether what you're trying will work or not harsha. interesting approach either way, i might take the following route
php Code:
Original - php Code
  1.  
  2. <?php
  3.  
  4. $cheese = file("data.txt");
  5. if(array_search($email, $cheese) != FALSE)
  6. {
  7.     echo "you've got e-mail";
  8. }
  9.  
  10. ?>

Note: Prior to PHP 4.2.0, array_search() returns NULL on failure instead of FALSE.

Reply With Quote
  #4  
Old July 13th, 2002, 08:11 AM
harsha harsha is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: india
Posts: 17 harsha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to harsha
RE: file handling help

mr D1NGO

i know that it is easier to code using database but it is life if every thing goes smoothly what is the use there should be some difficulties like here using text files then only we get experience in coding
hope you understood

Reply With Quote
  #5  
Old July 13th, 2002, 08:26 AM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: file handling help

yes that is true harsha, although, when trying to solve a problem, finding a solution is not good enough, its all about finding the best solution.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > file handling help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway