Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
sql geht nicht
#1
Ich schreibe dein Problem mal hier  rein weil es vieleicht noch andere gibt die das auch haben



PHP-Code:
<?php
error_reporting
(E_ALL); 
ini_set('display_errors'true);
$pdo = new PDO('mysql:host=localhost:3306;dbname=auftrag''Name''Passwort');
?>
<!DOCTYPE html> 
<html> 
<head>
  <title>Hairlich | Registrierung</title> 
</head> 
<body>
<?php
$showFormular 
true;
if(isset(
$_POST['register'])) {
 
$error false;
 
$email $_POST['email'];
 
$preis $_POST['preis'];
 
 $staff $_POST['staff'];
 if(!
filter_var($email)) {
 echo 
'<p class="error"><b>Bitte einen gültigen Benutzernamen angeben</b></p><br>';
 
$error true;
 } 
 if(!
$error) { 
 
$statement $pdo->prepare("SELECT * FROM register WHERE email = :email");
 
$result $statement->execute(array('email' => $email));
 
$user $statement->fetch();
 if(
$user !== false) {
 echo 
'<p class="error"><b>Dieser Benutzername ist bereits vergeben</b></p>';
 
$error true;
 } 
 }
 if(!
$error) { 
 
$statement $pdo->prepare("INSERT INTO register (email, preis, staff) VALUES (:email, :preis, :staff)");
 
$result $statement->execute(array('email' => $email'preis' => $preis'staff' => $staff));
 if(
$result) { 
 echo 
'
 
 <br><h1>Du wurdest erfolgreich registriert. </h1><a href="login.php"><button>zum Login</button></a>'
;
 
$showFormular false;
 } else {
 
var_dump($result);
var_dump($statement);
 }
 } 
}
if(
$showFormular) {
?>
 <br><br><br><br>
 <br><br><br><br>
<form action="registrieren.php" method="post">
Benutzername:<br>
<input type="text" size="40" maxlength="250" name="email" placeholder="Wähle einen Benutzernamen..."><br><br>
Dein Passwort:<br>
<input type="text" size="40"  maxlength="250" name="passwort" placeholder="Wähle ein Passwort..."><br>
Passwort wiederholen:<br>
<input type="text" size="40" maxlength="250" name="passwort2" placeholder="weitere Infos"><br><br>
Eingeloggt bleiben?<br>
 <select class="" name="staff">
 <option value="false">Diese Option kommt bald</option>
 </select>
 <br><br>
 
 <input name="register" type="submit" value="Registrieren">
</form>
<?php
//Ende von if($showFormular)
?>
 
<br>
 <a href="login.php" class="alreadyreg">Bereits registriert? -> Anmelden</a>
 
 <style>
body {font-family: Arial, Helvetica, sans-serif; text-align: center; background-color: #E6E6E6;}
input[type=text], select, textarea {
 width: 30%;
 padding: 12px;
 border: 1px solid #ccc;
 border-radius: 4px;
 box-sizing: border-box;
 margin-top: 6px;
 margin-bottom: 16px;
 resize: vertical;
}
 
 input[type=password]{
 width: 30%;
 padding: 12px;
 border: 1px solid #ccc;
 border-radius: 4px;
 box-sizing: border-box;
 margin-top: 6px;
 margin-bottom: 16px;
 resize: vertical;
}
input[type=submit] {
   background-color: #578e8c;
 color: white;
 padding: 12px 20px;
 border: none;
 border-radius: 4px;
 cursor: pointer;
 opacity: 0.8;
}
input[type=submit]:hover {
 background-color: #578e8c;
 opacity: 1.0;
}
.container {
 border-radius: 5px;
 background-color: #f2f2f2;
 padding: 20px;
}
 
 
 
 button{
  background:#1AAB8A;
  color:#fff;
  border:none;
  position:relative;
  height:60px;
  font-size:1.6em;
  padding:0 2em;
  cursor:pointer;
  transition:800ms ease all;
  outline:none;
}
button:hover{
  background:#E6E6E6;
  color:#1AAB8A;
}
button:before,button:after{
  content:'';
  position:absolute;
  top:0;
  right:0;
  height:2px;
  width:0;
  background: #1AAB8A;
  transition:400ms ease all;
}
button:after{
  right:inherit;
  top:inherit;
  left:0;
  bottom:0;
}
button:hover:before,button:hover:after{
  width:100%;
  transition:800ms ease all;
}
 .error{
 color: red;
 
 }
 .alreadyreg{
 text-decoration: none;
 font-size: 10pt;
 color: black;}
 
 .alreadyreg:hover{
 text-decoration: none;
 font-size: 12pt;
 color: red;}
 
</style>
</body>
</html> 


Jetzt aber, oder? Wo liegt der Fehler?


Error:

Code

  1. [/url]Notice: Undefined index: preis in /var/www/.php on line 18
  2. [url=https://=10533#codeLine_2_6c506f]bool(false) object(PDOStatement)#3 (1) { ["queryString"]=> string(74) "INSERT INTO register (email, preis, staff) VALUES (:email, :preis, Confusedtaff)" }

SoBig Grinu solltest erstmal kucken wo du preis definierst ? Gar nicht. also muß da erstmal ein Preis Feld dazu ,oder du nimmst den Preiss aus den Sql abfrage raus.

Mach das erstmal dann sehen wir weiter
Zitieren


Nachrichten in diesem Thema
sql geht nicht - von admin - 19.04.2022, 00:47
RE: sql geht nicht - von admin - 19.04.2022, 00:48
RE: sql geht nicht - von admin - 19.04.2022, 00:48
RE: sql geht nicht - von admin - 19.04.2022, 00:49
RE: sql geht nicht - von admin - 19.04.2022, 00:49
RE: sql geht nicht - von admin - 19.04.2022, 00:49
RE: sql geht nicht - von admin - 19.04.2022, 00:51
RE: sql geht nicht - von admin - 19.04.2022, 00:51
RE: sql geht nicht - von admin - 19.04.2022, 00:52
RE: sql geht nicht - von admin - 19.04.2022, 00:52
RE: sql geht nicht - von admin - 19.04.2022, 00:53
RE: sql geht nicht - von rzscout - 19.06.2022, 17:54

Gehe zu:


Benutzer, die gerade dieses Thema anschauen:
7 Gast/Gäste