Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['registerPHP' ] )){
- try{
- $registerPHP = new registerPHP();
- $registerPHP->connect();
- }catch(Exception $e){echo $e->getMessage();}
- }
- if(isset($_POST['loginPHP' ] )){
- try{
- $class = new loginPHP();
- }catch(Exception $e){echo $e->getMessage();}
- }
- class registerPHP{
- public function __construct() {
- }
- public function connect() {
- $dbip = "85.10.205.173:3306";
- $dbusername = "pretpacked";
- $dbpassword = "i6kfxTEYXs0rkQw16mPQ";
- $dbdatabase = "sdgger24w45672fe";
- $con = mysqli_connect("$dbip", "$dbusername", "$dbpassword", "$dbdatabase");
- if (mysqli_connect_errno()){
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }else{$this->registerPHP($con);}
- }
- public function registerPHP($con = null){
- if($con){echo "<br> black nibba, fuck these ; "; var_dump($con);}
- $username = $_POST['usernameReg'];
- $password = $_POST['passwordReg'];
- if(strlen($username) <= 4){
- throw new Exception(' <script> alert("Username is to small [4]")</script>' );
- }
- if(strlen($password) <= 6){
- throw new Exception(' <script> alert("Password is to small [6]")</script>' );
- }
- $dbip = "***********";
- $dbusername = "***********";
- $dbpassword = "***********";
- $dbdatabase = "***********";
- echo "<br>Username: $username";
- echo "<br>Password: $password";
- $password = password_hash($password, PASSWORD_DEFAULT);
- echo "<br>HASHED Password: $password <br><br>Output:";
- $lgn="SELECT * FROM loginData WHERE lgn = '$username'";
- $addData = "INSERT INTO loginData ( lgn, pass) VALUES ( '$username', '$password' )";
- if ($result=mysqli_query($con,$lgn)){
- $rowcount=mysqli_num_rows($result);
- mysqli_free_result($result);
- if($rowcount == 0){
- echo "<br>Username free.";
- if ($result=mysqli_query($con,$addData)){
- if($rowcount == 0){
- echo "<br>Data added";
- echo "<script>alert('Account created')</script>";
- echo "<script>window.open('http://localhost/index.php', '_blank')</script>";
- }
- }else{printf("<br>Data not added");}
- }else{printf("<br>username result set has %d rows.\n",$rowcount);}
- }
- echo "<br>==============================================================";
- mysqli_close($con);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement