Hi I am learning php and I have script which works just what I need to do is I have two files one is form.php and second process.php in process.php I use capatcha image security code and when people type incorrect code it echo "Wrong security code!" but in process.php page. What i need to do I want to echo that message in form.php That is actually question how to echo something in one file from another file? Thank you for help
You have to identify the error in one file, then redirect to the other file with http://ca3.php.net/manual/en/function.header.php and include the fact that there was an error either with a cookie (http://ca3.php.net/manual/en/function.setcookie.php), session variable (http://ca3.php.net/manual/en/features.sessions.php), or a URL parameter (redirect to form.php?error=1), and then in the form.php you would check for that indication of an error, and display an appropriate message if an error is found. That's how it can be done.
Basically you need to embedded the PHP Code before html part of the code to display the data in the same files so the job will be simpler and quicker now If you use include or something it will become a two way process!
well i don't think changing the order will help this one! He seems to be doing all the validation on process.php so the form will have action="process.php" ... He seems to have solved it using header(location...) . Ajax might have been the other way to validate on the same page before actually processing the form.