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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
| <!doctype html>
<html>
<head>
<title>Inscription</title>
<meta charset="utf-8"/>
<link rel="stylesheet" href="TP3.css"/>
</head>
<body>
<!--connexion with the database-->
<?php
//query of insertion of data in database
function query_insertion($pseudo, $password, $email, $phone)
{
global $connection;
$password = sha1($password);
$insertion_query = $connection->prepare('INSERT INTO membres(pseudo, password, email, date_inscription, phone_number) VALUES (:pseudo, :password, :email, DATE_FORMAT(NOW(), \'%d/%m/%Y %Hh:%imin:%ss\'), :phone)');
$insertion_query->bindParam(':pseudo',$pseudo);
$insertion_query->bindParam(':password', $password);
$insertion_query->bindParam(':email', $email);
$insertion_query->bindParam(':phone', $phone);
$insertion_query->execute();
$insertion_query->closeCursor();
}
// query of selection data in database
function query_selector($pseudo, $password, $email, $phone)
{
global $connection;
$query_selector = $connection->prepare('SELECT ?,?, ?, ? FROM membres ');
$query_selector->execute(array($pseudo, $password, $email, $phone));
$query_response = $query_selector->fetchAll();
return $query_response;
$query_selector->closeCursor();
?>
<!--End of connexion with the database-->
<!--verification of the input-->
<?php
//insertion of connextion and queries file
//include_once('modele/connexion_requetes.php');
//definig variables
$pseudo=$password=$email=$phone=$password_confirm="";
$pseudoErr=$passwordErr=$emailErr=$phoneErr=$password_confirmErr="";
//submt of visitors input to the database for insertion ans requesting in it.
$query_verification= query_insertion($pseudo, $password, $email, $phone);
$query_response = query_selector($pseudo, $password, $email, $phone);
//treatment of information submit by the users
//verification of whether the information submit valid or not
function verification($visitor_input)
{
$visitor_input = trim($visitor_input);
$visitor_input = htmlspecialchars($visitor_input);
//$visitor_input = stripslashes($visitor_input);
$visitor_input = filter_var($visitor_input, FILTER_SANITIZE_STRING);
return $visitor_input;
}
$pseudo = verification($_POST['pseudo']);
$password = verification($_POST['password']);
$password_confirm = verification($_POST['password_confirm']);
$email = verification($_POST['email']);
$phone = verification($_POST['phone']);
//recupération des nouvelles valeurs filtrées par vérification
if($_SERVER["REQUEST_METHOD"] == "post")
{
if(empty($pseudo))
{
$pseudoErr = "Pseudo is required! You most type it.";
}
//pseudo verification
else if($pseudo == $query_response['pseudo'])
{
$pseudoErr = "The pseudonyme you have entered already exists";
}
else
{
$pseudo = verification($_POST['pseudo']);
}
if(empty($password))
{
$passwordErr = " Password is required for this inscription";
}
else
{
$password = verification($_POST['password']);
$password = sha1($password);
}
if(empty($password_confirm))
{
$password_confirmErr = "You most type your password for the second time";
}
else
{
$password_confirm = verification($_POST['password_confirm']);
$password_confirm = sha1($password_confirm);
}
if(empty($email))
{
$emailErr ="Your Email address is required for this inscription";
}
//verification of email
else if(!preg_match("#^[a-z0-9._-]+@[a-z0-9.-_]{2, }\.[a-z]{2,4}$#i",$email))
{
$emailErr = "Your Email Address is not valid.Check that it's the same format as the one in example";
}
else
{
$email = verification($_POST['email']);
}
//verification of phone Number
if(empty($phone))
{
$phoneErr = "";
$phone= "";
}
else if(!preg_match("#^6((9|7|6)[0-9]{6})|5(1|2|6)[0-9]{5}$#", $phone))
{
$phoneErr = "Type a valid Phone Number!";
}
else
{
$phone = verification($_POST['phone']);
}
//verification of egality between the two passwords
if($password_confirm != $password)
{
$password_confirmErr = "Your two password are not the same.Retry and check you have correctly entered.";
}
//recovery of the news pseudo in the database
foreach($query_response as $query_responses)
{
$query_response['pseudo'] = $query_responses['pseudo'];
}
}
//include_once('vue/Inscription.php');
//header('location:vue/Inscription.php');
//include('vue/Inscription.php');
?>
<!--End of verification-->
<!--Appling or using of the result in the Index page-->
<form method = "post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<label for="pseudo">Pseudo</label><input type="text" name="pseudo" id="pseudo"/><br/>
<span class="error"><?php echo $pseudoErr; ?></span>
<label for="password">Password</label><input type="password" name="password" id="password"/><br/><span class="error"><?php echo $passwordErr; ?></span>
<label for="password_confirm">Confirm your Password</label><input type="password" name="password_confirm" id="password_confirm"/><br/><span class="error"><?php echo $password_confirmErr; ?></span>
<label for="phone" >Phone Number</label><input type="phone" name="phone" id="phone"/><br/><span class="error"><?php echo $phoneErr; ?></span>
<label for="email">Email address</label><input type="email" name="email" id="email"/><br/><span class="error"><?php echo $emailErr; ?></span>
<input type="submit" value="Submit" />
</form>
</body> |
Partager