0

My Code Looks Like:

<?php
    echo "
        <form action='form.php'>
            <input type='text' name='value'>
            <input type='submit'>
        </form>
    ";
?>

And form.php is

<?php
    echo $_POST['value'];
?>

Error Code is:

Notice: Undefined index: value in C:\xampp\htdocs\dynamic\form.php on line 2

Is it possible to get the value of field created using echo command?I don't want to use database,jQuery etc.

Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
darshan shah
  • 23
  • 1
  • 3
  • why are you using echo in your first file (where you are submiting form)? it can work without echo as well – Ram Chander Sep 03 '18 at 16:23
  • 1
    Forms default to a GET method when POST isn't implied. – Funk Forty Niner Sep 03 '18 at 16:36
  • I'm trying to create a dynamic form using php only,this code was just to grab the idea.In my original code,there is one form using which already created one form and i want to create one more form for which i have been taking data in my 2nd form. – darshan shah Sep 03 '18 at 16:58

2 Answers2

0

You need to set the form method to post

<?php
    echo "
        <form action='form.php' method='post'>
            <input type='text' name='value'>
            <input type='submit'>
        </form>
    ";
?>
95faf8e76605e973
  • 13,643
  • 3
  • 24
  • 51
0

you are missing method="post" in form tag

Ram Chander
  • 1,088
  • 2
  • 18
  • 36