effkay Posted November 12, 2007 Share Posted November 12, 2007 Hi. I'm running a questionnaire on the web which consists of a basic html form, a php-script for sending the information, and a mysql database to store the information. To ensure that not everyone can get access to the questionnaire, I added a simple login-script which registers a new session. All subsequent pages after the login-page have "session_start; if !session_is_registered(username) { header(index.html); }. So thats working fine for now. However, I've been working on implementing serverside validation of the formdata and here's where the problem arise. Lets say someone entered a sql-command into a text-field, e.g. "SELECT * FROM $table" and submitted. This input would not validate with my current validation-script, since special characters like * and $ are banned. Ok... So the user now gets a html-page saying "Hey.. you used illegal characters. Go back and try again". When the user goes back, the questionnaire is blank, even though the user got it right on all other questions. Now I thought, since the user registers a new session when he logs in, that the form-data would be stored in that session, and that going back from the validation-error-page would display the questionnaire as the user tried to submit it. Has anyone got an idea as to what I should do? I tested my current script in several browsers. Safari seems to be the only browser that stores the questionnaire, and displays it as it was prior to the error-page when going back. Suggestions are appreciated! -FK- Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 12, 2007 Share Posted November 12, 2007 I think you would need to create a session for each of your form fields to accomplish what your wanting to do and then echo the session back into your input field. <input type="text" name="FieldOne" value="<?php echo $_SESSION['FieldOneSessionName']; ?>"> Quote Link to comment Share on other sites More sharing options...
effkay Posted November 12, 2007 Author Share Posted November 12, 2007 I see... The size of my form and number of inputs within makes that a major undertaking to say the least. Would that work the same way with radiobuttons and select-lists? Thank you for your suggestion -FK- Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 12, 2007 Share Posted November 12, 2007 you could create a PHP function to select a specific radio or select menu option either with PHP or Javascript based on your session variable; that's what I would do. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.