Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- #default 127.0.0.1 this is the local IP
- #xo4.x10hosting.com this is the host address
- $con = mysqli_connect('xo4.x10hosting.com:3306', 'root','', 'tstdom63_logreg');
- $error = "";
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $username = $_REQUEST['username'];
- $email = $_REQUEST['email'];
- $password = $_REQUEST['password'];
- $password2 = $_REQUEST['password2'];
- $sql = "INSERT INTO login(username, email, password) VALUES ('$username', '$email', '$password')";
- $sqlu = "SELECT * FROM login WHERE username='$username'";
- $x = mysqli_query($con, $sqlu);
- if(mysqli_num_rows($x) > 0) {
- $error = "Account Exist!";
- } else{
- if (strlen($password) < 8){
- $error = "Password must contain 8 character!";
- }else{
- if($password == $password2){
- $password = md5($password);
- $message = "Success";
- echo "<script type='text/javascript'>alert('$message');</script>";
- $sql1 = "INSERT INTO login(username, email, password) VALUES ('$username', '$email', '$password')";
- mysqli_query($con, $sql);
- }
- }
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <link rel="stylesheet" href="style1.css" type="text/css">
- </head>
- <body background="greenback.jpeg">
- <br>
- <form method="post">
- <div class="container" >
- <h1>Register</h1>
- <p>Please fill in this form to create an account.</p>
- <hr>
- <label for="email"><b>Username</b></label>
- <input type="text" placeholder="Username" name="username" required>
- <label for="email"><b>Email</b></label>
- <input type="text" placeholder="Email" name="email" required>
- <label for="psw"><b>Password</b></label>
- <input type="password" placeholder="Password" name="password" required>
- <label for="psw-repeat"><b>Confirm Password</b></label>
- <input type="password" placeholder="Password" name="password2" title="Must contain at least 8 or more characters" required>
- <p class="error" style="color:red"><?php echo $error; ?></p>
- <a><input type="submit" class="registerbtn"></a>
- <hr>
- <CENTER>
- <p>Already have an account? <a href="login.php">Sign in</a>.</p>
- </CENTER>
- </div>
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment