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 Apache Apple Bing Blog Books Broadband browser Browser Security Development Facebook Firefox Google GZIP HOSTNAME IFCONFIG Internet Explorer iPhone Linux Linux Man Pages Mac Microsoft Mobile Mozilla MySQL Novell OpenOffice Open Source OpenSUSE OpenSUSE 11.1 PHP Programming Search Security SENDMAIL SEO Social Networking Suse Linux Ubuntu usermod Virtualization Windows Windows 7 Wordpress Yahoo
  1. No comments yet.
(will not be published)

  1. No trackbacks yet.