Guest User

Untitled

a guest
Jun 20th, 2018
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.25 KB | None | 0 0
  1. <?php
  2.  
  3. //konektimi.php
  4. $conn = new mysqli ("localhost", "", "", "Baza");
  5.  
  6. $sql = "
  7.  
  8. create table Perdoruesit
  9. (
  10.     Perdoruesi varchar (50) primary key,
  11.     Password char (40) not null,
  12.     Tel varchar (10) not null
  13. );
  14.  
  15. ";
  16.  
  17. if ($conn->query($sql))
  18. {
  19.     echo "Keni krijuar tabelen me sukses";
  20. }
  21. else
  22. {
  23.     echo "Tabela nuk eshte krijuar";
  24.     return;
  25. }
  26.  
  27. //regjistrimi.php
  28. require "konektimi.php";
  29.  
  30. $breakLater = false;
  31.  
  32. if (isset ($_SESSION['perdoruesi']))
  33. {
  34.     $user = $_SESSION['perdoruesi'];
  35.    
  36.     echo "Jeni regjistruar me sukses.";
  37.     $breakLater = true;
  38. }
  39.  
  40. if (isset ($_COOKIE['user']) and isset ($_COOKIE['pass']))
  41. {
  42.     $u = $_COOKIE['user'];
  43.     $p = $_COOKIE['pass'];
  44.    
  45.     echo $u." mundeni mu kqyq ".$p;
  46. }
  47.  
  48. if ($breakLater == true)
  49.     return;
  50.  
  51.  
  52. $canContinue = true;
  53.  
  54. if (isset ($_POST['user']) && isset ($_POST['pass']) && isset ($_POST['tel']))
  55. {
  56.     $name = $_POST['user'];
  57.     $pass = $_POST['pass'];
  58.     $tel = $_POST['tel'];
  59.    
  60.     $sql = "select Perdoruesi from Perdoruesit";
  61.     $res = $conn->query($sql);
  62.    
  63.     while ($row = $res->fetch_assoc())
  64.     {
  65.         $user = $row["Perdoruesi"];
  66.        
  67.         if ($user == $name)
  68.         {
  69.             echo "Nje perdorues i tille ekziston";
  70.             $canContinue = false;
  71.         }
  72.     }
  73.    
  74.     if ($canContinue)
  75.     {
  76.         $insertSql = "insert into Perdoruesit () values ('$name', '$pass', '$tel')";
  77.        
  78.         if ($conn->query ($insertSql))
  79.         {
  80.             echo "Keni futur te dhenen me sukses.";
  81.             $_SESSION['perdoruesi'] = $name;
  82.            
  83.             if (isset ($_POST['chb']))
  84.             {
  85.                 setcookie("user", $name, time() + 10000000);
  86.                 setcookie("pass", $pass, time() + 10000000);
  87.             }
  88.         }
  89.         else
  90.         {
  91.             echo "Gabim!";
  92.         }
  93.     }
  94.     else
  95.     {
  96.     ?>
  97.         <form method="post" action="<?php $_SERVER["PHP_SELF"]; ?>">
  98.             <input type="text" name='user'></input>
  99.             <input type="text" name='pass'></input>
  100.             <input type="text" name='tel'></input>
  101.             <input type="checkbox" name='chb'></input>
  102.             <input type="submit" value="Send"></input>
  103.         </form>
  104.  
  105.     <?php
  106.    
  107.     }
  108. }
  109. else
  110. {
  111.     ?>
  112.     <form method="post" action="<?php $_SERVER["PHP_SELF"]; ?>">
  113.         <input type="text" name='user'></input>
  114.         <input type="text" name='pass'></input>
  115.         <input type="text" name='tel'></input>
  116.         <input type="checkbox" name='chb'></input>
  117.         <input type="submit" value="Send"></input>
  118.     </form>
  119.     <?php
  120. }
  121. ?>
Add Comment
Please, Sign In to add comment