Form input submit to table with this data

- 1 answer

Ad

Helou, I have a form like this

<form id="some" data-request="checkout" class="checkoutForm">
 <div class="form-group mb10">
                                    <label for="firstName" class="col-sm-12">Name <span class="color-main">*</span></label>
                                    <input class="form-control checkout-form-border" id="firstName" value="" type="text">
</div>
 <div class="form-group mb10">
                                    <label for="Address" class="col-sm-12">Address <span class="color-main">*</span></label>
                                    <input class="form-control checkout-form-border" id="address" value="" type="text">
</div>
etc etc ....
</form>

Now, I want on submit button show new page with collected data from this form in a table body. Can I do this via php and jquery or new custom component? Thanx

Ad

Answer

Ad

PHP:

need a submit button in the form

need action=" " and method="post" attributes added to your form tag

need to add name attributes to your input boxes

Top of page,

if(isset($_POST['submit'])){
    $variable = $_POST['namedOfInputBox'];
    echo "<table><tr><td>$variable</td></tr></table>";
{

What that says is if the form is submitted (submit being name of your submit button, generally name it submit), the values coming through are these and in PHP we "echo", or print, out html code and place our variable here. You can either use :

echo "<table><tr><td>$variable</td></tr></table>";

or

echo "<table><tr><td>" . $variable . "</td></tr></table>";
Ad
source: stackoverflow.com
Ad