Sorta Mad-Libs: How difficult to accomplish in PHP?

Okay it’s not really Mad-Libs, which for you youngsters out there, was a series of books with page-long stories that had blanks where important words would normally go. One person read the story and asked a friend, “name a noun, a verb, an adverb, another adverb, another verb…” and so on. Then the random words were inserted into the story and hilarity ensued.

Well, I’d kinda like to have the same process on a website. The idea would be:

  1. On the back end, ideally pulled from a MySQL database but it could just be pre-written PHP pages, I set up a few story templates with variables that would be replaced by user entries. The story templates might vary between “Mystery” “Romance” “Western” or whatever.

  2. On the website itself, a visitor selects one of the story types, then fills in a form with certain prompts (“Enter a thing you hate eating,” “Enter your first name,” or whatever). Once the form is submitted…

  3. The info is sent to the database (the reason why it needs to be stored will become apparent), and…

  4. The visitor is redirected to the correct predetermined story template, with the variables now correctly filled in with the user’s data.

*Optional:*5a. The user can now choose a different story type and their original data is now transferred to the matching template. This is why the data needs to be stored somewhere. Also…

5b. Finally, the visitor should be able to send these completed ‘stories’ to him/herself or a friend via email.

My question to any PHP experts is: How difficult/complex a process is this? I know there are some existing PHP classes set up for Mad-Libs-type games, some even open-source. So it can’t be too onerous. But I know some of the things I’m asking are not out-of-the-box (the email part, the different story part, etc.).

I’m sort of in the process of hiring someone to fulfill this for me and I’d like to be marginally aware of how lengthy / difficult a process this is, and whether I’m even describing it correctly. Thoughts?

It’s trivial, assuming you’ve got a box set up with PHP (or whatever) and MySQL (or whatever) already running. Anybody who quotes you more than a couple days to put it together (not including final touches like the visual design) probably doesn’t know what they’re doing.

The hardest part would be writing multiple story templates that could have the same data plugged into them. But that’s an art problem, not technology.

Oh that’s good to hear, thank you friedo and Chronos. Yes, the stories would be pretty easy for me to whip up, it’s the coding that’s over my head. (To a degree; I can look at PHP code and get the gist of what’s going on, and can often tweak things when given some directions, but coming up with it out of the blue is beyond me.)

No need to reinvent the wheel:
[ul]
[li]http://sourceforge.net/projects/phpml/[/li][li]https://github.com/nikorablin/MadLibs-PHP[/li][/ul]

Oh wow, thank you so much, Duckster. And these are both open source so they’re customizable. (Tents hands like Mr. Burns…) Excellent!