Click here to Skip to main content
15,878,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to insert html

Tag attributes value in mysql as below

<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 File is


  1  <?php
  2  $servername = "localhost";
  3  $username = "myuser";
  4  $password = "mypwd";
  5  $dbname = "mydb";
  6  
  7  try {
  8  $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username,
  9   $password);
 10  // set the PDO error mode to exception
 11  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 12  // prepare sql and bind parameters
 13  
 14  $stmt = $conn->prepare("INSERT INTO myorder ( name, path, mobil, email, qty, price, tamt, myidd)VALUES(:name, :path, :mobil, :email, :qty, :price, :tamt, :myidd)");
 15  
 16  
 17   $stmt->bindParam(':name', $name);
 18   $stmt->bindParam(':path', $path);
 19   $stmt->bindParam(':mobil', $mobil);
 20   $stmt->bindParam(':email', $email);
 21   $stmt->bindParam(':qty', $qty);
 22   $stmt->bindParam(':price', $price);
 23   $stmt->bindParam(':tamt', $tamt);
 24   $stmt->bindParam(':myidd', $idd); 
 25  
 26  // insert a row
 27   $name = $_POST['name'];
 28   $path = $_POST['path'];
 29   $mobil = $_POST['mobil'];
 30   $email = $_POST['email'];
 31   $qty = $_POST['qty'];
 32   $price = $_POST['price'];
 33   $tamt = $_POST['tamt'];
 34   $idd = $_POST['idd'];
 35   $stmt->execute();
 36   echo "New records saved successfully";
 37  }
 38   catch(PDOException $e)
 39   {
 40   echo "Error: " . $e->getMessage();
 41   }
 42  
 43   $conn = null;
 44  
 45   ?>



input tag value are inserted into mysql table successfully but "p" tag not inserted but its shows below Error

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



I try but don't know how to do?.

What I have tried:

invested whole day on online. search online regarding the topics but not found solution.
Posted
Updated 19-Feb-23 6:28am
v2
Comments
Member 15627495 19-Feb-23 5:02am    
".value" is the value of the field you invoke ( when you do document.getElementById("ex_name").value )

to retrieve the 'P id="retrieve"' tag, you can invoke 'document.getElementById("retrieve")'.
".value" is an attribute "value" belonging to the element you invoke.


when you call :
let the_tag = document.getelementbyId("the_target"); // you copy the full element and its childs elements ( all attributes , values , and the html tags inside ).

It's a 'var' like the other, you can send 'the_var' by 'get/post' as usual.
MAHESH WAGHELA 19-Feb-23 6:19am    
by javascript?. if yes then how to utilise?. can you post in details please
0x01AA 19-Feb-23 9:41am    
I'm completely noob on that. But my speculation is, that only input fields will be posted back and therefore are available with $_POST
Member 15627495 19-Feb-23 11:15am    
'$_POST' and '$_GET' are 2 vars 'array type' use in Php,
but also members of CGI ( common gateway interface ) since first web page and 'Perl' exist, as datas exchange tools. [ like Request / Cookie ]

!!- for small datas and so files of big size.

the chain is : "
uri?data_one=var_one&data_two=var_two&data_three=var_three... " 

you can read that channel in your web browser on all web pages.

to come back to the question , a tag ( DOM part ) could be allocated in a var, and the var could be send to the server, by an explicit 'form' and 'submit' , or by a JS script .

to pick a tag :
let myTAG = document.getElementById("the_id") // It's the full spell tag and all inside.
0x01AA 19-Feb-23 11:38am    
Ok then. But then document.getElementById("the_id").innerHTML can get the specific detail?

1 solution

Solved by OP. This answer is only to remove the question from unsolved list.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900