Forum Moderators: coopster
if ( $_POST["prodqty8352"] > 0) {
echo '<input type="Hidden" name="prodnum" value="8352">' ;
So far, so good. Now, I want to insert a new line, but every time I try, it just gives me a parser error or prints the actual backslash n. That's the first problem.
The second one is I want to print the value of that variable in this line:
<input type="Hidden" name="prodqty" value="$_POST["prodqty8352"]"> in place of $_POST["prodqty8352"].
I've tried several things, but need help.
What is the actual line (and possibly the line or two before) that is causing the error.
value="$_POST["prodqty8352"]"
you can't actually do this. The page, first of all, has to be parsed by php and then you need to echo/print the variable value. I usually use something like this
value="<?= $_POST["prodqty8352"]?>"
that initiates the php parser and therefore puts the value of the variable into the value attribute of your hidden element.
<?php
if ( $_POST["prodqty8352"] > 0) {
echo ('<input type="Hidden" name="prodqty" value="') ;
echo ($_POST["prodqty8352"]) ;
echo ('">');
}
?>
However, I still can't get the @#$! new line to give me a carriage return before or after that line.
I've tried:
echo ("\n");
echo \n;
echo '\n';
Any ideas?
I am not sure where you want the newline but "\n" works great for me everywhere I've used it. Remember that you _WILL NOT_ see them on the webpage as you will need to use "<BR>" but if you view source you will see the new lines just fine.
<?php
if ( $_POST["prodqty8352"] > 0) {
echo ("<input type='Hidden' name='prodqty' value='${_POST['prodqty8352']}'>") ;
}
?>
daisho.