0
Collecting data
How do I use PHP to collect data from html ?
1 ответ
+ 1
so write a form in html with a couple of inputs. Make sure you give these input unique ID values. And then use the action attribute on the form to post to the processing php or use Ajax to handle it.
<form method="post" action="myProcess.php">
<input id="firstName" name="firstName" placeholder="First Name">
<input id="lastName" name="lastName" placeholder="Last Name">
</form>
Then for the myProcess.php page. Simply request these post values and do what ever you wish with them. Just remember if you are not using PHP7 with PDO and binding, then you will need to escape these strings.
<?php
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
echo $firstName . ' ' . $lastName;
?>
Hope this helps.