Advertisement
soyuka

Exemple d'inscription en php

Mar 31st, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. <form method="POST" action="actions/inscriptions.php">
  2. <input type="text" name="username" />
  3. <input type="password" name="password" />
  4. </form>
  5.  
  6. <!-- le php dans le fichier inscriptions.php situé dans le dossier actions par exemple -->
  7.  
  8. <?php
  9.  
  10. if(!empty($_POST['username']) && !empty($_POST['password']) ) {
  11.     //Ici on a reçu un POST et on fout tout dans un tableau par ex
  12.     $membre['username'] = mysql_real_escape_string(htmlentities($_POST['username']));
  13.     $membre['password'] = sha1($_POST['password']);
  14.  
  15.     //On met tout ça en bdd (voir SDZ)
  16.     //...
  17.     //Pour la connexion par cookies, on serialize le tableau (voir php.net/serialize)
  18.    
  19.     setcookie('membre', serialize($membre), time() + 365*24*3600, '/', null, false, true);
  20.  
  21.     /*Pour la session c'est encore plus simple : avant tout autre instruction on introduit les sessions avec
  22.     session_start();
  23.     */
  24.     $_SESSION['membre'] = serialize($membre);
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement