Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "student.famnit";
- $password = "pwd";
- $dbname = "rprakt_2017";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- if(isset($_GET["email"])==true){
- $email=$_GET["email"];
- //zgeneriraj random string, ki bo kot geslo:
- function generateRandomString($length = 10) {
- $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $charactersLength = strlen($characters);
- $randomString = '';
- for ($i = 0; $i < $length; $i++) {
- $randomString .= $characters[rand(0, $charactersLength - 1)];
- }
- return $randomString;
- }
- $pw= generateRandomString();
- $sql = "INSERT INTO users (email, ageslo) VALUES ('$email','$pw')";
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- $naslovnik_email=$email;
- $zadeva="Potrdi mail";
- $sporocilo="pojdina povezavo za potrditev "."http://www.studenti.famnit.upr.si/~89171118/php/databseverify.php?pw=".$pw."";
- mail($naslovnik_email, $zadeva, $sporocilo);
- } else {
- echo "taken";
- }
- }
- $conn->close();
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <form action="database.php" method="GET">
- Email:<br>
- <input type="email" name="email" >
- <br>
- Password:<br>
- <input type="password" name="password" >
- <br><br>
- <input type="submit" value="Sign Up">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement