(Q1)Hi I’m using textbox in my project and I can’t receive the values that are typed
<textarea rows="5" cols="60"> Type your suggestion </textarea>
<br>
<input type="submit" name="sugestao" value="Submit" />
Sorry I don’t know how to ‘kill’ html code, that’s why < is missing.
All I’m getting in the column of the database from this text box is “Submit”, I’d like to receive whatever is written in the text area. How can I make the value equal whaterever is typed?
(Q2) How can I make sure that I’ll only store the same type(int,varchar,text) that I setted,declared in the database. For example: age(int), but if someone types “abc” in the input it will be stored in my database as the value 0 . How can I forbid this, and only save the age when it’s just int and all the other fields(like name, email) are filled ?. And if is still possible warn the user that he is typing something wrong, don’t need to say where.
Sorry for any mistake in English and Thanks for the attention.
You need a
nameattribute for your textarea, otherwise, when you submit the form, the text you have entered is not sent.For your second question, you can implement input validation on client side (with javascript), server side (with whatever language you are using), or both.
For age validation as an example you want to validate two things:
With PHP you check this way: