Created
March 8, 2020 05:16
-
-
Save Reevan799/1a3a984214a4879b0ffa527c70f3d84a to your computer and use it in GitHub Desktop.
Fixed Sql Injection Problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <form id="register" class="input_group" action="registration.php" method="post" required> | |
| <input type="username" class="input_field" placeholder="Username" name="username" required> | |
| <input type="email" class="input_field" placeholder="Email Id" name="email" required> | |
| <input type="password" class="input_field" placeholder="Password" name="password" required> | |
| <input type="checkbox" class="checkbox" name="checkbox"> <span>I agree to the term & conditions</span> | |
| <button type="submit" class="submit_btn">Register</button> | |
| </form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| session_start(); | |
| $conn = mysqli_connect('localhost','root','7777','gm-registration'); | |
| $username = $_POST['username']; | |
| $email = $_POST['email']; | |
| $password = $_POST['password']; | |
| $s = "select * from users where username = '$username'"; | |
| $result = mysqli_query($conn, $s); | |
| $num = mysqli_num_rows($result); | |
| if($num==1){ | |
| echo "This Username is Already Taken"; | |
| } | |
| else{ | |
| $stmt = $conn->prepare("INSERT INTO users(username, email, password) VALUES(?,?,?)"); | |
| $stmt->bind_param("sss", $username, $email, $password); | |
| $stmt->execute(); | |
| echo "Registration Successful"; | |
| $stmt->close(); | |
| $conn->close(); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment