500man 500man - 6 months ago 11
PHP Question

post entire form php

I'm creating a script on my website to echo the contents of an entire form. My html code looks like this:



<form action ="forma.php" method ="POST" name="FORM-TXT">
First name:<br>
<input type="text" name="firstname"><br>
Last name:<br>
<input type="text" name="lastname">
<input type="submit" name="submitsave" value ="Submit">
</form>




My PHP code looks like this:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
//use the html Name element to attach html to php scripts
//V-----------------=|txt file codes|=-----------------V
$text = $_POST["FORM-TXT"];
echo $text;
?>


When I run the form, this error is thrown:


Notice: Undefined index: FORM-TXT in
/homepages/31/d585123241/htdocs/mail/forma.php on line 7


How can I make it so the entire form echos, but no specific elements are referenced, only the form.

Answer

Like @EatPeanutButter says

<?php
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    //use the html Name element to attach html to php scripts

    //V-----------------=|txt file codes|=-----------------V
    $text = $_POST;

    var_dump($text); 

    ?>
Comments