Answer the question
In order to leave comments, you need to log in
How to get data from input in form?
Hello everyone, I made forms for a page with filling,
But now the question is, how to receive data from input?
as I understand it, in the form, specify action = "... php"
and as a result, the page simply moves to the same php when the button is pressed. The
question is, how to correctly attach the forms to an excel file or to any other?
Need help)
Here is the code of my input with form
<div class="container">
<form action="#">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<h3>Інформація про Вас</h3>
<div class="row">
<div class="col-md-6">
<input class="form-control" id="Fname" placeholder="Імя" type="text">
</div>
<div class="col-md-6">
<input class="form-control" id="Lname" placeholder="Прізвище" type="text">
</div>
</div>
<div class="row">
<div class="col-md-6">
<input type="text" placeholder="Рік народження" class="form-control" id="date" onfocus="(this.type='date')">
</div>
<div class="col-md-6">
<input class="form-control" id="exampleInputEmail1" placeholder="Email" type="email">
</div>
</div>
<div class="row">
<div class="col-md-6">
<input class="form-control" id="Mobphone" placeholder="Мобільній телефон" type="tel">
</div>
<div class="col-md-6">
<input class="form-control" id="Outphone" placeholder="Закордонний номер" type="tel">
</div>
</div>
<div class="row">
<div class="col-md-12">
<textarea placeholder="Коментар до подорожі" class="form-control" name="" id="comment" cols="30" rows="10"></textarea>
</div>
</div>
<div class="row">
<div class="spoiler-block">
<div class="col-md-12">
<a href="#" class="spoiler-title">Додати подорожуючого</a>
<div class="spoiler-content">
<div class="row">
<div class="col-md-6">
<input class="form-control" id="Fname" placeholder="Імя" data-toggle="tooltip" title="введіть ваше імя будь-ласка" type="text">
</div>
<div class="col-md-6">
<input class="form-control" id="Lname" placeholder="Прізвище" type="text">
</div>
</div>
<div class="row">
<div class="col-md-6">
<input type="text" placeholder="Рік народження" class="form-control" id="date" onfocus="(this.type='date')">
</div>
<div class="col-md-6">
<input class="form-control" id="exampleInputEmail1" placeholder="Email" type="email">
</div>
</div>
<div class="row">
<div class="col-md-6">
<input class="form-control" id="Mobphone" placeholder="Мобільній телефон" type="tel">
</div>
<div class="col-md-6">
<input class="form-control" id="Outphone" placeholder="Закордонний номер" type="tel">
</div>
</div>
<div class="row">
<div class="col-md-12">
<textarea placeholder="Коментар до подорожі" class="form-control" name="" id="comment" cols="30" rows="10"></textarea>
</div>
</div>
</div>
</div>
</div>
</div>
<h3>Вид транспорту</h3>
<div class="row">
<div class="col-md-12">
<select class="form-control" id="Transport" name="country">
<option value="FLY">Літаком</option>
<option value="TRN">Залізниця</option>
<option value="CAR">Авто</option>
</select>
</div>
</div>
<h3>Маршрут </h3>
<div class="row">
<div class="col-md-3">
<select class="form-control" id="locate" name="country">
<option value="ENG">Англія</option>
<option value="TUR">Туреччина</option>
<option value="AL">Албанія</option>
<option value="USA">США</option>
</select>
</div>
<div class="col-md-3">
<input type="text" placeholder="Місто" class="form-control" id="City">
</div>
<div class="col-md-3">
<input type="text" placeholder="Дата заїзду" class="form-control" id="datein" onfocus="(this.type='date')">
</div>
<div class="col-md-3">
<input type="text" placeholder="Дата виїзду" class="form-control" id="dateout" onfocus="(this.type='date')">
</div>
</div>
<h3>Адреса</h3>
<div class="row">
<div class="col-md-4">
<select class="form-control" name="Place">
<option>Готель</option>
<option>Офіс</option>
</select>
</div>
<div class="col-md-4">
<input type="text" name="Adres" placeholder="Вкажіть адресу" class="form-control">
</div>
<div class="col-md-4">
<input class="form-control" type="text" name="URL" placeholder="Вкажіть веб сторінку готелю">
</div>
</div>
<h4>Контакти в Україні / Закордоном з Вашими родичами чи близькими особами</h4>
<div class="row">
<div class="col-md-12">
<input class="form-control" id="exampleInputEmail1" placeholder="ПІБ" type="text">
</div>
</div>
<div class="row">
<div class="col-md-6">
<select class="form-control" name="country">
<option value="ENG">Англія</option>
<option value="TUR">Туреччина</option>
<option value="AL">Албанія</option>
<option value="USA">США</option>
</select>
</div>
<div class="col-md-6">
<input class="form-control" id="exampleInputEmail1" placeholder="Номер телефону" type="tel">
</form>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
If you just did action="...php" (and did not specify method="get | post"), then you will not only go to another page, but you will have a number of parameters in the address bar like:
site.ru/form_result .php?name1=1&name2=str
where name1 and name2 are the names of the inputs in your form.
So, the point is that your form_result.php page needs to process the GET parameters (name1=1 and name2=str) in the process, possibly writing something to the database.
And already from the database you will unload in a format convenient for you.
Well, or immediately php should create csv / xls, but here you also need to look at how to create / change files.
Have a look at php.net/manual/en/tutorial.forms.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question