0

Collecting data

How do I use PHP to collect data from html ?

17th Jul 2018, 8:48 PM
Joshua Wilson
Joshua Wilson - avatar
1 Antwort
+ 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.
18th Jul 2018, 10:15 AM
ihateonions