我想DIY一个php测验,当你满级时,你可以将你的信息输入到我的数据库中,但是当我填写表格并放入sumbit时。有这个错误~
注意:未定义索引:第 19 行 C:\xampp\htdocs\record.php 中的名字
注意:未定义索引:第 19 行 C:\xampp\htdocs\record.php 中的姓氏
注意:未定义的索引:年龄在 C:\xampp\htdocs\record.php 第 19 行 mysql_connect.inc.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
//資料庫設定
//資料庫位置
$db_server = "localhost";
//資料庫名稱
$db_name = "quiz";
//資料庫管理者帳號
$db_user = "root";
//資料庫管理者密碼
$db_passwd = "123456";
//對資料庫連線
if(!@mysql_connect($db_server, $db_user, $db_passwd))
die("can't connect mysql");
//資料庫連線採UTF8
mysql_query("SET NAMES utf8");
//選擇資料庫
if(!@mysql_select_db($db_name))
die("can't connect db");
?>
记录.php
<?php ?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
session_start();
include("mysql_connect.inc.php");
$con = mysql_connect("localhost","root","123456");
mysql_query("INSERT INTO Persons (FirstName, LastName, Age)
VALUES ('Peter', 'Griffin', '35')");
mysql_query("INSERT INTO Persons (FirstName, LastName, Age)
VALUES ('Glenn', 'Quagmire', '33')");
$sql="INSERT INTO Persons (FirstName, LastName, Age)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";
mysql_close($con)
?>
进程.php
<html>
<head>
<style type="text/css">
#wrapper {
width:950px;
height:auto;
padding: 13px;
margin-right:auto;
margin-left:auto;
background-color:#fff;
}
</style>
</head>
<?php
$fid = $_GET['id'];
?>
<body bgcolor="#e1e1e1">
<div id="wrapper">
<center><font face="Andalus" size="5">Your Score</font></center>
<br />
<br />
<?php
$answer1= $_POST['answerOne'];
$answer2= $_POST['answerTwo'];
$answer3= $_POST['answerThree'];
$score = 0;
if ($answer1 == "A"){$score++;}
if ($answer2 == "B"){$score++;}
if ($answer3 == "C"){$score++;}
echo "<center><font face='Berlin Sans FB' size='8'>Your Score is <br> $score/3</font></center>";
?>
<br>
<br>
<Center>
<?php
if ($score == 3)
{
echo "
<form action='record.php' method='post' >
ID: <input type='text' id='firstname'/><br>
Phone: <input type='text' id='lastname'/><br>
E-mail: <input type='text' id='age'/><br><br>
<input type='submit' value='Submit Data' />
</form> ";
}
?>
</Center>
</div><!--- end of wrapper div --->
</body>
</html>