Guest User

Untitled

a guest
Apr 8th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. <?php
  2. $servername = "localhost:3306";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "untold";
  6. // Create connection
  7. $conn = new mysqli($servername, $username, $password,$dbname);
  8.  
  9. // Check connection
  10. if (!$conn) {
  11. die("Connection failed: " . mysqli_connect_error());
  12. }
  13. $nume = $_POST['Nume'];
  14. $prenume = $_POST['Prenume'];
  15. $varsta = $_POST['Varsta'];
  16. $cnp = $_POST['CNPa'];
  17. if($nume==='' || $prenume==='' || $varsta==='' || is_numeric($nume) || is_numeric($prenume) || !is_numeric($varsta) || !is_numeric($cnp) || strlen($cnp)!='13')
  18. trigger_error("VALORI INVALIDE", E_USER_ERROR);
  19.  
  20. $sql= "Select CNP from Spectatori";
  21. $result = mysqli_query($conn, $sql);
  22.  
  23. if (mysqli_num_rows($result) > 0)
  24. {
  25. while($row = mysqli_fetch_assoc($result)) {
  26.  
  27. if($row["CNP"]===$cnp)
  28. trigger_error("CNP-ul exista deja inserat!", E_USER_ERROR);
  29.  
  30. }
  31. }
  32.  
  33. $sql = "INSERT INTO Spectatori (Nume, P_nume, Varsta,CNP)
  34. VALUES ('$nume', '$prenume', '$varsta','$cnp')";
  35.  
  36. if (mysqli_query($conn, $sql)) {
  37.  
  38. }
  39. else
  40. {
  41. echo "Error: " . $sql . "<br>" . mysqli_error($conn);
  42. }
  43. $sql="ALTER TABLE Spectatori DROP ID_spect";
  44. mysqli_query($conn, $sql);
  45.  
  46. $sql="ALTER TABLE Spectatori AUTO_INCREMENT = 1";
  47. mysqli_query($conn, $sql);
  48.  
  49. $sql="ALTER TABLE Spectatori ADD ID_spect int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST";
  50. mysqli_query($conn, $sql);
  51.  
  52. mysqli_close($conn);
  53. ?>
  54. <!DOCTYPE html>
  55. <html>
  56. <head>
  57. <style>
  58. body {
  59. background-image: url("untold-2017.jpg");
  60. background-size:cover;
  61. }
  62.  
  63. poztit {
  64. position: fixed;
  65. left: 500px;
  66. top: 20px;
  67. }
  68.  
  69. poz1 {
  70. position:fixed;
  71. left: 570px;
  72. top: 270px;
  73. }
  74. poz2 {
  75. position:fixed;
  76. top: 100px;
  77. left: 350px;
  78. }
  79. .btn {
  80. background: #3498db;
  81. background-image: -webkit-linear-gradient(top, #3498db, #2980b9);
  82. background-image: -moz-linear-gradient(top, #3498db, #2980b9);
  83. background-image: -ms-linear-gradient(top, #3498db, #2980b9);
  84. background-image: -o-linear-gradient(top, #3498db, #2980b9);
  85. background-image: linear-gradient(to bottom, #3498db, #2980b9);
  86. -webkit-border-radius: 28;
  87. -moz-border-radius: 28;
  88. border-radius: 28px;
  89. font-family: Arial;
  90. color: #ffffff;
  91. font-size: 27px;
  92. padding: 10px 20px 10px 20px;
  93. text-decoration: none;
  94. }
  95.  
  96. </style>
  97. </head>
  98. <head>
  99. <title>INSERT</title>
  100.  
  101. </head>
  102. <body>
  103. <poztit>
  104. <div style="text-shadow:1px 1px 9px rgba(255,28,89,1);color:#9D28F7;font-size:70px;font-family:comic sans, comic sans ms, cursive, verdana, arial, sans-serif;">
  105. UNTOLD
  106. </div>
  107. </poztit>
  108. <poz2>
  109. <div style="text-shadow:1px 1px 9px rgba(255,28,89,1);color:#9D28F7;font-size:70px;text-align:center;font-family:comic sans, comic sans ms, cursive, verdana, arial, sans-serif;">
  110. Tabel Modificat!
  111. </div>
  112. </poz2>
  113. <poz1>
  114. <a href="meniu.php">
  115. <button class="btn">
  116. HOME
  117. </button>
  118. </a>
  119. </poz1>
  120.  
  121. </body>
  122. </html>
Add Comment
Please, Sign In to add comment