![]() |
Creating a guest book
Hello there,
Some one mentioned that I created a guest book to improve my PHP skills, I thought this was a really good idea and took on the challenge! Unfortunately I don't think I have the skills right now to be able to create one, but here's what I've done so far: Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"Code:
<?Thanks, Steven |
Store your information in a database. I'd somewhat explain this, but I'm off to the pub soon and don't have time :-P
Look up tutorials on how to store values into a database. |
If I where writing a guestbook script, it would probably flow something like the following:
Code:
1. Display guestbook to userAlan |
Quote:
|
I've wrote this PHP:
Code:
<? |
You'll want to escape that data with mysql_real_escape_string
|
Quote:
If you have a username and password, then you need to enter that in, otherwise username and password variables can be null |
Don't take up too much work at one time. ("Don't bite off more than you can chew")
I've learned from experience that if you take bite off more than you can chew, you'll end up not finishing the work or dropping it all together. Make readable, tidy scripts. Use spaces, enters, tabs and more important, invent your own style. Things like securing your scripts is something that you'll learn later on, but it's a good way to start. One other thing hat you can do, is simply follow a LOT of tutorials or download pre-made guestbooks and try to rescript yours from scratch, using what you have learned from the other scripts. I made it on the go, I haven't tested it, I haven't payed that much attention (chatting with girls, you know the drill) but I wish you luck. If you find a bug, try to fix it yourself, otherwise, just post it! Apologies in that case. PHP Code:
|
U can save those comments into a txt fail, its easier then inserting data to mysql database.
Just use: fopen; fwrite; fclose; and then include that txt fail on that page where u want those comments. |
karg, you could use flat file storage, but then you'd run into a bunch of security problems and it's generally a pain in the ass
Using a database, although maybe a little more difficult(debatable?), is good for the long run and is a must-know for any PHP developer. |
Quote:
ReSpawN: Thank you ever so much for doing that. I can see I had the logic sorted out (I think), but had some syntax wrong. When setting variables, you've used: addslashes, urlencode and [i]htmlentities[/I. I haven't actually used them before and I'll need to look up what each of them do. I'll have a play around with it and see what I can come up with! |
It works!
Code:
<?phpI was also wondering if someone could explain this: Code:
<?i=0 so while (0 is less than $num (the number of rows in the query) then display the next set of variables. I don't understand how "i" can ever become less than "$num". |
mysql_result is deprecated, no need for it.
|
When I delete mysql_result from
Code:
<? |
We need to use the function tags more..
array_splice |
Quote:
|
Quote:
Quote:
|
Quote:
PHP Code:
|
Whoa wait: side note
mysql_result is deprecated?! what replaced it? and when? wow where have I been... |
mysql_result() isn't officially depreciated as far as I know.
Alan |
| All times are GMT. The time now is 06:53 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0