i never put too much thought on how the data would be submitted without using <form>
. I initially just focused on the design of my form.
now, im having trouble trying to send POST
data without having a <form>
markup.
im using bootstrap
framework.
also, how do i get the values in my <select>
markup to be submitted. below is my HTML and PHP code.
below HTML
<div id="box1">
<input name="fname" type="text" placeholder="name">
</div>
<div id="box2">
<select id="food" name="food">
<option value="meat" name="nmeat"> meat </option>
<option value="fruit" name="nfruit"> fruit </option>
</select>
</div>
// ^ Above code is in a JQuery Conditional Statement
// When user select meat, <select id="meat"> will display else fruit
<div id="box3">
<!--MEAT-->
<select id="meat" name="topic">
<option value="hotdog" name="nhotdog"> hotdog </option>
<option value="sausage" name="nsausage"> sausage </option>
</select>
<!--FRUIT-->
<select id="fruit" name="topic">
<option value="apple" name="napple"> apple </option>
<option value="grapes" name="ngrapes"> grapes </option>
</select>
</div>
<div id="box4">
<textarea name="desc" rows="5" class="span11" placeholder="Description"></textarea>
<button name="submit" class="btn btn-large btn-block btn-primary" type="button">Submit</button>
</div>
below PHP
Im having a hardtime making the correct syntax in PHP, specially if the values being submitted is not in a <form>
<?php
if ( isset( $_POST['submit'] ) ) {
$name = $_POST["fname"]; //box1
$gender =$_POST["gender"]; //box2
$topic =$_POST["topic"]; //box3
$desc =$_POST["desc"]; //box4
//echo $msg;
$sql = "insert into z_form (name) values ('".$msg."')";
mysql_query( $sql );
} else {
echo "error";
}
?>