If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

What is unclear to me, is how can I apply the above value-comparison concept and still submit my form data to my server-side form_mailer.php. Without using submit (to itself) to validate the 'captcha' value to = the 'code'?

I have tried to read/display the value of the $_SESSION['captcha'] (its a 4 digit number) but nothing I do with Echo displays the value. I think if I (could read/display) this value I could validate the code on the fly.

A followup question involving ? echo $PHP_SELF ?

Using this session variable method in the web browser, and submitting to the same form, how would one pass the actual form data back to the server side?

To clearly understand the sequence of events, could not a Validate button be used to submit the Captcha code for validation, and a Submit form button be separate to submit form data to the server-side?

Should work if you remember to do a session_start() as the first thing on the PHP script that processes the form submission. It can then just validate the captcha value against that stored in the $_SESSION array. If invalid, the trick here is to then redisplay the original form with all the other fields already populated with the user's previous inputs, but probably regenerating the captcha value and saving that in $_SESSION (so that the redisplayed form uses a new captcha image/value).

All that is probably most easily managed via a single-page approach: one page that has conditional processing based on whether or not there is $_GET/$_POST data that indicates a form is being submitted, with branches based on validation results and submission results, and so forth. That way, if you need to redisplay the form, you already have the prior inputs in $_GET or $_POST.

"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation

one page that has conditional processing based on whether or not there is $_GET/$_POST data that indicates a form is being submitted, with branches based on validation results and submission results, and so forth

if (form is submitted)
if (form is valid)
process form
display success page
else
display form page with error messages and prefilled data
endif
else
display form page
endif

The "success" and "form" pages could be separate files that get included at the appropriate points. The form file can look to see if an $error array is populated, and if so, use that to display error messages, and can look at the $_POST array to see if there are already values submitted, which can then be used to prefill the form, e.g.: