-2

I want to insert data to database via html form. I tried everything but after clicking the submit button, I get a blank page with no error messages. But the date isn't insert to the database. Can you help me?

register.php

<?php

if(isset($_GET["page"])){

    if($_GET["page"] == "2"){

     $user = strtolower($_POST["user"]);
     $pw   = md5($_POST["pw"]);
     $pw2   = md5($_POST["pw2"]);   

    if($pw != $pw2){

        echo "Deine Passwörter stimmen nicht über ein. Bitte wiederhole deine Eingabe... <a href='register.php'>zurück</a>";

    } else {

        $verbindung = mysql_connect("localhost", "user1", "") or die ("error");

        mysql_select_db("michael29") or die ("connection not possible");

        $control = 0;
        $abfrage = "SELECT user FROM login WHERE user = '$user'";
        $ergebnis = mysql_query($abfrage);
        while($row = mysql_fetch_object($ergebnis))
        {

            $control++;
        }
        if($control != 0){

            echo "Username schon vergeben. Bitte verwende einen anderen Usernamen... <a href='register.php'>zurück</a>";

        }


        mysql_close($verbindung);

    }

    }

}


?>
Michael29
  • 13
  • 2

1 Answers1

-1

You missed the second parameter to connect to the database. This line has an error:

mysql_select_db("michael29") or die ("connection not possible");

Replace it by:

mysql_select_db("michael29", $verbindung) or die ("connection not possible");

And you have to take care with the extensions you are using to work with mysql. Those one you have on your code were deprecated on PHP 5.5.0 version and since PHP 7.0.0 version they were removed.

Art_Code
  • 518
  • 4
  • 12