Advertisement
Guest User

Untitled

a guest
May 17th, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "student.famnit";
  4. $password = "pwd";
  5. $dbname = "rprakt_2017";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11. die("Connection failed: " . $conn->connect_error);
  12. }
  13. if(isset($_GET["email"])==true){
  14. $email=$_GET["email"];
  15. //zgeneriraj random string, ki bo kot geslo:
  16. function generateRandomString($length = 10) {
  17. $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  18. $charactersLength = strlen($characters);
  19. $randomString = '';
  20. for ($i = 0; $i < $length; $i++) {
  21. $randomString .= $characters[rand(0, $charactersLength - 1)];
  22. }
  23. return $randomString;
  24. }
  25.  
  26. $pw= generateRandomString();
  27.  
  28. $sql = "INSERT INTO users (email, ageslo) VALUES ('$email','$pw')";
  29.  
  30. if ($conn->query($sql) === TRUE) {
  31. echo "New record created successfully";
  32. $naslovnik_email=$email;
  33. $zadeva="Potrdi mail";
  34. $sporocilo="pojdina povezavo za potrditev "."http://www.studenti.famnit.upr.si/~89171118/php/databseverify.php?pw=".$pw."";
  35.  
  36. mail($naslovnik_email, $zadeva, $sporocilo);
  37.  
  38. } else {
  39. echo "taken";
  40. }
  41. }
  42.  
  43. $conn->close();
  44.  
  45. ?>
  46. <!DOCTYPE html>
  47. <html>
  48. <head>
  49. <title></title>
  50. </head>
  51. <body>
  52. <form action="database.php" method="GET">
  53. Email:<br>
  54. <input type="email" name="email" >
  55. <br>
  56. Password:<br>
  57. <input type="password" name="password" >
  58. <br><br>
  59. <input type="submit" value="Sign Up">
  60. </form>
  61.  
  62. </body>
  63. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement