PHP在网站制作者平台中显示/隐藏表单

I am using this site to make a website. This website maker is easy to use because the elements are just drag and drop but you can also add your HTML code.

In one of my pages, I have inserted an HTML code which is a form. The form's process is to ask for a password, then with the GET method, it will check if the password is correct, if correct, another form will show. I use PHP language to process the checking of password. The problem that I encounter is, when the right password is entered, it does not show anything, even if I have put the right id. This is the preview site

HTML Code

<form name="password" id="password" style="width:300px;" method="get" action="http://link.co/transfer/password_protect_transfer.php">
   <label for="password">
    Enter password:
   </label>
   <input type="password" id="1151457790" name="password" required=""/>
   <input type="submit" id="submit" name="submit" value="Submit"/>
</form>

<form name="transfer" id="transfer" method="POST" action="http://link.co/transfer/transfer.php" style="display: none;">
   <select id="affAccts" name="affAccts" required="">
    Select an account:
    <option value="A">
     A
    </option>
    <option value="B">
     B
    </option>
    <option value="C">
     C
    </option>
   </select>
   <br/>
   <label for="name">
    Enter name:
   </label>
   <input type="text" id="name" name="name" required=""/>
   <input type="submit" value="Join"/>
 </form>

PHP

<?php

$pw = $_GET['password'];

if($pw == "Admin1234"){?>
    <script type="text/javascript">
    $('#password').hide();
    $('#transfer').show();
    </script>
<?php}else{?>
<script type="text/javascript">
    alert("Access Denied!");
    location.reload();
  </script>
  <?php
  }
?>

Judging only from the preview site, I say it's a problem with the platform you are using. Once you submit a form with get method you should see the values in the URL. There is no change in the URL when I submit the password.

Part of the issue you're facing is that when the password is incorrect, you're calling location.reload(); to reload the page. GET is putting the password in the URL, so every time the page reloads, it will re-evaluate whether or not it's correct and reload again (because it's still incorrect). A loop.

I would suggest changing the form method from GET to POST.

To narrow down the issue further, simplify the JavaScript a bit. E.g. instead of calling some jQuery functions:

<script type="text/javascript">
$('#password').hide();
$('#transfer').show();
</script>

Maybe just try some simple alert statements (e.g. alert('password good');) until you know the right code is firing in the right places. I copied your code to a local test machine and I had to make quite a few adjustments to get things to work right.

You have some flaws in your PHP: if/else sets don't work outside of the PHP, they need to terminate. For example:

<?php
$pw = $_GET['password'];
if($pw == "Admin1234"){
echo '
<script type="text/javascript">
$("#password").hide();
$("#transfer").show();
</script>
';
}else{
    echo '
<script type="text/javascript">
alert("Access Denied!");
location.reload();
</script>
';
}
?>