Jump to content

Web coding advise on how to have a user input text and have it save and be displayed in a browser(Like a review for a product)

Just like many sites have "reviews" on products/services where a user can have an input box to type text, then that text is saved and displayed on the page.... 

 

Any advise on how I could achieve this using a web language.. html, php, javascript, etc.

Link to comment
Share on other sites

Link to post
Share on other sites

Like a comment box , then which applyed moves into a comment section?

|Casual Rig| CPU: i5-6600k |MoBo: ROG Gene  |GPU: Asus 670 Direct CU2 |RAM: RipJaws 2400MHz 2x8GB DDR4 |Heatsink: H100i |Boot Drive: Samsung Evo SSD 240GB|Chassis:BitFenix Prodigy |Peripherals| Keyboard:DasKeyboard, Cherry MX Blue Switches,|Mouse: Corsair M40

|Server Specs| CPU: i7-3770k [OC'd @ 4.1GHz] |MoBo: Sabertooth Z77 |RAM: Corsair Vengeance 1600MHz 2x8GB |Boot Drive: Samsung 840 SSD 128GB|Storage Drive: 4 WD 3TB Red Drives Raid 5 |Chassis:Corsair 600t 

Link to comment
Share on other sites

Link to post
Share on other sites

Correct, basically like how this forum we are on is working right now... but without adding complications of user accounts and so forth.   

Link to comment
Share on other sites

Link to post
Share on other sites

Well you would use HTML and JavaScript. Give the user a text box, then create a variable and use document.getElementById("InsertTextBoxIDHere").value to give the variable the value of what they had entered into the text box and then use document.write(Variable) to insert it into the HTML.

 

Not sure if that is what you where wanting to do though. 

 

Where you asking on how to do it?

Link to comment
Share on other sites

Link to post
Share on other sites

I don't know whether you are going to use a database, but you can save text in a database by making a 'text' attribute. You can then make a table with a product ID as the primary key, and then with the text as a second attribute.

Link to comment
Share on other sites

Link to post
Share on other sites

Well you would use HTML and JavaScript. Give the user a text box, then create a variable and use document.getElementById("InsertTextBoxIDHere").value to give the variable the value of what they had entered into the text box and then use document.write(Variable) to insert it into the HTML.

 

Not sure if that is what you where wanting to do though. 

 

Where you asking on how to do it?

 

Sounds like something I want to do....

 

I don't know whether you are going to use a database, but you can save text in a database by making a 'text' attribute. You can then make a table with a product ID as the primary key, and then with the text as a second attribute.

 

I don't plan on using a database. I'm not fully sure how it will save to the server... thats mostly my problem I guess. I don't know if I should have the user input text saved to a .txt file then have the page somehow know to find it and display it in the page...

Link to comment
Share on other sites

Link to post
Share on other sites

I don't plan on using a database. I'm not fully sure how it will save to the server... thats mostly my problem I guess. I don't know if I should have the user input text saved to a .txt file then have the page somehow know to find it and display it in the page...

There's no real way to do this without using some kind of database.

 

You could get the string and write it into an XML file, along with any other information needed. It would work for a small amount of information only, since you need to load the entire XML file into memory to access info. XML parsers are pretty easy to find.

Link to comment
Share on other sites

Link to post
Share on other sites

There's no real way to do this without using some kind of database.

 

You could get the string and write it into an XML file, along with any other information needed. It would work for a small amount of information only, since you need to load the entire XML file into memory to access info. XML parsers are pretty easy to find.

 

If I can code it right, storing as an XML file sounds like it could work. There would probably be only 10-15 text entries max on the page. Thank you for the idea

Link to comment
Share on other sites

Link to post
Share on other sites

Ruby on Rails can do that it doesn't save the entries in XML but it will save them it also will build the basic site framework here is a link to a project I did for a class, It has mutiple database tables and users have to sign in with passwords being encrypted.  To run ruby on rails needs to be installed (it is free and open source) http://inft.ly/35q5CGp

 

Link to comment
Share on other sites

Link to post
Share on other sites

If I can code it right, storing as an XML file sounds like it could work. There would probably be only 10-15 text entries max on the page. Thank you for the idea

 

Why would you want to? Don't you have multiple pages each containing 10-15 text entires per page? 

 

If that's the case I would strongly suggest you get a hosting / development enviroment with a database engine installed. PHP, Ruby, C#, Java are not built to save things. They are ment to calculate and execute actions, not remember things. If a MySQL database or something is not done you could see if you could get SQLite to work which also stores in a file (how ever it is a fully fledged database engine).

If database really are not an option you have multiple ways of doing it. Depening on what you got available in terms of programming skills and programming languages installed on your hosting. You could always use LoneRanger's suggestion and use JavaScript, this removes the need for any programming languages to be installed as JavaScript runs in the browser. This how ever is super sensitive to hacking so I'd advise using a server sided programming language like PHP.

 

However, if you do want to know more on JavaScript and XML check out this link here. It's a W3Schools section on JavaScript + XML. You can use that if you want to. For PHP just Google "PHP and XML" and you'll find lots of help on the subject.

Intel Core i5 2500K @ 3.30GHz MSI Radeon R9 290 Gaming 4G | Asus P8H61-M Evo Rev B Kingston ValueRAM KVR1333D3N9K2/8G Scythe Mugen 2 Rev. B Samsung 840 Evo 512GB Seagate Barracude 7200.12 ST3500413AS, 500GB Samsung Spinpoint 1TB 5400RPM OCZ ZS Series 650W Cooler Master Elite 430 Windowed Logitech LS21 Creative Fatal1ty Logitech G500 Razer BlackWidow 2010 | 2x Dell U1214H | 1x Ilyama ProLite E2407HDS
Link to comment
Share on other sites

Link to post
Share on other sites

Don't use PHP, due to it being a disgusting joke language.

 

I recommend Python, perhaps the Bottle framework.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×