# {php} how do i check users inputed data correctly?

**URL:** <https://forum.kirupa.com/t/php-how-do-i-check-users-inputed-data-correctly/198347>\
**Category:** programming\
**Created:** [August 24, 2006, 11:09am UTC](https://forum.kirupa.com/t/php-how-do-i-check-users-inputed-data-correctly/198347 "2006-08-24T11:09:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![boozy\_juice](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@boozy\_juice](https://forum.kirupa.com/u/boozy_juice)\
**Post date:** [August 24, 2006, 11:09am UTC](https://forum.kirupa.com/t/php-how-do-i-check-users-inputed-data-correctly/198347/1 "2006-08-24T11:09:42Z")

</div>

Firstly Hello all, im new to server-side and to php and the functionality behind feedback forms - i delt with pearl a while back for a feedback form and got quite burnt by the experience, so…

Anyway, ive cobbled together some code from kirupas really good tutorial section - [http://www.kirupa.com/web/form\_mailer.htm](http://www.kirupa.com/web/form_mailer.htm) - and it works excellently…

```auto
<?PHP 
$to = "@gmail.com";
$date = date ("l, F jS, Y"); 
$time = date ("h:i A"); 
$subject = "Results from your Request Info form";
$headers = "From: you";
$forward = 0;
 

$msg = "Below is the result of your feedback form. It was submitted on $date at $time.

"; 

if ($_SERVER['REQUEST_METHOD'] == "POST") {
    foreach ($_POST as $key => $value) { 
        $msg .= ucfirst ($key) ." : ". $value . "
"; 
    }
}
else {
    foreach ($_GET as $key => $value) { 
        $msg .= ucfirst ($key) ." : ". $value . "
"; 
    }
}

mail($to, $subject, $msg, $headers); 
if ($forward == 1) { 
    header ("Location:$location"); 
} 
else { 
    echo "Thank you for submitting our form. A representative will get back to you as soon as possible."; 
} 

?>

```

but i need to ‘validate’(?) or see that the user has inputted the correct or any data ie: \*required fields type thing. If they dont input anythikng or the correct thing (like @ in email box) then it shows an ‘error’ as a page or anything, and then doesnt send.

i also need 1 tick box - ‘yes’ if ticked, ‘no’ if unticked - again ‘validated’

thinking about it… is php even the best method for this?

thanks a lot!
