Shea Lavington Shea Lavington - 1 year ago 73
SQL Question

PHP->MySQL Form - Validation

I've got a dilema, I've got my database created, my input form works, however I'm looking to add validation to the POST so that certain things cant be entered, I can release snippets of code if needed however I can't find what I'm looking for.

My form basically

<input type="text" name="id1" placeholder="Pick a number">
<input type="text" name="id2" placeholder="Pick another number">

However, I would like to display an error if they pick the same number

EG: IF ID1 == ID2 then ECHO error.

However I'm unsure of the code, I have a simple PHP Mysql form.

Answer Source

You can use this code:

 if($_POST['id1'] == $_POST['id2']) {
        echo 'error';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download