Hallo,
ich habe eine Registrierung erstellt, aber die Daten werden nicht in die Datenbank eingetragen, aber warum?
Hier der Code:
ich habe eine Registrierung erstellt, aber die Daten werden nicht in die Datenbank eingetragen, aber warum?
Hier der Code:
PHP-Code:
<?php
include("c_config.php");
class register extends config
{
private $username;
private $password;
private $password2;
private $email;
private $code;
private $code2;
private $sql_username;
private $sql_email;
private $row;
function register_user($name, $pw, $pw2, $email, $c, $c2)
{
//Überprüfen ob alle Felder asugefüllt sind
if(empty($name) || empty($pw) || empty($pw2) || empty($email) || empty($c))
{
if(empty($name))
{
header("LOCATION: ".$this->domain."?fail=7");
exit;
}
if(empty($pw))
{
header("LOCATION: ".$this->domain."?fail=8");
exit;
}
if(empty($pw2))
{
header("LOCATION: ".$this->domain."?fail=9");
exit;
}
if(empty($email))
{
header("LOCATION: ".$this->domain."?fail=10");
exit;
}
if(empty($c))
{
header("LOCATION: ".$this->domain."?fail=11");
exit;
}
}
//Datenbankverbindung aufbauen
$this->mysqli();
//Variablen zu weisen
$this->username = $name;
$this->email = $email;
$this->code = $c;
$this->code2 = $c2;
$this->row = array();
//Überprüfen ob alle Felder nur aus Buchstaben und Zahlen bestehen
if(!preg_match("/^[a-zA-Z0-9]+$/s",$this->username) || !preg_match("/^[a-zA-Z0-9]+$/s",$pw) ||
!preg_match("/^[a-zA-Z0-9]+$/s",$pw2))
{
header("LOCATION: ".$this->domain."?fail=3");
exit;
}
//Passwörter sichern und überprüfen
if(!$pw == $pw2)
{
header("LOCATION: ".$this->domain."?fail=12");
exit;
}
$this->password = hash("sha512", $pw);
$this->password2 = hash("sha512", $pw2);
//Username und Email Überprüfen
$this->sql_username = "SELECT * FROM userdata WHERE username='".$this->username."' ";
$this->sql_email = "SELECT * FROM userdata WHERE password='".$this->password."' ";
$this->row["1"] = mysqli_fetch_array($this->mysqli->query(($this->sql_username)));
$this->row["2"] = mysqli_fetch_array($this->mysqli->query(($this->sql_email)));
if(!$this->row["1"]["id"] == "" || !$this->row["2"]["id"] == "")
{
if(!$this->row["1"]["id"] == "")
{
header("LOCATION: ".$this->domain."?fail=13");
exit;
}
else
{
header("LOCATION: ".$this->domain."?fail=14");
exit;
}
}
if($this->mysqli->query("INSERT INTO userdata (id, username, password, email, delete) VALUES ('', '".$this->username."', '".$this->password."', '".$this->email."', '0')"))
{
echo "Hallo!";
}
}
}
?>
Kommentar