register.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Gestionnaire de recherche d'emploi - Inscription</title>
  5. <link href="custom.css" rel="stylesheet">
  6. <meta name="viewport" content="width=device-width">
  7. </head>
  8. <body>
  9. <h1>Gestionnaire de recherche d'emploi - Inscription</h1>
  10. <h2>C'est le moment où vous parlez de vous ! 🙂</h2>
  11. <form action="register.php" method="post">
  12. <table>
  13. <tr style='border:0px;'>
  14. <td style='border:0px;'>
  15. <label for="first_name">&nbsp;Prénom :</label>
  16. </td>
  17. <td style='border:0px;'>
  18. <input type="text" name="first_name" size="50" required>
  19. </td>
  20. </tr>
  21. <tr style='border:0px;'>
  22. <td style='border:0px;'>
  23. <label for="last_name">&nbsp;Nom :</label>
  24. </td>
  25. <td style='border:0px;'>
  26. <input type="text" name="last_name" size="50" required>
  27. </td>
  28. </tr>
  29. <tr style='border:0px;'>
  30. <td style='border:0px;'>
  31. <label for="username">&nbsp;Nom d'utilisateur :</label>
  32. </td>
  33. <td style='border:0px;'>
  34. <input type="text" name="username" size="50" required>
  35. </td>
  36. </tr>
  37. <tr style='border:0px;'>
  38. <td style='border:0px;'>
  39. <label for="password">&nbsp;Mot de passe :</label>
  40. </td>
  41. <td style='border:0px;'>
  42. <input type="password" name="password" size="50" required>
  43. </td>
  44. </tr>
  45. <tr style='border:0px;'>
  46. <td style='border:0px;'>
  47. <label for="profession">&nbsp;Profession (un seul poste) :</label>
  48. </td>
  49. <td style='border:0px;'>
  50. <input type="text" name="profession" size="50" required>
  51. </td>
  52. </tr>
  53. </table><br>
  54. <input type="submit" name="submit" value="S'inscrire">
  55. </form>
  56. </body>
  57. </html>
  58. <?php
  59. // Connexion à la base de données
  60. $host = "localhost";
  61. $dbusername = "prodrechercheemploi";
  62. $dbpassword = "j6uSgr49bpXC1PwRZKV8";
  63. $dbname = "prod_rechercheemploi";
  64. $conn = mysqli_connect($host, $dbusername, $dbpassword, $dbname);
  65. if (!$conn) {
  66. die("Erreur de connexion à la base de données : " . mysqli_connect_error());
  67. }
  68. // Récupération des informations soumises par l'utilisateur
  69. if(isset($_POST['submit'])) {
  70. $first_name = $_POST['first_name'];
  71. $last_name = $_POST['last_name'];
  72. $username = $_POST['username'];
  73. $password = $_POST['password'];
  74. $profession = $_POST['profession'];
  75. $profession = htmlentities($profession);
  76. $profession = str_replace("/", "\/", $profession);
  77. // Requête d'insertion des informations dans la base de données
  78. $sql = "INSERT INTO users (first_name, last_name, username, password, profession)
  79. VALUES ('$first_name', '$last_name', '$username', '$password', '$profession')";
  80. if (mysqli_query($conn, $sql)) {
  81. echo "Inscription réussie !";
  82. header("refresh:1; url=index.php");
  83. } else {
  84. echo "Erreur : " . $sql . "<br>" . mysqli_error($conn);
  85. }
  86. }
  87. mysqli_close($conn);
  88. ?>