2

My code looks somewhat like this:

<form method="POST">
//something
<form method='GET'>
<input readonly type='text' id='userpwd' value= 'Day'  name='count'/>
<input type='submit' id='btn' formaction='admi.php'  name='admin' value='Add Details'></form>
<input type="submit" id="btn" formaction="choose.php"  name="admin" value="Done"></p>
</form>

I want to get the value of readonly type input in my new php file.How could I achieve this.I tried doing this:

$var=$_GET['count'];

but it is giving following error msg:

Notice: Undefined index: count in C:\xampp\htdocs\tourism\admi.php on line 4

Please somebody help me out..!Kindly give some solution in php only.

Tarishi Jain
  • 254
  • 3
  • 13

2 Answers2

1

<form> element shouldn't be nested:

4.10.3. The form element
Content model:
Flow content, but with no form element descendants.

HTML 5.2 Recommendation

Can't you do both forms seperate (not nested)?


Edit: If you need a readonly field to be sent in your form, you can add a hidden field with the same value :

<input type="hidden" name="count" value="Day" />
<input type="text" name="count" value="Day" readonly />
Maarti
  • 3,600
  • 4
  • 17
  • 34
0
<?php
if(isset($_GET['txtUserPwd'])) { echo "<div>" . $_GET['txtUserPwd'] . "</div>"; }
else { ?>
  <form method="GET">
    <input type="text" id="txtUserPwd" name="txtUserPwd" value="Day" readonly />
    <input type="submit" id="btnAdmi" name="btnAdmi" value="Add Details">
    <input type="button" id="btnChoose" name="btnChoose" value="Done">
  </form>
<?php } ?>

This doesn't address your second button. I would do that with JavaScript or jQuery.