0

I created a bootstrap form and want to include the data from the form into my database. My problem is that it is not working and I have no idea why. In my opinion everything is correct. I am looking for hours now but I can't find the issue.

You can find my form here: http://schulkantine.ccsolution.at/registration.php Please do not look at the style, I have to customize it later.

Here is my register.php! Database connection is working.

<?php // Create connection credentials $db_host = 'localhost'; $db_name = 'DBNAME'; $db_user = 'DBUSER'; $db_pass = 'DBPASSWORD'; // Create mysqli object $connect = new mysqli ($db_host, $db_user, $db_pass, $db_name); // Error Handler if ($connect->connect_error) { printf ("Connection failed: %s\n", $connect->connect_error); exit(); } ?> <?php // Check if form is submitted if (isset ($_POST['submit'])) { $anrede = mysqli_real_escape_string ($connect, $_POST['anrede']); $vorname = mysqli_real_escape_string ($connect, $_POST['vorname']); $nachname = mysqli_real_escape_string ($connect, $_POST['nachname']); $strasse = mysqli_real_escape_string ($connect, $_POST['strasse']); $plz = mysqli_real_escape_string ($connect, $_POST['plz']); $ort = mysqli_real_escape_string ($connect, $_POST['ort']); $email = mysqli_real_escape_string ($connect, $_POST['email']); $telefon = mysqli_real_escape_string ($connect, $_POST['telefon']); // Validate Input $query = mysql_query("INSERT INTO user (anrede, firstname_parent, lastname_parent, street_parent, plz_parent, city_parent, email, phonenumber_parent) VALUES ('$anrede', '$vorname', '$nachname', '$strasse', '$plz', '$ort', '$email', '$telefon')") or die(mysql_error()); } ?> 

Hope someone can help me and tell me what my error is!

2 Answers 2

3

Try changing

INSERT INTO user (anrede, firstname_parent, lastname_parent, street_parent, plz_parent, city_parent, email, phonenumber_parent) VALUES ('$anrede', '$vorname', '$nachname', '$strasse', '$plz', '$ort', '$email', '$telefon')" 

to

INSERT INTO `user` (`anrede`, `firstname_parent`, `lastname_parent`, `street_parent`, `plz_parent`, `city_parent`, `email`, `phonenumber_parent`) VALUES ('$anrede', '$vorname', '$nachname', '$strasse', '$plz', '$ort', '$email', '$telefon')" 
Sign up to request clarification or add additional context in comments.

Comments

1

Replace this line in your registration.php file. You forget to add "name" attribute so your condition if (isset ($_POST['submit'])) not work.

 <button type="submit" name="submit" value="submit" class="btn btn-custom pull-right">Send</button> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.