0

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.

2
  • where's the PHP? Commented Feb 14, 2019 at 13:54
  • And WHY the upvote? Commented Feb 14, 2019 at 14:03

1 Answer 1

1

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];
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.