「未定義変数:C:\ xampp \ htdocs \ online test \ study_question1.phpの15行目のテーブル」のエラーが発生するそれ。PHPテーブルスクリプトを作成してデータをテーブルに挿入
<?php
$connection = mysqli_connect('localhost','root','','userquestion') or die(mysqli_error($connection));
define("table","table_name");
if(isset($_POST['next'])){
$table=$_POST['table_name'];
$query= "CREATE TABLE `userquestion`.`$table` (`id` INT(15) NOT NULL AUTO_INCREMENT , `question` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL , `option1` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL , `option2` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL , `option3` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL , `option4` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL , `true_ans` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;";
$data = mysqli_query($connection,$query);
header('Location: study_question1.php');
return $table;
}
?>
<?php
include "online.php";
$connection = mysqli_connect('localhost','root','','userquestion') or die(mysqli_error($connection));
if(isset($_POST['submit'])) {
$question = $_POST["question"];
$option1 = $_POST['option1'];
$option2 = $_POST['option2'];
$option3 = $_POST['option3'];
$option4 = $_POST['option4'];
$true_ans = $_POST['true_ans'];
$query = "INSERT INTO `userquestion`.`$table` (question,option1,option2,option3,option4,true_ans) VALUES ('$question','$option1','$option2','$option3','$option4','$true_ans')";
$data = mysqli_query($connection,$query);
if($data) {
echo "ab dusra dal...";
}
}
?>
を
希望は、あなたはstudy_question1.php' 'にどのコードcorrepondsを指定することはできますか? – Ayush
online.phpを含む2番目のコード –