1

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!

1
  • Just do $admin = $TheArg2 ? "ADMIN=TRUE&" : ""; Then use $admin in the action. Commented May 31, 2021 at 2:43

1 Answer 1

3

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">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.