1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
| <?php
trim($_POST['last_name']);
trim($_POST['first_name']);
trim($_POST['email']);
trim($_POST['mobile']);
if(!isset($_POST['last_name']) || strlen($_POST['last_name'])<1 || !preg_match('/^[a-zA-Zàâéèêïîöôüû -]+$/',$_POST['last_name']))
{
$last_name='Your last name doesn\'t seem correct ! Only letters are available and accent (a->z and àâéèêïîöôüû)';
$check=false;
}
else
{
$last_name=true;
}
if(!isset($_POST['first_name']) || strlen($_POST['first_name'])<1 || !preg_match('/^[a-zA-Zàâéèêïîöôüû -]+$/',$_POST['first_name']))
{
$first_name='Your first name doesn\'t seem correct ! Only letters are available and accent (a->z and àâéèêïîöôüû)';
$check=false;
}
else
{
$first_name=true;
}
date_default_timezone_set('America/Los_Angeles');
if(isset($_POST['year']) && $_POST['year']<=date('Y')-10 && isset($_POST['month']) && isset($_POST['day']) && is_numeric($_POST['year']) && is_numeric($_POST['month']) && is_numeric($_POST['day']))
{
if(($_POST['year']==4 || $_POST['year']==6 || $_POST['year']==9 || $_POST['year']==11) && $_POST['day']>30)
{
$date_of_birth='Your date of birth dosn\'t seem correct !';
$check=false;
}
elseif($_POST['year']==2 && $_POST['year']%4==0 && $_POST['year']%100!=0 || $_POST['year']%400==0)
{
if($_POST['day']>29)
{
$date_of_birth='Your date of birth dosn\'t seem correct !';
$check=false;
}
}
elseif($_POST['year']==2 && $_POST['year']>28)
{
$date_of_birth='Your date of birth dosn\'t seem correct !';
$check=false;
}
else
{
$date_of_birth=true;
}
}
else
{
$date_of_birth='Your date of birth dosn\'t seem correct !';
}
if(!isset($_POST['sex']) || ($_POST['sex']!='male' && $_POST['sex']!='female'))
{
$sex='Your gender dosn\'t seem correct, can be only male or female !';
$check=false;
}
else
{
$sex=true;
}
if((!preg_match('`[0-9]{10}`',$_POST['mobile']) || strlen($_POST['mobile'])!=10) && isset($_POST['mobile']) && $_POST['mobile']!='')
{
$mobile='Your numberphone doesn\'t seem correct !';
$check=false;
}
else
{
$mobile=true;
}
try
{
$db = new PDO('mysql:host=mon_host;dbname=ma_base_de_donnee;charset=utf8', 'mon_utilisateur', 'mon_mot_de_passe');
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
$db_count_line_table_country=$db->prepare('SELECT id FROM country');
$db_count_line_table_country->execute();
$db_max_line_table_country = $db_count_line_table_country->fetchAll();
$db_max_line_table_country = count($db_max_line_table_country);
if(!isset($_POST['country']) || (!is_numeric($_POST['country']) && ($_POST['country'] < 0 || $_POST['country']>$db_max_line_table_country)))
{
$country='Your country doesn\'t seem correct !';
$check=false;
}
else
{
$country=true;
}
if(!isset($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
{
$email='Your mail doesn\'t seem correct';
$check=false;
}
else
{
$email=true;
}
if(!isset($_POST['password']) || (!preg_match('#^[a-zA-Z0-9]$#',$_POST['password']) && (strlen($_POST['password'])>=12 || strlen($_POST['password'])<=5)))
{
$password='Your password must contain only letters and numbers (a->z A->Z 0->9) and between 6 and 12 characters !';
$check=false;
}
else
{
$password=true;
}
if($_POST['password_check']!=$_POST['password'])
{
$password_check='Passwords don\'t corrresond !';
$check=false;
}
else
{
$password_check=true;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Sijeun</title>
<link href='http://fonts.googleapis.com/css?family=Dancing+Script:700' rel='stylesheet' type='text/css'/>
<style>
</style>
</head>
<body>
<h1 style="font-family:'dancing script';width:100%;border-bottom:double 4px black;text-align:center;">Sijeun</h1>
<?php
if(isset($check) && $check==false)
{
printf("%s<br/>%s<br/>%s<br/>%s<br/>%s<br/>%s<br/>%s<br/>%s<br/>",$last_name, $first_name, $date_of_birth, $sex, $mobile, $country, $email, $password, $password_check);
}
else
{
printf("registration with success !");
}
?>
</body>
</html> |
Partager