Send data from a form to a URL

1

I know HTML, but I'm not an expert. I created a site for my hostel based on a template that I bought in the themeforrest and it has a form that receives data (like entrance, exit, adults, etc.)

The form is as follows:

<!--Book Section-->
<section class="book-section">
    <div class="auto-container">

        <div class="row clearfix">

            <!--Title Column-->
            <div class="title-column col-lg-2 col-md-12 col-sm-12 col-xs-12">
                <div class="bg-layer"></div>
                <!--Inner Box-->
                <div class="inner-box">
                    <h2>RESERVE</h2>
                    <div class="text">Melhor Preço Garantido</div>
                    <!--Arrow Box-->
                    <div class="arrow-box"><span class="icon fa fa-angle-right"></span></div>
                </div>
            </div>

            <!--Form Column-->
            <div class="form-column col-lg-10 col-md-12 col-sm-12 col-xs-12">
                <div class="inner-box">
                    <form method="post" action="contact.html">
                        <div class="clearfix">
                            <div class="column col-md-9 col-sm-12 col-xs-12">
                                <div class="clearfix">


                                    <div class="form-group col-md-3 col-sm-6 col-xs-12">
                                        <div class="group-inner">
                                            <label>Check In</label>
                                            <input type="date" name="in" value="" placeholder="Entrada" required>
                                        </div>
                                    </div>

                                    <div class="form-group col-md-3 col-sm-12 col-xs-12">
                                        <div class="group-inner">
                                            <label>Check Out</label>
                                            <input type="date" name="out" value="" placeholder="Saída" required>
                                        </div>
                                    </div>

                                    <div class="form-group col-md-3 col-sm-12 col-xs-12">
                                        <div class="group-inner">
                                            <label>Adultos</label>
                                            <input type="number" name="adultos" value="" placeholder="Adultos" min="1" max="4" required>
                                        </div>
                                    </div>

                                    <div class="form-group col-md-3 col-sm-12 col-xs-12">
                                        <div class="group-inner">
                                            <label>Crianças</label>
                                            <input type="number" name="child" value="" placeholder="Crianças" min="0" max="3">
                                        </div>
                                    </div>



                                </div>
                            </div>

                            <!--Avalability Column-->
                            <div class="avalability-column col-md-3 col-sm-12 col-xs-12">
                                <a target="_blank" href="https://hbook.hsystem.com.br/Booking?companyId=593ec639c19a3b40b852aaec">
                                <button type="submit">
                                    <span class="big-txt">Reservar agora</span>
                                    <span class="small-text">Checar disponibilidade</span>
                                </button></a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>


    </div>
</section>
<!--End Book Section-->

I am working with an online booking company and need to pass the data from this form to the URL of that company's website. For example:

  

link

The companyId is fixed, and is not passed by the form. But checkin and checkout , for example, would need to receive different values from that form for each different client.

What is the best way to proceed? I am currently redirecting directly to the online booking URL without passing the parameters.

    
asked by anonymous 17.08.2017 / 22:23

2 answers

4

In your HTML, the input's must have the attributes name as the page that will receive the expected data. The companyId must be in input with type="hidden" .

The page will receive the parameters by the get method, so you can use this form as an example and fit your code:

<form action="https://reservas/booking" method="get">
    <input type="hidden" name="companyId" value="COMPANY_ID">
    Adultos: <select name="adults">
        <option value="1">1</option>        
        <option value="2">2</option>        
    </select>
    Check-in: <input type="date" name="checkin">
    Check-out <input type="date" name="checkout">
    <input type="submit" value="Consultar Disponibilidade">
</form>
  

Replace COMPANY_ID in code with your ID.

    
17.08.2017 / 22:33
1

Use the

<form method=get action=pagina.php(sem o resto do link)>

And create inputs with name = field_name Example:

<input name=ADULT type=text>
    
17.08.2017 / 22:45