Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php - help - forms and info

Status
Not open for further replies.

barryturrell

Technical User
Oct 5, 2001
4
GB
Hello,

i am trying to make php read from a file and then give me a responce like : <number> <in/out>

The file it is reading from shall contain info such as:
123 in
124 out
125 out

So far i have a basic form:

<center>
<br>
<form method=&quot;post&quot; action=&quot;dosomething.php&quot;>
.:please Enter Video NumbeR:.
<br></br>
<input type=&quot;text&quot; name=&quot;.:Video NumbeR:.&quot; >
<br></br>
<input type=&quot;submit&quot; name=&quot;Press Here When Done&quot; value=&quot;.:SubmiT:.&quot;>
<br></br>
<input type=&quot;reset&quot; value=&quot;.:ReseT:.&quot;>
</center>

this will lead to &quot;dosomething.php&quot; but i need to eneter the number, eg 123, then when it opens dosomething.php i need it to gove me a reply, sof for 123 it would be a reply of &quot;In&quot;.

I will also need to write to the file containing the info.

If any1 can help it would be gratefully recieved.

Thank you
 
Hi Barry,

This sounds like a good place for a MySQL database (free by the way). With PHP and the DB, this application becomes much easier, though it can get more involved as you can add items to the pages, like ability to add/modify/delete videos, online reservation of movies and the like. This would change the pages that you have by needing a DB connection and some basic security. You should also divide the site into 2 areas, one accessable by everyone to check the availablilty of videos, sign up members; and the other limited access pages to add or change the information about videos.

The basic table would be
Movies
fields IDNumber(Unique DB Key), copyNumber (number), Available(boolean y/n(1/0),DVD(boolean),VHS(boolean),Title(text), Star(text)*, Catergory(ie SciFi,Drama,Comedy)(text)*

*optional search type catergories alows your user to pick videos of a certain star or genre.

Then you will need pages to insert new video, modify/delete video. You can take this as far as you want, online reservations, membership data....

You then use SQL to update the DB to reflect the movies availability, add new members, ohhh the possibilities are endless....
Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Thanx for the offer but i was really looking for a simple PHP solution, as this will end up being part of a school network.

Do u know how i could do it that way?
 
Hi Barry,

There really is no simple solution. The real issue for you is the ability to manipulate the data concerning the videos, ie availability. A DB of some kind is the easiest way to make this happen.

The other way to handle this is to write and read from a flat file, some kind of text file. This uses the FOpen method and a bunch of specifics depending on what you want to do. Data manipulation is more difficult with this but it can be done. You could try which has a few books on PHP or the PHP.net for more help. It is a bi lengthy for this.

The preferred method for me is to use a DB...

hth
Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Above suggestions are correct, this will be MUCH simpler, faster, and more reliable with a database, but if you must do it in a flat file... First take anything non-alphanumeric out of form field names and take out the spaces.

dosomething.php would look something like this (the guts of it anyway):

$reply = &quot;&quot;;
$arrFile = file(&quot;filename.txt&quot;);
$linecount = count($arrFile);
for ($i=0;$i<$linecount;$i++) {
$line = split(&quot; &quot;, $arrFile[$i]);
if (Trim($line[0]) == Trim($videoNumber)) {
$reply = Trim($line[1]);
break;
}
}
echo $reply;

You'll need to add some exception/error handling in there, but that should get you started.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top