Hi guys, hope you can give me some direction here.
I'm hoping PHP can do all this, since it sounds like basic demands but before I do a crash course on PHP variables I'd like to verify it can do what I want.
An html form sends results to the script, script loads form results. Based on that data it takes a text file on the server and reformats it according to what the html form has requested.
To elaborate further:
Sample contents of html form:
a) Select a name: [ ] This is a text field
b) Select events to display: (1) (2) (3) These are checkbox selects
c) Select an option: (1) (2) This is a radio select
d) List some colors that you like: [ ] These are multiple text fields
SUBMIT sends this to script.php, which then:
- Loads the value of (Select a name) to string variable $NAME
- Sets each of the following variables to true or false (or on or off, or 0 or 1, etc) $EVENTS1, $EVENTS2, $EVENTS3 based on the values of checkbox 1, 2, and 3 in (Select events to display)
- Generates a variable for each value from (List some colors that you like) and creates an array
- Parses textfile.txt and based on the tags and markup in that file, rearranges the layout of the blocks, replaces variable keywords with form data, and prints it out to a file.
Sample contents of textfile.txt:
$NAME is a great guy! <<--- This would get parsed based on whatever the user put in the (Select a name) text field.
This is text that will always be displayed, I like many colors, one color I like is $COLORTHATILIKE. <<--- I need to be able to randomly pick one of the colors indicated on the HTML form and have it inserted into this variable.
((EVENT1)) This is event 1! This text will only be displayed if event 1 was checked in the form.((/EVENT1))
((EVENT2)) This is event 2! This text will only be displayed if event 2 was checked in the form. Furthermore, if EVENT1 was also checked in the form, the text in this section will be different. So within this block I need to be able to have an "IF EVENT1 WAS CHECKED THEN LOAD THIS PARAGRAPH AND IF EVENT1 WAS NOT CHECKED THEN LOAD THIS ALTERNATE PARAGRAPH"((/EVENT2))
((EVENT3)) This is event 3! This text will only be displayed if event 3 was checked in the form. If EVENT1 was also checked in the form, the text in this section will be different. To further complicate things, if EVENT2 was also checked in the form, the text in this section will be different still. So within this block I need to be able to have an "IF EVENT1 WAS CHECKED AND EVENT2 WAS NOT THEN LOAD THIS PARAGRAPH; IF EVENT1 WAS NOT CHECKED AND EVENT 2 WAS CHECKED, THEN LOAD THIS ALTERNATE PARAGRAPH AND IF BOTH EVENT1 AND EVENT2 WERE CHECKED, LOAD THIS ALTERNATE PARAGRAPH"((/EVENT3))
Finally, I want to be able to take the finalized text file that is generated by the script, and have it run through a CSS style sheet, and have it emailed to me.
If PHP can do this, I'd appreciate some general direction in the approach I should take in regards to best practices, security and accessibility. As I said, I will definitely do the research and coding myself, but I'd feel much better knowing the approach I'm taking is the proper one.