Reputation: 117
I have one table with v_name and l_value column i have to add data from
id v_name l_value
---------- ---------- ----------
1 SITE_URL localhost/sitename
2 SITE_EMAIL [email protected]
and my form is
<form role="form" action="" method="post" >
<div class="form-group">
<label>Page Url</label>
<input type="hidden" placeholder="Enter Page Title" class="form-control" name="v_name" id="SITE_URL" value="SITE_URL" required>
<input type="text" placeholder="Enter Page Title" class="form-control" name="l_value" id="SITE_URL" value="" required>
</div>
<div class="form-group">
<label>Page Email</label>
<input type="hidden" placeholder="Enter Page Title" class="form-control" name="v_name" id="SITE_EMAIL" value="SITE_EMAIL" required>
<input type="text" placeholder="Enter Page Title" class="form-control" name="l_value" id="SITE_EMAIL" value="" required>
</div>
<div class="form-group">
<button class="btn btn-primary" type="submit" name="submit_btn" value="submit">submit</button>
</div>
</form>
i have 2 input but i want my data to add in single table column.
Upvotes: 0
Views: 150
Reputation: 54831
You should use []
notation in name
attributes:
<label>Page Url</label>
<input type="hidden" placeholder="Enter Page Title" class="form-control" name="v_name[]" id="SITE_URL" value="SITE_URL" required>
<input type="text" placeholder="Enter Page Title" class="form-control" name="l_value[]" id="SITE_URL" value="" required>
</div>
<div class="form-group">
<label>Page Email</label>
<input type="hidden" placeholder="Enter Page Title" class="form-control" name="v_name[]" id="SITE_EMAIL" value="SITE_EMAIL" required>
<input type="text" placeholder="Enter Page Title" class="form-control" name="l_value[]" id="SITE_EMAIL" value="" required>
</div>
On serverside you can access values through $_POST
array (if request method is POST):
foreach ($_POST['v_name'] as $key => $name) {
echo $name . ' and ' . $_POST['l_value'][$key];
}
Upvotes: 1