Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/233393-post-data/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.