Reputation: 13
I have a php page that includes a form that looks like this:
<form action="<?php echo $_SERVER['PHP_SELF'] .'?Board=' . $_GET['Board']; ?>" method="post">
I now need to include that in an IF/THEN to modify the form action to either look like that or like this:
<form action="<?php echo $_SERVER['PHP_SELF'] .'?ADMIN=TRUE&Board=' . $_GET['Board']; ?>" method="post">
The problem is I can't figure out how to properly write the echo in my PHP given all the ' and "
<?php
if($TheArg2 == "TRUE")
{
//The one with ADMIN would go here
}
else
{
//The one without ADMIN would go here
}
?>
Any suggestions?
Thanks!
Upvotes: 1
Views: 37
Reputation: 2934
Build the url first then use it in form action
<?php
$url = $_SERVER['PHP_SELF']."?Board=".$_GET['Board'].($TheArg2 == true ? '&ADMIN=TRUE':'');
?>
<form action="<?php echo $url; ?>" method="post">
Upvotes: 3