按“提交”时未保存数据(注意:第18行C:\xampp\htdocs\C.W\register.php中的未定义索引:firstname)

按“提交”时未保存数据(注意:第18行C:\xampp\htdocs\C.W\register.php中的未定义索引:firstname),php,mysql,Php,Mysql,帮助!!!!用以下代码更新您的代码: Notice: Undefined index: firstname in C:\xampp\htdocs\C.W\register.php on line 18 Notice: Undefined index: lastname in C:\xampp\htdocs\C.W\register.php on line 19 Notice: Undefined index: email in C:\xampp\htdocs\C.W\register.php o

帮助!!!!

用以下代码更新您的代码:

Notice: Undefined index: firstname in C:\xampp\htdocs\C.W\register.php on line 18
Notice: Undefined index: lastname in C:\xampp\htdocs\C.W\register.php on line 19
Notice: Undefined index: email in C:\xampp\htdocs\C.W\register.php on line 20
Notice: Undefined index: phn_number in C:\xampp\htdocs\C.W\register.php on line 21
Notice: Undefined index: password in C:\xampp\htdocs\C.W\register.php on line 22
您的html表单的格式应为,请更新您的html表单:

 if($link->connect_error){
  die ("connection failed: " . $link->connect_error);
  }

$sql ="INSERT INTO user (firstname, lastname, email, phn_number, password) VALUES ('Dinanath', 'Thakur', 'dina@example.com', 123456789, 'xyz')";

名字:


姓氏:

电邮:

电话号码:

密码:


您可能忘记包含以下内容:

form action=“name\u of\u your\u php\u file.php”method=“POST”

将此代码插入到您上面提供的代码中,我们将得到:

<p>
    <label for="firstname"> First Name: </label>
    <input type="text" name="firstname" id="firstname"> <br/> <br/>
    <label for="lastname"> Last Name: </label>
    <input type="text" name="lastname" id="lastname"> <br/> <br/>
    <label for="email"> E-mail: </label>
    <input type="text" name="email" id="email"> <br/> <br/>
    <label for="phn_number"> Phone Number: </label>
    <input type="text" name="phn_number" id="phn_number"> <br/> <br/>
    <label for="password"> Password: </label>
    <input type="text" name="password" id="password">
</p>
<input type="submit" value="Sign Up">

名字:


姓氏:

电子邮件:

电话号码:

密码:


这很有效,谢谢!!但是现在出现了另一个错误(注意:未定义的索引:第18行C:\xampp\htdocs\C.W\register.php中的firstname),但是还有其他错误(注意:未定义索引:C:\xampp\htdocs\C.W\register.php第18行中的firstname注意:未定义索引:C:\xampp\htdocs\C.W\register.php第19行中的lastname注意:未定义索引:C:\xampp\htdocs\C.W\register.php第20行中的电子邮件注意:未定义索引:C:\xampp\htdocs\C.W\register.php第21行中的phn_编号注意:未定义index:C:\xampp\htdocs\C.W\register.php中的密码(第22行)问题出在您的查询中:请尝试以下格式:
$sql=“插入用户(名字、姓氏、电子邮件、phn\U编号、密码)值('Dinanath'、'Thakur'、'dina@example.com“,123456789,'xyz')”
名字:

姓氏:

电子邮件:


电话号码:

密码:

相同错误:未定义方法
<p>
    <label for="firstname"> First Name: </label>
    <input type="text" name="firstname" id="firstname"> <br/> <br/>
    <label for="lastname"> Last Name: </label>
    <input type="text" name="lastname" id="lastname"> <br/> <br/>
    <label for="email"> E-mail: </label>
    <input type="text" name="email" id="email"> <br/> <br/>
    <label for="phn_number"> Phone Number: </label>
    <input type="text" name="phn_number" id="phn_number"> <br/> <br/>
    <label for="password"> Password: </label>
    <input type="text" name="password" id="password">
</p>
<input type="submit" value="Sign Up">
<form action="name_of_your_php_file.php" method="POST">
<p> <label for "firstname"> First Name: </label>
<input type="text" name"firstname" id="firstname"> <br/ > <br/ > 
<label for "lastname"> Last Name: </label> <input type="text" name"lastname" id="lastname"> <br/ > <br/ > 
<label for "email"> E-mail: </label> <input type="text" name"email" id="email"> <br/ > <br/ >
<label for "phn_number"> Phone Number: </label> <input type="text" name"phn_number" id="phn_number"> <br/ > <br/ > <label for "password"> Password: </label>
<input type="text" name"password" id="password"> </p>
<input type="submit" value="Sign Up"></form>
if($link->connect_error){

die ("connection failed: " . $link->connect_error);

}

$fname = $_POST['fname'];

$lname = $_POST['lname'];

$email = $_POST['email'];

$pno = $_POST['pno'];

$pass = $_POST['pass'];

$sql ="INSERT INTO user (firstname, lastname, email, phn_number, password)     VALUES ('$fname', '$lname', '$email', '$pno', '$pass')";

$res = mysql_query($sql);