Automatically display form data with PHP


This is a simple PHP  script to automatically display (dump output)  data submited from a html form.

The form setup

  • all inputs (form fields) need to have the same name with [] at the end to turn it into an array,  e.g <input type=text name=formdata[]>

formq.html content

<form method=post action=showme.php>
Name: <input type=text name=formdata[]><br>
Email: <input type=text name=formdata[]><br>

<input type=submit value=ok>
</form>

The Script setup

showme.php content

<?php
$data = $_POST['formdata']; # get value from the form fields

foreach ( $data as $key => $value ) { # loop through array collecting the results

echo  “$value<br>”;  # output the data  – print to page
}
?>

Technorati Tags: , , , ,

Related Posts

, , , ,

Android Apple Blog Books browser Browser Security Development Facebook Firefox Google Google Earth GZIP HOSTNAME IFCONFIG Internet Explorer Linux Linux Man Pages Mac Microsoft Mobile Mozilla Novell OpenOffice OpenSource Open Source OpenSUSE OpenSUSE 11.1 PHP Programming Search Security SENDMAIL SEO Social Networking Sun Suse Linux tail Ubuntu usermod Virtualization Windows Windows 7 Wordpress Yahoo Zypper
  1. No comments yet.
(will not be published)
  1. No trackbacks yet.