|Dec 5, 2007, 01:37 PM||#1|
Adding to an .inc File Through a Web Form
How can this be done!?
I have downloaded the Cj Random Quote php script, which takes a line randomly from a .inc file.
What I want to do is allow users to add their own 'quotes' through a web form. However I have no experience in this field (I know CSS and html fairly well, but no server/forms knowledge), and would like to know the easiest way to perform this task, or be directed to a tutorial (as I can't find one personally). Or if there are alternatives, I would be interested.
|Dec 5, 2007, 07:59 PM||#2|
It's hard to give a direct answer without knowing how that quote script works etc. I would recommend opening up the text file in which the quotes are stored and taking a look at the structure. Your goal is to get user input from an HTML form and append it to that file using PHP - manipulating it into the necessary structure beforehand. Take a look at the PHP file functions - fopen(), fwrite(), etc.
Be careful to sanitize user input. Use functions like substr() to limit length to X characters, and perhaps limit the frequency at which a user can submit a quote using PHP sessions.
|Dec 7, 2007, 01:18 PM||#4|
I'm going to expand a little on the excellent advice already given, to summarize it all for you:
It sounds like a flat file (a simple text file, the .inc file mentioned) stores quotes and is loaded into memory, one line (quote) is pulled at random and included in the output. This is how standard taglines work.
Of course to add quotes to that .inc file involves:
1) knowing how the .inc file is structured (are there special characters or separators to distinguish one quote from another, or simply a newlines?)
2) the full path must be known and permissions for read/write set properly
So if you need some coding help, we need to know the answer to each unknown listed above and that you can do #2 on your own.
In a nutshell it all works like this:
A form on your page is filled in and submitted by the user. The form calls a PHP script on your server that processes the user input (a quote of some sort), locks then opens the .inc file, appends the user's quote on the end (or beginning), unlocks and writes.
Please supply what you can, or hire a pro (not me, sorry, too busy) if the basic concepts I explained are not within your experience level. If you do, consider asking the pro if using a database method is more efficient in the long run. Using flat files to randomly pick out content is not efficient once the file gets large depending on your site activity. Not to mention wouldn't it be prudent to permit users (or an admin) to remove their submitted quotes as well?
Sr. Web Developer, owner GoldTechPro, LLC
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|How to stream mkv files through MBP||vtokmak||Apple TV and Home Theater||1||Oct 10, 2010 09:58 PM|
|Is it safe to download files through a web proxy?||ItDoesntMatter||Mac Basics and Help||6||Aug 14, 2009 09:51 AM|
|Adding to an existing itunes folder on external Hard drive?||cherrybomb||Mac Applications and Mac App Store||1||Jan 15, 2009 03:06 PM|
|Best way to transfer large file over the web||techlover828||Mac Basics and Help||12||Jul 24, 2008 09:04 AM|
|Adding to an mp3 using GarageBand||bodieq||OS X||1||Jun 16, 2006 06:18 PM|
All times are GMT -5. The time now is 07:15 PM.