Comment if this PHP plan sounds like it will work

The goal: Solution for processing not “required fields” which are, for lack of better term, “soft required”. When the form is submited, and required fields are OK, there is a soft-require check asking the user “Are you sure you don’t want the undercoating?”

How I plan to do it: Three pages. (1) the user form, (2) “thank you for submitting”, and (3) “soft require” confirmation (ok, submits and goes page 2; cancel, returns to page 1. I’m thinking where “soft require” is triggered, to forward the form’s contents in _POST from page 1 to page 3, ask for confirm and then duplicate in php page 1’s mysql query to save the data, and redirect to page 2.

Does this confrom to best practice for form data with security of the form contents?

It has nothing to do with Ajax. Consider this psuedo code:


if form_is_valid
  if !optional_fields_ and !confirm_field
    display_the_form_with_confirm
  else
    do_something_useful
else
display_the_form

I’m getting there. Let me see if I get this.

  1. The form displays blank with submit.
  2. User fills out and submits form, with server[‘php_self’]…
  3. There is somefin like this in the form controller,
    [COLOR=“Red”]If $validation && !$undercoating {

//display form with “confirm” button

}[/COLOR]
4) else normal submit, do the mysql_query INSERT, etc…
eh. That’s kewl. If you can be sure the user gets that the submit button has changed. And If you highlight the bottom of the form with a changed background color. And add the message “Are you sure?”. Most users who see a form presented back to them is usually gonna look for errors…
And the more I think about it the changing of the submit to confirm at the bottom of the form is a real “PHP-Solution”.
I like the idea. Cheers!
C

>If it’s not present then redisplay the page this time including the hidden field
>(plus the “are you sure” message).
I don’t want to slow anyone down if they fill out the form correctly the first time. Besides, I like to make PHP do my bidding (insert Dr. Evil maniacal laugh)

>I think those fields are typically refered to as ‘optional’ fields. :stuck_out_tongue:
I don’t know how to respond because you’ve gotten the joke and made a good question, are these optional? hmm. The type of field I’m thinking of is between “optional” and “required”. Here’s the scenario. This optional or soft-require is a sign up mailing list option on the form. I want people to sign up for a mailing list, and I want their feedback as well. I’m believe I’m constructing a statement through the stats saying there are x% who are compelled to comment on my content, and z% who want to follow my content. I’m pushing the sign up, but its not required.

>I would rely on a postback and invalidate the fields as required,
I’m not familiar with the term “postback” its not in wikipedia and google only references postback event in .ASP, but I can find no explanation of what this is supposed to do. I gather from the name it has something to do with POST variable?

>pass along a token to indicate the next POST should ignore optional fields.
Next? I’m lost. Will you explain this?

What you are talking about sounds like an Ajax form field based on a previous option’s selection. Something like:

  1. “Choose State” pull-down with the “hidden token” pull-down, “Choose City”.
  2. Once a state is selected, then the pull-down, “Choose Cities”, is displayed on the form populated with the cities in that state.
    …Yes?

Sounds good, but this is not my form. Imagine my form as three fields,
A) “Choose Car*” pull down.
B) “Do you want the optional undercoating? ($50)” checkbox
C) Submit.

  1. The user submits the form. The car choice is required, and if not selected, the form validation will trigger an error message giving the user one choice: go back.
  2. If you choose a car AND do not choose the undercoating, a new screen will give you two choices: “Hey. cheapskate! Press back”, OR “What-ever”.

I thought to use POST to suspend the data from page to page. Then submit to the MYSQL database on page one or three.

I gather, since no one has said it was “bad”, its worth the time to try to develop it…
Chris

I think those fields are typically refered to as ‘optional’ fields. :stuck_out_tongue:

There are many ways you could implement something like that, I would rely on a postback and invalidate the fields as required, pass along a token to indicate the next POST should ignore optional fields.

Cheers,
Alex

I think PCSpectra an myself are really describing the same idea. When the form is first displayed, it will not contain a hidden field (the “token”). After it’s submitted, the PHP code checks if that field exists (and of course if the optional fields have been filled in). If not then the form is redisplayed, this time with the additional hidden field added to the form.

Sounds like a job for Javascript. I would just live with the fact that people who have it disabled don’t get this functionality (it doesn’t sound critical anyway). Of course the non-required field data should still be validated on the server side.

If you don’t want to go down that route, you could just check for the presence of a (hidden) “confirm” field when page 1 is submitted. If it’s not present then redisplay the page this time including the hidden field (plus the “are you sure” message). Certainly better than duplicating code.