Hi guys, I think I may be losing my marbles over this form I've put together. I'm trying to get my code to post the following to a database but my MySQL and PHP isn't that good, so wondering if any one could possibly suggest what I could do?
Here is my code:
<?php
// we check if everything is filled in
if(empty($_POST['fname']) || empty($_POST['lname']) || empty($_POST['email']))
{
die(msg(0,"All the fields are required"));
}
// is the sex selected?
if(!(int)$_POST['sex-select'])
{
die(msg(0,"You have to select your sex"));
}
// is the birthday selected?
if(!(int)$_POST['day'] || !(int)$_POST['month'] || !(int)$_POST['year'])
{
die(msg(0,"You have to fill in your birthday"));
}
// is the email valid?
if(!(preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $_POST['email'])))
die(msg(0,"You haven't provided a valid email"));
// I think here is where I need to put something to get the data into a table!
echo msg(1,"registered.html");
function msg($status,$txt)
{
return '{"status":'.$status.',"txt":"'.$txt.'"}';
}
?>
How do I get the $_POST['day'] and $_POST['month'], $_POST['year'] etc into a table? It should be so easy but my head is hurting from trying lots of things and tutorials online.
Any thoughts my PHP Freaks?