0

ユーザーが入力した入力値を取得してデータベースに送信したい。しかし、何らかの理由で、値の代わりに空白がテーブルに挿入されます! 誰かが何が悪いのか知っていますか?

<form method="post" name="name" action="pt2.php" >

<?php
//$mysql->commit();
            echo "<h3>";
            echo "Please enter the name for each seat:<br><p>&nbsp</p>";
            echo "";
            foreach($_POST['seats'] AS $seat) {
                $rowId = substr($seat, 0, 1);
                $columnId = substr($seat, 1);
        echo $rowId . $columnId . '<input type="hidden" name="seats[]" value="' . $seat . '"><input name="' . $seat . 'name" type="text"/></br>';
            }

?>

   <input type="submit" name="submit" value="Submit Form"><br>
</form>

pt2.php

<?php
// Connect to MySQL
mysql_connect("localhost", "root", "root") or die("Connection Failed");
mysql_select_db("tickets")or die("Connection Failed");


$namei = $_POST[$seat . 'name'];

foreach ($_POST['seats'] as $seat){
echo $seat;
echo $namei;
$query = "INSERT INTO seatnames (seatname) VALUES ('$namei')";
mysql_query($query) or die(mysql_error()); 
}
?>
4

0 に答える 0