Candle/connect_db.php

49 lines
1.7 KiB
PHP
Raw Normal View History

2023-05-26 16:39:10 +02:00
<?php
$db_link = mysqli_connect('localhost', 'web_b-3', 'een7Ao6s', 'bibliothek_candle', '3306');
2023-05-26 16:39:10 +02:00
function runSQL($sql){
global $db_link;
$db_res = mysqli_query($db_link, $sql) or die("SQL_Abfrage: " . $sql . "Fehler: " . mysqli_error($db_link));
return $db_res;
}
2023-05-30 13:54:44 +02:00
$kartenid = 1000000000000000;
function register($vorname,
$nachname ,
$strasse,
$hausnummer,
$plz,
$ort,
$emailrep,
$email,
$passwort,
$passwortrep){
global $db_link;
$vorname = mysqli_real_escape_string($db_link, $vorname);
$nachname = mysqli_real_escape_string($db_link, $nachname);
$email = mysqli_real_escape_string($db_link, $email);
$passwort = md5( $passwort);
$ort = mysqli_real_escape_string($db_link, $ort);
$plz = mysqli_real_escape_string($db_link, $plz);
$strasse = mysqli_real_escape_string($db_link, $strasse);
$hausnummer = mysqli_real_escape_string($db_link, $hausnummer);
//Benutzer schon vorhanden?
$db_res = runSQL("SELECT COUNT(*) FROM benutzer WHERE E-MailAdresse='" . $email . "'");
$row = mysqli_fetch_array($db_res);
if($row['COUNT(*)'] > 0)
{
return 'Es gibt schon einen Benutzer mit der angegebenen E-Mail Adresse';
}
runSQL("INSERT INTO benutzer (VorName, NachName, KartenID, E-MailAdresse, Passwort) VALUES ('". $vorname ."' , '". $nachname ."' ,'". $kartenid ."' , '". $email ."', '". $passwort ."')");
runSQL("INSERT INTO adresse (Stadt, Postleitzahl, Straße, Hausnummer) VALUES ('". $ort ."' , '". $plz ."' ,'". $strasse ."' , '". $hausnummer ."')");
2023-05-30 21:51:35 +02:00
$kartenid = $kartenid + 1;
2023-05-30 13:54:44 +02:00
}
2023-05-30 21:51:35 +02:00
2023-05-26 16:39:10 +02:00
?>