trying to connect to the database
parent
ed9d1349c0
commit
82d9156636
|
@ -51,7 +51,7 @@
|
|||
|
||||
<div class="buttonContainer">
|
||||
<a id="backToHomeButton" href="abmelden_erfolgreich.php">Bestätigen</a>
|
||||
<a id="logInAgainButton" href="meinebuecher.html">Abbrechen</a>
|
||||
<a id="logInAgainButton" href="anmelden_meinebuecher.php">Abbrechen</a>
|
||||
</div>
|
||||
|
||||
<br><br><br>
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
session_start();
|
||||
|
||||
function register($vorname,
|
||||
$nachname ,
|
||||
$strasse,
|
||||
$hausnummer,
|
||||
$plz,
|
||||
$ort,
|
||||
$email,
|
||||
$passwort,){
|
||||
|
||||
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);
|
||||
$kartenid = 100000000;
|
||||
$id=1;
|
||||
//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,AdressenID, Passwort) VALUES ('". $vorname ."' , '". $nachname ."' ,'". $kartenid ."' , '". $email ."', '". $id ."','". $passwort ."')");
|
||||
runSQL("INSERT INTO adresse (Stadt, Postleitzahl, Straße, Hausnummer) VALUES ('". $ort ."' , '". $plz ."' ,'". $strasse ."' , '". $hausnummer ."')");
|
||||
return 'der Benutzer wurde erfolgreich registriert';
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
$servername = "localhost";
|
||||
$username = "web_b-3";
|
||||
$password = "een7Ao6s";
|
||||
$dbname = "bibliothek_candle";
|
||||
|
||||
// Create a connection
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Check the connection
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
|
||||
// Assume you have a table named 'users' with columns 'name' and 'email'
|
||||
|
||||
$vorname = $_POST["vorName"];
|
||||
$nachname = $_POST['nachName'];
|
||||
$strasse = $_POST['strasse'];
|
||||
$hausnummer = $_POST['hausnummer'];
|
||||
$plz = $_POST['postleitzahl'];
|
||||
$ort = $_POST['ort'];
|
||||
$email = $_POST['email'];
|
||||
$passwort = $_POST['passwort'];
|
||||
$kartenid = 1;
|
||||
$id = 1;
|
||||
// Prepare the INSERT statement
|
||||
$stmt = $conn->prepare("INSERT INTO benutzer (VorName, NachName, KartenID, E-MailAdresse,AdressenID, Passwort) VALUES ('". $vorname ."' , '". $nachname ."' ,'". $kartenid ."' , '". $email ."', '". $id ."','". $passwort ."')");
|
||||
|
||||
// Execute the statement
|
||||
if ($stmt->execute()) {
|
||||
echo "Data inserted successfully.";
|
||||
} else {
|
||||
echo "Error inserting data: " . $stmt->error;
|
||||
}
|
||||
|
||||
// Close the statement and connection
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
|
@ -1,6 +1,10 @@
|
|||
<?php
|
||||
$db_link = mysqli_connect('localhost', 'web_b-3', 'een7Ao6s', 'bibliothek_candle', '3306');
|
||||
|
||||
if(!$db_link){
|
||||
die("<p>Verbindung nicht hergestellt</p>");
|
||||
}else{
|
||||
echo("<p>Verbindung wurde hergestellt</p>");
|
||||
}
|
||||
function runSQL($sql){
|
||||
global $db_link;
|
||||
$db_res = mysqli_query($db_link, $sql) or die("SQL_Abfrage: " . $sql . "Fehler: " . mysqli_error($db_link));
|
||||
|
@ -8,42 +12,4 @@
|
|||
}
|
||||
|
||||
|
||||
$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 ."')");
|
||||
$kartenid = $kartenid + 1;
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
session_start();
|
||||
require('anmeldesystem.php');
|
||||
require('connect_db.php');
|
||||
if(isset($_POST['Registrieren'])){
|
||||
$vorname = $_POST["vorName"];
|
||||
$nachname = $_POST['nachName'];
|
||||
|
@ -191,62 +193,19 @@ if(isset($_POST['Registrieren'])){
|
|||
</body>
|
||||
|
||||
</html>';
|
||||
$db_link = mysqli_connect('localhost', 'web_b-3', 'een7Ao6s', 'bibliothek_candle', '3306');
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
$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 ."')");
|
||||
$kartenid = $kartenid + 1;
|
||||
}
|
||||
|
||||
register($vorname,
|
||||
$erg = register($vorname,
|
||||
$nachname ,
|
||||
$strasse,
|
||||
$hausnummer,
|
||||
$plz,
|
||||
$ort,
|
||||
$emailrep,
|
||||
$email,
|
||||
$passwort,
|
||||
$passwortrep);
|
||||
$passwort,);
|
||||
|
||||
|
||||
echo '<p> . $erg . </p>';
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue