![]() |
php/forms/posting/I NEED HELP!!!!!!!!!
I want to put a comment/quotes page on my teams site, and let people submit their own, but I don't know anything about php or any other database. Can some one help me?
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
There are a few options. One is to use a free shoutbox type program. Another is to use php and log all of the comments to a text file. The last option is to use php and save it all to a database. The last will be the hardest to code but could allow for more features to be added. If i have any free tome today i will write you some sample code.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
CHeck out these links. http://www.project-angel.com/index.p...&cat=PHP&id=13 and http://www.project-angel.com/index.p...&cat=PHP&id=14 . Hopefully that will get you started. If you need any help just ask.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Could some one give me the code for the text file option.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Just to confirm what you want, you want a box that holds the posts of the shoutbox, under that you want a spot for people to input a nickname and message. Will that work for you? Also, do you know what version of php your webserver is running?
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Here is the server info:
![]() |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
And I would want it to look like this
http://www.khsfirst.com/insert.html for the submiting page, and http://www.khsfirst.com/Quotes.html for the pageit would show up on. |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
ya know, it would be a ton easier to just use a database.
if you have PHPmyAdmin, then use it. PHP Code:
columns should be AT LEAST: id INTEGER AUTO_INCREMENT, title VARCHAR(35), body TEXT adding news to the DB is a different story. |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Ya what is PHPmyAdmin? And how do I Use it?
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
The databases can be created without phpMyAdmin. I can write up some code for inputing data and createing the tables if you want me to. Also, can you find out if your webserver supports PHP and if so what version. If you cant find it, please post a link to the people who provide your hosting. EDIT: I wrote this up quickly so its not that great but it will work. PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
Oh by the way (correct me if I am wrong), I see a SQL injection vulnerability in your code. It's not as if it'll probably ever cause any real problems, it's just that it exists. PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
PHP Code:
I used to have a bunch of tutorials that i made about how to do this stuff. |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Yea, definatly fix that. I didnt really thing about security as i dont even know if he has PHP or if he is even going to use the code. If he is then with all SQL statements YOU MUST CHECK FOR INJECTION VULNERABILITIES. Its not cool. There are lots of features and fixes the code could use, i mean i wrote it quickly during class.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
By the way.. you're not the only one who likes to write things quickly during class. In history class I once wrote a simple math game (I was bored, don't ask).. although it didn't turn out all that great. |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
![]() |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
I looked at your webhost and they have PHP. Make a file called "junk.php" and in it write
PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
its version 4.3.4 heres the link
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Ok, thank you. If you have any questions setting it up just ask.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
I'll see if maybe I can write some code up for this later today. |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
On the WebRyders website is shows that all hosting plans come with a database. I wonder why you dont have any.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Maybe because its old and we probably got it for free.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Ok, if i were you i would see if you could get databases becuase they can be used for so much. If not, then use a text file.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
When it comes to this (text file) I have no clue what to do.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Basicly i would say this. Write each post to a line in the file. Use a "|" between the users name, email, post, post number, etc (whatever info you need saved). Then just read in each line, expode the string by "|". And then echo is out. Ill post some code shortly.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Well here's a simplistic example (I have tested it for about 45 seconds, it seems to work). It takes the quote submitted and writes HTML to a text file, and then on the quote view page all it does is read that text file and output all of the HTML in it.
I would also like to add that I haven't really put in any error handling yet for the most part (I've only been working on this for about 10 minutes). Anyway, here it is. insert.php - This allows the user to enter their quote. PHP Code:
PHP Code:
If you need any more help with this, don't hesitate to ask. |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
This code isnt very portable. Say they do a site resign all the posts would have to be manually redone becuase you saved all html and not just the pure data. I think that my way is more portable. Ill scrap together some code soon.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
PHP Code:
PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
I think XML would be a good storage method. Example: Code:
<quotes>Another option, I suppose, would be to use an INI-style storage method... though that could become problematic when new line characters are entered. This reminds me that in my previous code I failed to handle those by replacing them with <br /> .. along with doing a bunch of other cleaning that I would normally do, like check for JavaScript and deal with HTML entities. And that's where this whole thing can get much more complicated than it would normally need to be - security, user formatting features, ensuring HTML validation, etc.. This is what happens after using a database server like MySQL all the time. I'm having such a hard time trying to figure out a good, reliable storage method besides just dumping HTML into a file. |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Using XML would definatly open up more options but it means the data has to be parsed and i have only ever done a little XML and PHP together. As for the problem with using the "|" charcter there is a simple solution. The PHP explode function uses a string, just pick something nobody will ever uses suck as "a2ufjf94u". It might not look pretty in you data file but it will do the trick.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
Looks like using XML could actually work, but I haven't tried using this yet. If I'm not doing anything tommorow (and possibly later tonight) I think I may want to play around with that. Yay for learning (kind of) how to do new things. |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
The code from the last page works at http://www.khsfirst.com/insert.php , but it only records one message.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
and theres some extra stuufffffff at the bottom
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
On this line in insert.php: PHP Code:
I also noticed that there looks to be some RTF stuff in there.. did you create this file with Wordpad? You can probably just delete it, the script will recreate the file when a quote is submitted. As much as I don't want to admit it.. I actually did a pretty sloppy job on this. I will work on improving it sometime during this weekend. |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Might want to fix this http://www.khsfirst.com/quotes.php. Its looks like a mess. Also, the .dat is still being overwritten.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
where do i put quotes(" ") in the code so that they will show up around the quote on quotes.php?
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
and can i have a href in the part where it says "thanks, your quote has been submited", or have it automaticly rediect to the quotes.php page?
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
PHP Code:
Quote:
PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Every time a ( ' ) is used, like in I'm theres a slash to.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
PHP Code:
PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
yup that code worked, only two questions is there any way of limiting the words, not the amount, but like not allowing "$@#$@#$@#$@#" to be posted?
And, is there any way to send me an email that says there was a post? |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
woooooooooo, like what happened when i used a swear in the last post.
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
Here's an example of that (this should be in insert.php, before the fwrite() function call, but after the initial assignment of $write): PHP Code:
As for sending an email notification, add this in insert.php (right before the echo "Thanks.." line would be a good spot) PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
does the [beep] or whatever have to be in the brakets?
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
jk I SOLVED THE PROBLEM HECK YES!
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
but another question on the mailto, do i put
PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
Example: PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
really i just did it with
PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
whats the \r\n\r\n? |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
EDIT: Forgot to mention, the quotes inside of the string literal need to be escaped by preceding them with a \. PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
In most programming languages, when you want to add in the value of variable within a string of text, it must be concatenated with it, and not just within a string literal (everything inside the quotation marks) in order to be recognized. PHP picks up on the usage of variables inside of literals though, but I still like to use the concatenation operator. It's just a preference thing, really. |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Thank you, all of you for all of your help!
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
sry got another question, Will this work?( all of the second ones are the code ex. <-- !--> is " ! ")
$write = str_replace("!", "!", $write); $write = str_replace("$", "$", $write); $write = str_replace("&", "&", $write); $write = str_replace("'", "'", $write); $write = str_replace("(", "(", $write); $write = str_replace(")", ")", $write); $write = str_replace(",", ",", $write); $write = str_replace(";", ";", $write); $write = str_replace("?", "?", $write); $write = str_replace("^", "^", $write); And will two words work in a PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
Example: $bad_words = array('guy', 'dog', 'cat'); $good_words = array('male', 'canine', 'feline'); $write = str_replace($good_words, $bad_words, $write); |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
PHP Code:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
oh shoooooooooooot, all the str_replace s are case sensitive!!!!!!!!!!!!!!!!!!
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
Same thing as str_replace, but case insensitive. |
Re: php/forms/posting/I NEED HELP!!!!!!!!!
Quote:
|
Re: php/forms/posting/I NEED HELP!!!!!!!!!
ok so it works great, but now theres like 25 quotes. I want to make a second page so you dont have to scroll forever to get to the bottom. Do i have to make a new database or can i use the same one?
|
| All times are GMT -5. The time now is 22:59. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi