Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['identifiant']))      $identifiant=$_POST['identifiant'];
  3. else      $identifiant="";
  4.  
  5. if(isset($_POST['mdp']))      $mdp=$_POST['mdp'];
  6. else      $mdp="";
  7.  
  8. if(isset($_POST['prenom']))      $prenom=$_POST['prenom'];
  9. else      $prenom="";
  10.  
  11. if(isset($_POST['nom']))      $nom=$_POST['nom'];
  12. else      $nom="";
  13.  
  14. if(isset($_POST['mail']))      $mail=$_POST['mail'];
  15. else      $mail="";
  16.  
  17. if(isset($_POST['ecole']))      $ecole=$_POST['ecole'];
  18. else      $ecole="";
  19.  
  20. if(empty($identifiant) OR empty($mdp) OR empty($prenom) OR empty($nom) OR empty($mail) OR empty($ecole))
  21. {
  22.     echo '<font color="red">Attention, merci de remplir les champs !</font>';
  23. }
  24. else      
  25. {
  26.     $servername = "localhost";
  27.     $username = "root";
  28.     $password = "";
  29.     $dbname = "evenement";
  30.  
  31.     $conn = new mysqli($servername, $username, $password, $dbname);
  32.     if ($conn->connect_error) {
  33.        die("Erreur de connexion: " . $conn->connect_error);
  34.    }
  35.  
  36. // duplicate check
  37.    $check_mail = "SELECT mail FROM utilisateur WHERE mail='".$mail."'";
  38.    $resultat = mysql_query($check_mail);
  39.    $nombre_mail = mysql_num_rows($resultat);
  40.    if($nombre_mail < 1) {
  41.     header('Location: ../erreurinscription.php');
  42. }
  43.  
  44. $sql = "INSERT INTO utilisateur(identifiant, mdp, prenom, nom, mail, ecole) VALUES('$identifiant','$mdp','$prenom','$nom','$mail','$ecole')";
  45. if($conn->query($sql) === true){
  46.     header('Location: ../succesinscription.php');
  47. }else{
  48.     header('Location: ../erreurinscription.php');
  49. }
  50.  
  51. $conn->close();
  52.  
  53. }  
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement