Define and submit value for variables in the page - HOW?

A

Anonymous

Guest
Hello all,
which is the way to let a user choose an option on a page (check boxes), and with this define a value for a variable in the page itself?
I did a form, displayed with a statement to check is other values are set. Is so, a form is displayed. Here the user has two option in order to display stuff on the page. Seems that i don't get how to link the form to the variables values...
OF COURSE IF THERE ARE EXPEMLE AROUND JUST SEND ME THERE...
Thanks all...
 
You can access to the vars of your form with the following:
Code:
$myvar = $_REQUEST['myvar'];
if your problem is only the checkbox, here a example how to:
Code:
echo "<input type=checkbox name=myvar value=thevalueofmyvar>";
 
you want to get value from user and then use the same value of variable in the same php page ?
( if yes you can do by setting the form action to the PHP_SELF and then track that variable/value according to get/post methods)
 
I've almost did it, but now i have a problem displaying this string. How i can escape the carhacters?
Code:
print ("<form name=\"status\" method=\"POST\" action=\"issues.php?pn=\".$_GET['pn'].\"\">");
This is the line where i get the error
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
How can i let the script accept
Code:
.$_GET['pn'].
to read the variable?
 
you can embed php in html like this

<form name="" method="post" action="<?php echo "issue.php?pn=".$_GET['pn']; ?> ">
...
...
</form>
will work neat
 
Is not a problem of embedding a piece of code. And more over, is not html pure, is displayed via the PHP parser, so there is something to do to let him read
Code:
action="issues.php?pn=".$_GET['pn']."
 
Tonkpils said:
Code:
print ("<form name="status" method="POST" action="issues.php?pn=".$_GET['pn']."">");
This is the line where i get the error
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
How can i let the script accept
Code:
.$_GET['pn'].
to read the variable?

Just see your above code you have escaped the charecter but have not closed the string
Code:
print ("<form name="status" method="POST" action="issues.php?pn=" . $_GET['pn']. "">");
 
Back
Top