Es gibt eine Seite namens form.html. Es richtet sich an die Seite addtodatabase.php am Ende gibt es Schaltfläche "Senden"wie zu korrigieren Undefinierter Index: Vorname in C: wamp64 www Form addtodatabase.php on line 12 Fehler
<form action="addtodatabase.php" method="post">
<form class="form-inline">
<fieldset>
<legend>Security Department User Registration</legend>
<div class="form-group">
<label for="Firstname">First Name</label>
<input type="text" class="form-control" id="Firstname" name="firstname" placeholder="Text input"><br/>
</div>
<div class="form-group">
<label for="Secondname">Second Name</label>
<input type="text" class="form-control" id="Secondname" name="secondname" placeholder="Text input"><br/>
</div>
</form>
Meine Seite addtodatabase.php.
$connect=mysqli_connect('localhost','root','','form_db');
if(mysqli_connect_errno($connect))
{
echo 'Failed to connect:'.mysqli_connect_error();
}
$firstname="";
$secondname="";
if (isset($_POST)) {
$firstname = isset($_POST['firstname']) ? $_POST['firstname'] : '';
$secondname = isset($_POST['secondname']) ? $_POST['secondname'] : '';
echo 'Your first name is ' .$firstname. '<br>';
echo 'Your second name is ' .$secondname. '<br>';
}
Es gibt drei Fehler
es nicht auf die Seite
addtodatabase.php
bekommt. http://localhost:8080/form/form.html?
Hinweis: Undefinierter Index: Vorname in C: \ wamp64 \ www \ Form \ addtodatabase.php in Zeile 12. wird nichts zur Datenbank hinzugefügt. Nur ID ist Inkrement
Vielen Dank im Voraus.
Ich glaube, Sie Submit-Button verpasst .. – sunilwananje
Wenn Sie dort nicht bekommen, wie bekommt man den Fehler/Hinweis ? Warum sollte '$ firstname = $ _ POST ['firstname'];' zweimal vergeben werden? – chris85
Mögliches Duplikat von [PHP: "Notice: Undefinierte Variable", "Notice: Undefinierter Index" und "Notice: Undefined Offset"] (http://stackoverflow.com/questions/4261133/php-notice-undefined-variable- notice-undefined-index-and-notice-undef) – chris85