Page 1 of 1

How to Validate Text and Submit Button?

Posted: Wed Sep 06, 2006 1:22 am
by umapathy
Hi all

i have one problem in my page.
i have four textboxs.

1. Should Accept only Character
2.Should Accept only Number
3.Should check date format.
4. should check upload file.

in the above four if i leave blank or type miss match a error should indimate to the user when he clicking the Submit Button.
How is possible.?
Can you guide me?


Thanks and Regards
Umapathy

Posted: Wed Sep 06, 2006 1:42 am
by Oren
First of all, take a look at isset() and empty().

1. ctype_alpha()
2. ctype_digit()
3. Use select boxes to force your own format and check the range of the day, month and year - each one separately.
4. exif_imagetype(), getimagesize() and move_uploaded_file()

- Get yourself a good book.
- Read related topics on the forums here.
- Read online tutorials.

Posted: Wed Sep 06, 2006 2:54 am
by Ollie Saunders
3. Use select boxes to force your own format and check the range of the day, month and year - each one separately.
Remember just because the user can only choose from select options doesn't mean a hacker can't specify his own. Validate the date is correct on the server as if it was entered as text.

Posted: Wed Sep 06, 2006 2:34 pm
by Oren
ole wrote:Remember just because the user can only choose from select options doesn't mean a hacker can't specify his own. Validate the date is correct on the server as if it was entered as text.
Read my post again pal... I think I was clear enough when I told him to check the ranges :P

Posted: Wed Sep 06, 2006 6:08 pm
by Ollie Saunders
Sorry oren didn't see that.

Posted: Thu Sep 07, 2006 12:14 am
by angelena
Below is some codes which hopefully helps u :

Let say u have a submit button names var and value as add

Code: Select all

<input type=submit value="add" name="var">

Then your validation once a submit button clicked is :

Code: Select all

//if add button is clicked
    if($var == 'add')
	{
	   
                  ...do your checking here		
	}

Posted: Thu Sep 07, 2006 2:24 am
by Rovas
Here it is a good PHP tutorial http://codewalkers.com/tutorials/47/1.html.
Another tutorial here: http://www.php-mysql-tutorial.com/form- ... th-php.php.
Use them as an example do not copy the code.
Good luck!