1
34 points at
74%
Posted June 23 '09 at 02:43 PM
Posts: 787
looking for suggestions to automatically update a page when data is added to the file in question.
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.” Albert Einstein
Advertisement
Register for free to hide these ads and participate in discussions!
2
1,251 points at
99%
Posted June 23 '09 at 03:37 PM
Posts: 3,100
What is the file in question?
If it's zero degrees outside today, and it's supposed to be twice as cold tomorrow, how cold is it going to be?
3
34 points at
74%
Posted June 23 '09 at 04:05 PM
Posts: 787
suppose you have a site for a caffe that wants to take orders online. the form send it to a file that is included in an interface for the servers to get the orders. you could of course refresh the page manually, but this is not efficient. how could the be done automatically when new orders are placed.
sorry for the bad spelling i have a hang over
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.” Albert Einstein
Last edited June 23 '09 at 05:12 PM by Wired ("merged posts").
Reply
4
32 points at
100%
Posted June 23 '09 at 05:55 PM
Posts: 76
Check out hostscripts.com Dorky. I'm sure you'll find what you need there pre-made and free.
If you can't let me know I can probably put something together for you pretty quick.
Lead Web Designer
MLW & Associates, LLP.
W3C Standards Complaint and SEO Friendly
Admin of Vraul
5
34 points at
74%
Posted June 23 '09 at 06:34 PM
Posts: 787
as cool as the offer is im actually more interested in learning how to do it. ie.. give a fish vs teach to fish.
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.” Albert Einstein
6
32 points at
100%
Posted June 23 '09 at 06:38 PM
Posts: 76
Well first of all, I wouldn't be allowing anyone to add anything to file (HUGE security issues)... Instead I would let them insert it into a database and query from the database when you request the page. That is not too hard to do... but if you're set on file editing; you'll need to read up on fopen on php.net.
Again though the best way to go is databasing it and its pretty simplistic to do considering..
Insert your orders into the orders table and loop out those orders on a separate page.
Lead Web Designer
MLW & Associates, LLP.
W3C Standards Complaint and SEO Friendly
Admin of Vraul
7
34 points at
74%
Posted June 23 '09 at 06:52 PM
Posts: 787
lol no i know how to create ad to and delete files and working on securing them. what im looking for is real time display of the added info. and sql injections are more of a risk then anything.
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.” Albert Einstein
8
34 points at
74%
Posted June 23 '09 at 06:53 PM
Posts: 787
thx again for the help and future help by the way.
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.” Albert Einstein
9
32 points at
100%
Posted June 23 '09 at 06:59 PM
Posts: 76
No they're not
mysql_real_escape_string($_POST['your_field'])
Nullifies SQL injections =)
Look at it like this; when someone types in a username box:
admin
The MySQL query looks something like:
"SELECT * FROM `users` WHERE `user_name`='" . $_POST['username'] . "' AND `user_pass`='". $_POST['password'] ."'"
Ok so if I enter for password,
Would make the query look like:
"SELECT * FROM `users` WHERE `user_name`='" . $_POST['username'] . "' AND `user_pass`='testbe' OR `user_id`='1'"
That is a simple SQL injection that would access the user_id of 1, which is usually the admin of the site.
Ok so now, adding....
"SELECT * FROM `users` WHERE `user_name`='" . mysql_real_escape_string($_POST['username']) . "' AND `user_pass`='". mysql_real_escape_string($_POST['password']) ."'"
Would now change any 's or "s in the post data to MySQL safe strings making it so that SQL injections are completely impossible =).
Hope that helps!
Lead Web Designer
MLW & Associates, LLP.
W3C Standards Complaint and SEO Friendly
Admin of Vraul
10
34 points at
74%
Posted June 23 '09 at 07:15 PM
Posts: 787
not so much, i have a much larger protection script and im not realy looking for another. im looking to update a web page in real time with data added to the file in question.
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.” Albert Einstein
11
32 points at
100%
Posted June 23 '09 at 07:17 PM
Posts: 76
Then I'd utilize fopen then... basically open the file thats been updated and pull out specific information. Doing a little research into PHP SOAP will be helpful as well.
Lead Web Designer
MLW & Associates, LLP.
W3C Standards Complaint and SEO Friendly
Admin of Vraul
12
34 points at
74%
Posted June 23 '09 at 07:17 PM
Posts: 787
ml the file would be whatever. the idea is to update a web page in real time with the data added to said file.
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.” Albert Einstein
13
34 points at
74%
Posted June 23 '09 at 07:18 PM
Posts: 787
im not really sure there is any other way to word this question.
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.” Albert Einstein
14
1,251 points at
99%
Posted June 23 '09 at 11:00 PM
Posts: 3,100
Dorky ...
You would use MySQL.
And it's not a big deal with "injections".
On the user's end, it would be like a catalog where they see the
photos of the different items (like a menu) and they simply click.
You could even do a drag and drop thing using AJAX.
They enter a phone number or some sort of ID and the items they
want are written to the database, with a unique ID, their ID, a timestamp, items, etc.
On the Caffe's end, they have a browser running that refreshes every minute.
Items (new, recent) pop-up on top and the others are pushed down. As the orders
are filled, the employee(s) simply check them off. The page that is viewed at the Caffe
only appears on their PC because they are logged in as "admin".
People at the Caffe, using their laptops, could actually order from their table.
The place is a Caffe, not Wells Fargo Bank. You should use this project to learn about
MySQL and actually experience how it works. There's no need to worry about security
issues any further than escaping strings.
This would be a great first project for MySQL, and you'll be a changed man afterwards.
If it's zero degrees outside today, and it's supposed to be twice as cold tomorrow, how cold is it going to be?
15
34 points at
74%
Posted June 24 '09 at 02:38 AM
Posts: 787
thx ml. i am actually already using mysql so its not fear of it that causes my decision to use files. i tried the refresh bit but not with the new entry in the top slot. if you could point me in the direction of how to make entries to a file in reverse order that would be the ticket. and its not for a project so to speak just yet. i have been talking with local biz owners the last couple of days and want not to look like an a$$ when i start talking to whoever. so im just trying to get a good hold on php.
mysql is actualy pretty simple. not a lot of commands to remember or work with, not that im an sql expert but its not as hard as php. a local designer has angered a lot of folks and as long as i dont look foolish i should be able to take his accounts. this is some of his fine work
http://coastersfwb.com/gallery.html
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.” Albert Einstein
16
345 points at
100%
Wired, Admin and WDF Alien Overlord
Home page
Private message
Posted June 24 '09 at 03:22 AM
Posts: 6,275
if you could point me in the direction of how to make entries to a file in reverse order that would be the ticket.
If you want the info refreshed live, a javascript refresh would be best. An AJAX display would make it seamless (e.g. no refresh flicker). As for your quote above, if you're grabbing info from the database, just call the order DESC versus ASC, or vice versa depending on what you're doing.
On the other hand, you may want to see if a free commerce tool like
osCommerce has a back end built in like what you want to do. While it's great learning how to code new ideas, if someone has a free complete package that can do the same job, I'd go with that. It means you can do the job quicker and cheaper, and the customer is always happy about that.
Admin at
houseofhelp.com
WDF Resources:
The Rules
Founder/Creator/Admin of
ZE SECRET PROJECT!
Was another WDF member's post helpful? Click the positive rating button (

) above the post.
17
1,251 points at
99%
Posted June 24 '09 at 09:19 AM
Posts: 3,100
Dorky,
Each entry into the database can be given a unique ID number ... that is incremented
automatically. Along with that, save one field as a UNIX timestamp. That is also
sortable, and gives the exact time the record was written .... you format that UNIX time
when you display the item (date, hour, minute, etc).
I didn't know osCommerce can do something similar to your Caffe idea ...
that's something to look into. It could save you a lot of time.
If it's zero degrees outside today, and it's supposed to be twice as cold tomorrow, how cold is it going to be?
18
32 points at
100%
Posted June 24 '09 at 09:22 AM
Posts: 76
Dorky,
Each entry into the database can be given a unique ID number ... that is incremented
automatically. Along with that, save one field as a UNIX timestamp. That is also
sortable, and gives the exact time the record was written .... you format that UNIX time
when you display the item (date, hour, minute, etc).
I didn't know osCommerce can do something similar to your Caffe idea ...
that's something to look into. It could save you a lot of time.
Heck, you can even
microtime() it
But yeah, learn MySQL/PHP and in 2 months or less you'll be thanking us profusely for nudging you in that direction =)
Lead Web Designer
MLW & Associates, LLP.
W3C Standards Complaint and SEO Friendly
Admin of Vraul
Last edited June 24 '09 at 09:26 AM by Danny[MLWA].
Reply
19
34 points at
74%
Posted June 24 '09 at 11:35 AM
Posts: 787
omg lol i know mysql and how to use it by php. i use it for my log in and have the php & mysql for dummies. not trying to be stiff but none of this helps with printing new entrys to the top not bottom of a html or php file. i know how to meta refresh. keep in mind this is an excersise in php not mysql. the mysql i dont need practice with the php i do, thats the point of this excersize. please please gentalmen, help!
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.” Albert Einstein
20
32 points at
100%
Posted June 24 '09 at 03:35 PM
Posts: 76
This does the same thing but much more effectively, quicker, and much much more secure.
echo(showOrder($_REQUEST['show']));
function showOrder($limit)
{
$html = NULL;
$query = ("SELECT * FROM `orders` ORDER BY `time` ASC LIMIT " . $limit);
while($orders = mysql_fetch_array(mysql_query($query)))
{
$html .= ('
Order Number: ' . $orders['order_id'] . '
Name: '. $orders['order_name'] .'
IP: '. $orders['order_ip'] .'
');
}
return $html;
}
Lead Web Designer
MLW & Associates, LLP.
W3C Standards Complaint and SEO Friendly
Admin of Vraul
21
1,251 points at
99%
Posted June 24 '09 at 03:36 PM
Posts: 3,100
Open the MySQL account,
Read all entries for the table you are using, sort by DESC order.
We can't see what the name of your table is, or the name of your ID variable,
otherwise we could display an exact MySQL query example.
The query result is placed into an array and you can display that dynamically
on a page with auto refresh, every 1 minute.
You connect to MySQL,
query the table,
close MySQL,
display results,
wait one minute,
repeat.
Anytime in between, when the Caffe employee clicks on one of the entries
showing, it will remove it from the table (using another PHP script).
Order has been filled ... (remove from table, return back to the display page).
PHP/MySQL tutorials show how to query table and display results.
If it's zero degrees outside today, and it's supposed to be twice as cold tomorrow, how cold is it going to be?
22
34 points at
74%
Posted June 24 '09 at 03:55 PM
Posts: 787
ok i see why you both recommend db is because the "order by" command. is there a similar way to do this when writing to or reading from a file. if not its cool i can go the sql route if need be but i thought this would be a great way to tighten up on php. hard projects are the best way to learn. i will keep googleing and checking back here, im sure there is a way. the manner in which data is writen to and read from can be used in many aplications beond what i have suggested, such as custom site manager aplications and adding immages to article by the customer in the placement order they choose.
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.” Albert Einstein
23
1,251 points at
99%
Posted June 24 '09 at 04:08 PM
Posts: 3,100
If you don't want to use MySQL, you could use a simple flat-file text database.
Your entries are like this in a text file (perhaps you call it "coffee.txt" or "coffee.db" )
It doesn't matter what you call it, it's just a text file with fields separated by pipes.
43243243|espresso|651-555-5654|John Smith
89789987|Latte|612-555-5433|Bill Anderson
You load all lines into an array and sort the array by the timestamp (first field).
When the user orders a coffee, it appends their line to the text file.
No MySQL needed, just some file reads and writes.
EDIT:
You say you know MySQL, but we're trying to figure out why MySQL would be
used without PHP, C++ or some other programming language. If you know MySQL,
would it not be a good assumption to think you know how to use it with PHP?
There are many tutorials (for free) ... use Google to find them:
http://www.google.com/search?q=php+mysql+tutorial
I feel like I'm missing your questions ... and I apologize that I don't quite get it.
.
If it's zero degrees outside today, and it's supposed to be twice as cold tomorrow, how cold is it going to be?
Last edited June 24 '09 at 04:11 PM by mlseim.
Reply
24
34 points at
74%
Posted June 24 '09 at 04:16 PM
Posts: 787
sweet ok i have heard of flat file but i didnt know what that was till now. thx ml im on the right track now. i have to get to work in a bit but tonight i will do just that and play with sorting, i still am not sure how to call the newest to the top but im sure i will figure it out. thx a billion for all the help you two. im a cook by the way lol. for now anyway. if you are ever in fort walton florida send me an email. ill by your dinner at wherever im cooking at the time.
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.” Albert Einstein
25
345 points at
100%
Wired, Admin and WDF Alien Overlord
Home page
Private message
Posted June 24 '09 at 05:25 PM
Posts: 6,275
FYI look up Pagination. That may help you out.
Admin at
houseofhelp.com
WDF Resources:
The Rules
Founder/Creator/Admin of
ZE SECRET PROJECT!
Was another WDF member's post helpful? Click the positive rating button (

) above the post.