Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check a input field exists in the form when I submit it to the server?

How can I check a input field exists in the form when I submit it to the server?

For instance, I want to check whether a check box named 'mem_follow' exists or not in the form.

Or do I have to use javascript (jquery)?

like image 571
Run Avatar asked Aug 24 '11 17:08

Run


1 Answers

I'm guessing you need to check on the server side after the form is submitted. If that's the case, you can check like so...

<?php
if (isset($_POST['mem_follow']))
{
    // Work your server side magic here
} else {
    // The field was not present, so react accordingly
}
?>

Hope this helps!

like image 176
George Avatar answered Oct 04 '22 20:10

George