php insert statement is not working and code is beeing ignored [duplicate]












0
















This question already has an answer here:




  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



  • How to display errors for my MySQLi query? [duplicate]

    3 answers




I'm working on a simple register page to learn php but i have 2 big problems




  1. When I press register i get this error: Error:INSERT INTO users (username, password) VALUES (hello12345, hello12345)
    Unknown column 'hello12345' in 'field list'


  2. My if statements which checks the username/password length, and the ones which check if password and confirm password match are beeing ignored



My database table looks like this:



CREATE TABLE users (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
);


and the php is



include("config.php");



$username = "";
$password = "";
$passwordConfirm = "";
$usernameError = "";
$passwordError ="";
$passwordConfirmError ="";


if($_SERVER["REQUEST_METHOD"] == "POST"){




if(empty(trim($_POST["username"]))) {
$usernameError = "Bitte geben Sie einen Benutzernamen ein";
}else {
$username = trim($_POST["username"]);
}
}



if(empty(trim($_POST["password"]))) {
$passwordError = "Bitte geben Sie ein Passwort ein";
} elseif (strlen(trim($_POST["password"])) < 6) {
$passwordError = "Password muss mindestens 6 Zeichen lang sein";
} else {
$password = trim($_POST["password"]);
}



if(empty(trim($_POST["passwordConfirm"]))) {
$passwordError = "Bitte bestätigen Sie ihr Passwort.";
} else {
$passwordConfirm = trim($_POST["passwordConfirm"]);
if($password != $passwordConfirm) {
$passwordConfirmError = "Passwörter stimmen nicht überein";
}
}


if(empty($usernameError) && empty($passwordError) && empty($passwordConfirmError)) {


$sqlStatement = "INSERT INTO users (username, password)
VALUES ($username, $password)";



if(mysqli_query($connection, $sqlStatement)) {
echo "Registrierung erfolgreich";
} else {
echo "Error:" .$sqlStatement . "<br>" . mysqli_error($connection);
}
}

?>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Registrieren </title>
</head>
<body>

<div>
<h2>Registrieren</h2>
<p>Bitte erstelle eine Account</p>
<form action="register.php" method="post">
<input type="text" name="username" placeholder="Benutzername">
<input type="text" name="password" placeholder="Passwort">
<input type="text" name="passwordConfirm" placeholder="Passwort bestätigen">
<br>
<button type="submit" name="submit" value="submit">Registrieren</button>
<br>
</form>
</div>
</body>
</html>









share|improve this question















marked as duplicate by Funk Forty Niner mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 1:24


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • username, password =2 DEFAULT, hello12345, hello12345 =3, 2 != 3

    – user10226920
    Nov 23 '18 at 1:24













  • whats not clear about the error message ??? you pass three values, but only have two fields in the field list.

    – YvesLeBorg
    Nov 23 '18 at 1:25











  • Take out DEFAULT. Strings need to be quoted. Don't store plain text passwords. Parameterize your query.

    – user3783243
    Nov 23 '18 at 1:25













  • Not sure what you mean by are beeing ignored. Maybe you aren't sending a POST?

    – user3783243
    Nov 23 '18 at 1:26











  • i took out DEFAULT now I get this error message: Error:INSERT INTO users (username, password) VALUES (hello12345, hello12345) Unknown column 'fdai5106' in 'field list'

    – JangoCG
    Nov 23 '18 at 1:30
















0
















This question already has an answer here:




  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



  • How to display errors for my MySQLi query? [duplicate]

    3 answers




I'm working on a simple register page to learn php but i have 2 big problems




  1. When I press register i get this error: Error:INSERT INTO users (username, password) VALUES (hello12345, hello12345)
    Unknown column 'hello12345' in 'field list'


  2. My if statements which checks the username/password length, and the ones which check if password and confirm password match are beeing ignored



My database table looks like this:



CREATE TABLE users (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
);


and the php is



include("config.php");



$username = "";
$password = "";
$passwordConfirm = "";
$usernameError = "";
$passwordError ="";
$passwordConfirmError ="";


if($_SERVER["REQUEST_METHOD"] == "POST"){




if(empty(trim($_POST["username"]))) {
$usernameError = "Bitte geben Sie einen Benutzernamen ein";
}else {
$username = trim($_POST["username"]);
}
}



if(empty(trim($_POST["password"]))) {
$passwordError = "Bitte geben Sie ein Passwort ein";
} elseif (strlen(trim($_POST["password"])) < 6) {
$passwordError = "Password muss mindestens 6 Zeichen lang sein";
} else {
$password = trim($_POST["password"]);
}



if(empty(trim($_POST["passwordConfirm"]))) {
$passwordError = "Bitte bestätigen Sie ihr Passwort.";
} else {
$passwordConfirm = trim($_POST["passwordConfirm"]);
if($password != $passwordConfirm) {
$passwordConfirmError = "Passwörter stimmen nicht überein";
}
}


if(empty($usernameError) && empty($passwordError) && empty($passwordConfirmError)) {


$sqlStatement = "INSERT INTO users (username, password)
VALUES ($username, $password)";



if(mysqli_query($connection, $sqlStatement)) {
echo "Registrierung erfolgreich";
} else {
echo "Error:" .$sqlStatement . "<br>" . mysqli_error($connection);
}
}

?>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Registrieren </title>
</head>
<body>

<div>
<h2>Registrieren</h2>
<p>Bitte erstelle eine Account</p>
<form action="register.php" method="post">
<input type="text" name="username" placeholder="Benutzername">
<input type="text" name="password" placeholder="Passwort">
<input type="text" name="passwordConfirm" placeholder="Passwort bestätigen">
<br>
<button type="submit" name="submit" value="submit">Registrieren</button>
<br>
</form>
</div>
</body>
</html>









share|improve this question















marked as duplicate by Funk Forty Niner mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 1:24


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • username, password =2 DEFAULT, hello12345, hello12345 =3, 2 != 3

    – user10226920
    Nov 23 '18 at 1:24













  • whats not clear about the error message ??? you pass three values, but only have two fields in the field list.

    – YvesLeBorg
    Nov 23 '18 at 1:25











  • Take out DEFAULT. Strings need to be quoted. Don't store plain text passwords. Parameterize your query.

    – user3783243
    Nov 23 '18 at 1:25













  • Not sure what you mean by are beeing ignored. Maybe you aren't sending a POST?

    – user3783243
    Nov 23 '18 at 1:26











  • i took out DEFAULT now I get this error message: Error:INSERT INTO users (username, password) VALUES (hello12345, hello12345) Unknown column 'fdai5106' in 'field list'

    – JangoCG
    Nov 23 '18 at 1:30














0












0








0









This question already has an answer here:




  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



  • How to display errors for my MySQLi query? [duplicate]

    3 answers




I'm working on a simple register page to learn php but i have 2 big problems




  1. When I press register i get this error: Error:INSERT INTO users (username, password) VALUES (hello12345, hello12345)
    Unknown column 'hello12345' in 'field list'


  2. My if statements which checks the username/password length, and the ones which check if password and confirm password match are beeing ignored



My database table looks like this:



CREATE TABLE users (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
);


and the php is



include("config.php");



$username = "";
$password = "";
$passwordConfirm = "";
$usernameError = "";
$passwordError ="";
$passwordConfirmError ="";


if($_SERVER["REQUEST_METHOD"] == "POST"){




if(empty(trim($_POST["username"]))) {
$usernameError = "Bitte geben Sie einen Benutzernamen ein";
}else {
$username = trim($_POST["username"]);
}
}



if(empty(trim($_POST["password"]))) {
$passwordError = "Bitte geben Sie ein Passwort ein";
} elseif (strlen(trim($_POST["password"])) < 6) {
$passwordError = "Password muss mindestens 6 Zeichen lang sein";
} else {
$password = trim($_POST["password"]);
}



if(empty(trim($_POST["passwordConfirm"]))) {
$passwordError = "Bitte bestätigen Sie ihr Passwort.";
} else {
$passwordConfirm = trim($_POST["passwordConfirm"]);
if($password != $passwordConfirm) {
$passwordConfirmError = "Passwörter stimmen nicht überein";
}
}


if(empty($usernameError) && empty($passwordError) && empty($passwordConfirmError)) {


$sqlStatement = "INSERT INTO users (username, password)
VALUES ($username, $password)";



if(mysqli_query($connection, $sqlStatement)) {
echo "Registrierung erfolgreich";
} else {
echo "Error:" .$sqlStatement . "<br>" . mysqli_error($connection);
}
}

?>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Registrieren </title>
</head>
<body>

<div>
<h2>Registrieren</h2>
<p>Bitte erstelle eine Account</p>
<form action="register.php" method="post">
<input type="text" name="username" placeholder="Benutzername">
<input type="text" name="password" placeholder="Passwort">
<input type="text" name="passwordConfirm" placeholder="Passwort bestätigen">
<br>
<button type="submit" name="submit" value="submit">Registrieren</button>
<br>
</form>
</div>
</body>
</html>









share|improve this question

















This question already has an answer here:




  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



  • How to display errors for my MySQLi query? [duplicate]

    3 answers




I'm working on a simple register page to learn php but i have 2 big problems




  1. When I press register i get this error: Error:INSERT INTO users (username, password) VALUES (hello12345, hello12345)
    Unknown column 'hello12345' in 'field list'


  2. My if statements which checks the username/password length, and the ones which check if password and confirm password match are beeing ignored



My database table looks like this:



CREATE TABLE users (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
);


and the php is



include("config.php");



$username = "";
$password = "";
$passwordConfirm = "";
$usernameError = "";
$passwordError ="";
$passwordConfirmError ="";


if($_SERVER["REQUEST_METHOD"] == "POST"){




if(empty(trim($_POST["username"]))) {
$usernameError = "Bitte geben Sie einen Benutzernamen ein";
}else {
$username = trim($_POST["username"]);
}
}



if(empty(trim($_POST["password"]))) {
$passwordError = "Bitte geben Sie ein Passwort ein";
} elseif (strlen(trim($_POST["password"])) < 6) {
$passwordError = "Password muss mindestens 6 Zeichen lang sein";
} else {
$password = trim($_POST["password"]);
}



if(empty(trim($_POST["passwordConfirm"]))) {
$passwordError = "Bitte bestätigen Sie ihr Passwort.";
} else {
$passwordConfirm = trim($_POST["passwordConfirm"]);
if($password != $passwordConfirm) {
$passwordConfirmError = "Passwörter stimmen nicht überein";
}
}


if(empty($usernameError) && empty($passwordError) && empty($passwordConfirmError)) {


$sqlStatement = "INSERT INTO users (username, password)
VALUES ($username, $password)";



if(mysqli_query($connection, $sqlStatement)) {
echo "Registrierung erfolgreich";
} else {
echo "Error:" .$sqlStatement . "<br>" . mysqli_error($connection);
}
}

?>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Registrieren </title>
</head>
<body>

<div>
<h2>Registrieren</h2>
<p>Bitte erstelle eine Account</p>
<form action="register.php" method="post">
<input type="text" name="username" placeholder="Benutzername">
<input type="text" name="password" placeholder="Passwort">
<input type="text" name="passwordConfirm" placeholder="Passwort bestätigen">
<br>
<button type="submit" name="submit" value="submit">Registrieren</button>
<br>
</form>
</div>
</body>
</html>




This question already has an answer here:




  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



  • How to display errors for my MySQLi query? [duplicate]

    3 answers








php mysql database






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 1:32







JangoCG

















asked Nov 23 '18 at 1:22









JangoCGJangoCG

285




285




marked as duplicate by Funk Forty Niner mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 1:24


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Funk Forty Niner mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 1:24


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • username, password =2 DEFAULT, hello12345, hello12345 =3, 2 != 3

    – user10226920
    Nov 23 '18 at 1:24













  • whats not clear about the error message ??? you pass three values, but only have two fields in the field list.

    – YvesLeBorg
    Nov 23 '18 at 1:25











  • Take out DEFAULT. Strings need to be quoted. Don't store plain text passwords. Parameterize your query.

    – user3783243
    Nov 23 '18 at 1:25













  • Not sure what you mean by are beeing ignored. Maybe you aren't sending a POST?

    – user3783243
    Nov 23 '18 at 1:26











  • i took out DEFAULT now I get this error message: Error:INSERT INTO users (username, password) VALUES (hello12345, hello12345) Unknown column 'fdai5106' in 'field list'

    – JangoCG
    Nov 23 '18 at 1:30



















  • username, password =2 DEFAULT, hello12345, hello12345 =3, 2 != 3

    – user10226920
    Nov 23 '18 at 1:24













  • whats not clear about the error message ??? you pass three values, but only have two fields in the field list.

    – YvesLeBorg
    Nov 23 '18 at 1:25











  • Take out DEFAULT. Strings need to be quoted. Don't store plain text passwords. Parameterize your query.

    – user3783243
    Nov 23 '18 at 1:25













  • Not sure what you mean by are beeing ignored. Maybe you aren't sending a POST?

    – user3783243
    Nov 23 '18 at 1:26











  • i took out DEFAULT now I get this error message: Error:INSERT INTO users (username, password) VALUES (hello12345, hello12345) Unknown column 'fdai5106' in 'field list'

    – JangoCG
    Nov 23 '18 at 1:30

















username, password =2 DEFAULT, hello12345, hello12345 =3, 2 != 3

– user10226920
Nov 23 '18 at 1:24







username, password =2 DEFAULT, hello12345, hello12345 =3, 2 != 3

– user10226920
Nov 23 '18 at 1:24















whats not clear about the error message ??? you pass three values, but only have two fields in the field list.

– YvesLeBorg
Nov 23 '18 at 1:25





whats not clear about the error message ??? you pass three values, but only have two fields in the field list.

– YvesLeBorg
Nov 23 '18 at 1:25













Take out DEFAULT. Strings need to be quoted. Don't store plain text passwords. Parameterize your query.

– user3783243
Nov 23 '18 at 1:25







Take out DEFAULT. Strings need to be quoted. Don't store plain text passwords. Parameterize your query.

– user3783243
Nov 23 '18 at 1:25















Not sure what you mean by are beeing ignored. Maybe you aren't sending a POST?

– user3783243
Nov 23 '18 at 1:26





Not sure what you mean by are beeing ignored. Maybe you aren't sending a POST?

– user3783243
Nov 23 '18 at 1:26













i took out DEFAULT now I get this error message: Error:INSERT INTO users (username, password) VALUES (hello12345, hello12345) Unknown column 'fdai5106' in 'field list'

– JangoCG
Nov 23 '18 at 1:30





i took out DEFAULT now I get this error message: Error:INSERT INTO users (username, password) VALUES (hello12345, hello12345) Unknown column 'fdai5106' in 'field list'

– JangoCG
Nov 23 '18 at 1:30












0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen