1

i assign a text box value from a php variable and now i need to pass that value to another form, i'm able to receive other text box values in another page but couldn't get the value of the text box which i assigned using php variable...

<form name="form1" action="book.php" method="post">
<input type="text" name ="name" id="name" value="XXX">
<input type="text" name="da" id="da" value='<?php echo $output?>'>
<input type="submit" value="BOOK" name="book" onClick="return validate()">
</form>

in book.php

if(isset($_POST['book']))
{
$da = $_POST['da'];
$name= $_POST['name'];
echo "$name";

here i get the value for name but not for da...

Ganesh
  • 27
  • 7
  • Have you prevented the default submit event? – elclanrs Jun 16 '13 at 07:19
  • by using a normal button and submitting manually, I wrote that just now check this : http://stackoverflow.com/questions/17130827/my-form-submits-data-even-if-it-is-invalid-but-my-validation-works-fine/17130963#17130963 – CME64 Jun 16 '13 at 07:28
  • no, i didn't prevent it... – Ganesh Jun 16 '13 at 07:29
  • about the php value, try checking it on your browser's inspection and see the value in the html. what is it ? – CME64 Jun 16 '13 at 07:29
  • if i print or echo the value on same page means its printed but i can't able to pass the assigned text value to another page, help me pls – Ganesh Jun 16 '13 at 07:32

1 Answers1

1

You need a semi-colon after the PHP echo command:

<input type="text" name="da" id="da" value='<?php echo $output; ?>'>
imulsion
  • 8,820
  • 20
  • 54
  • 84
  • @Ganesh that's fine. Thanks for the 15 rep ;) – imulsion Jun 16 '13 at 07:35
  • 1
    This is funny, because semicolon is absolutely optional in this case. – dfsq Jun 16 '13 at 07:36
  • @dfsq maybe the command is running over to the tags without the semi colon? I thought semi colons were mandatory in PHP... – imulsion Jun 16 '13 at 07:38
  • Just tested it with `` and [it works ok](http://stackoverflow.com/questions/2038745/do-i-need-a-trailing-semicolon-here) so unless Ganesh don't show the generated form, it's uncertain to determine the real problem. Apostrophes or quotes maybe? – Stano Jun 16 '13 at 07:46
  • "you do not need to have a semicolon terminating the last line of a PHP block". http://php.net/manual/en/language.basic-syntax.instruction-separation.php – dfsq Jun 16 '13 at 07:47
  • @Stano maybe it's to do with the value of $output? – imulsion Jun 16 '13 at 07:47
  • I dunno, it's a question for Ganesh. Maybe we are something missing and your advice is right. – Stano Jun 16 '13 at 07:48