【解決方法】 タグ属性値を mysql テーブルに挿入する方法


私はhtmlを挿入しようとしています

以下のようにmysqlのタグ属性値

<div class="col-sm-6">

                          <p id="idd"></p><br>

                          <p id="path" class="d-none" ></p>

                          <label>Name</label><br>

                          <input type="text" id="name" name="name" style="width:300px;"><br><br>

                          <label>Mobile</label><br>

                          <input type="text" id="mobil" name="mobil" style="width:150px;"><br><br>
                          <label>Email</label><br>

                          <input type="text" id="email" name="email" style="width:200px;"><br><br>
                          <label>Enter Qty</label><br>

                          <input type="text" id="qty" name="qty" style="width:70px;" ><br><br>
                          <label style="display:inline">Price:</label >
                          <p id="price" style="display:inline"></p><br><br>

                          <label>Total Amount</label><br>

                          <input type="text" id="tamt" name="tamt" style="width:150px;" disabled><br><br>


                       <input type="submit" id="btn" name="btn" text="Submit">


          </div>

phpファイルは

<?php
$servername = "localhost";
$username = "myuser";
$password = "mypwd";
$dbname = "mydb";

try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username,
 $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// prepare sql and bind parameters

$stmt = $conn->prepare("INSERT INTO myorder ( name, path, mobil, email, qty, price, tamt, myidd)VALUES(:name, :path, :mobil, :email, :qty, :price, :tamt, :myidd)");


 $stmt->bindParam(':name', $name);
 $stmt->bindParam(':path', $path);
 $stmt->bindParam(':mobil', $mobil);
 $stmt->bindParam(':email', $email);
 $stmt->bindParam(':qty', $qty);
 $stmt->bindParam(':price', $price);
 $stmt->bindParam(':tamt', $tamt);
 $stmt->bindParam(':myidd', $idd); 

// insert a row
 $name = $_POST['name'];
 $path = $_POST['path'];
 $mobil = $_POST['mobil'];
 $email = $_POST['email'];
 $qty = $_POST['qty'];
 $price = $_POST['price'];
 $tamt = $_POST['tamt'];
 $idd = $_POST['idd'];
 $stmt->execute();
 echo "New records saved successfully";
}
 catch(PDOException $e)
 {
 echo "Error: " . $e->getMessage();
 }

 $conn = null;

 ?>

入力タグ値はmysqlテーブルに正常に挿入されましたが、「p」タグは挿入されていませんが、エラーの下に表示されます

Notice: Undefined index: path in /home/brandstu/public_html/php/order.php on line 28

Notice: Undefined index: price in /home/brandstu/public_html/php/order.php on line 32

Notice: Undefined index: tamt in /home/brandstu/public_html/php/order.php on line 33

Notice: Undefined index: idd in /home/brandstu/public_html/php/order.php on line 34
New records saved successfully

やってみるけどやり方がわからない?.

私が試したこと:

オンラインに丸一日投資しました。 トピックに関してオンラインで検索しますが、解決策が見つかりません。

コメント

タイトルとURLをコピーしました