Note that there are some explanatory texts on larger screens.

plurals
  1. POthe form value can't input to mysql, but can connect mysql (PHP)
    primarykey
    data
    text
    <p>I want to diy a php quiz, when you have full grade, you may input your information to my database, but when I have filled the form and put the sumbit. Have this error~</p> <p>Notice: Undefined index: firstname in C:\xampp\htdocs\record.php on line 19</p> <p>Notice: Undefined index: lastname in C:\xampp\htdocs\record.php on line 19</p> <p>Notice: Undefined index: age in C:\xampp\htdocs\record.php on line 19 mysql_connect.inc.php</p> <pre><code>&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;?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"); ?&gt; </code></pre> <p>record.php</p> <pre><code>&lt;?php ?&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;?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) ?&gt; </code></pre> <p>process.php</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; #wrapper { width:950px; height:auto; padding: 13px; margin-right:auto; margin-left:auto; background-color:#fff; } &lt;/style&gt; &lt;/head&gt; &lt;?php $fid = $_GET['id']; ?&gt; &lt;body bgcolor="#e1e1e1"&gt; &lt;div id="wrapper"&gt; &lt;center&gt;&lt;font face="Andalus" size="5"&gt;Your Score&lt;/font&gt;&lt;/center&gt; &lt;br /&gt; &lt;br /&gt; &lt;?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 "&lt;center&gt;&lt;font face='Berlin Sans FB' size='8'&gt;Your Score is &lt;br&gt; $score/3&lt;/font&gt;&lt;/center&gt;"; ?&gt; &lt;br&gt; &lt;br&gt; &lt;Center&gt; &lt;?php if ($score == 3) { echo " &lt;form action='record.php' method='post' &gt; ID: &lt;input type='text' id='firstname'/&gt;&lt;br&gt; Phone: &lt;input type='text' id='lastname'/&gt;&lt;br&gt; E-mail: &lt;input type='text' id='age'/&gt;&lt;br&gt;&lt;br&gt; &lt;input type='submit' value='Submit Data' /&gt; &lt;/form&gt; "; } ?&gt; &lt;/Center&gt; &lt;/div&gt;&lt;!--- end of wrapper div ---&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload