Re: preventing empty vote in form
>>Posted by: "Tedit kap" teditkap@... teditkapYou just need to do basic form validation. The way you thinking is
>>Sun Oct 5, 2008 6:48 pm (PDT)
>>I have a radio button style poll form, currently even if a >>user does not select a choice and hits the submit button, >>his answer is submitted to my database as an empty >>response, which I dont want. I want everyone to vote and >>only then the submission should work. I thought about >>not displaying the submit button before he votes, but >>then it did not seem like a good idea. I want the submit >>button displayed before he votes, but if he clicks it >>before voting, it should prevent the response to be sent >>to the database. Any ideas on how to do that?
>>Here is the submit button:
>>echo "<input type=\"submit\" value=\"submit my >>answer\"/>";
>>and, if it matters, here is how i display the choices >>before that:
>>for($i=1; $i<=$qtotal; $i++)
>>echo "<input type=\"radio\" name=\"answer\" >>value=$answer>";
client side form validation. Showing the submit button after input is
made, cannot be implemented from PHP well or not necessary for the
purpose you want to do.
First of all, PHP is server side language. If you do the basic steps
of form validation. Like check
if isset($_POST['submit']) == true then do the validation of inputs
if the $_POST have a necessary input pattern present they are eligible
to be inserted to DB.
Search through google, php_manual, elementary php books for the Form
Validation. The basic lesson will solve your problem perfectly well.