0

I know that there are a few Threads to this Problem but until now nothing changed. My code Looks like this:

<div data-role="page" id="RegisterPage">
  <div data-role="header">
        <h1>Register</h1>
      </div>
  <div data-role="content">
  <?php
  if(!isset($_GET["page"])){
  ?>
  <form action="register.php?page=2" method="post">
    Username:<input type="text" name="user" placeholder="Username" /><br />
    Password:<input type="text" name="password" placeholder="Password" /><br />
    Repeat Password:<input type="text" name="pw2" placeholder="Repeat Password" /><br />
    <input type="submit" value="Submit" />
</form>
<?php
  }
  if(!isset($_GET["page"])){
      if($_GET["page"] == "2") {
          $user = strtolower($_POST["user"]);
          $pw = md5($_POST["pw"]);
          $pw2 = md5($_POST["pw2"]);

          if($pw != $pw2 ){
              echo $pw;
              echo " The Passwords are diffrent! Please try again..<a href=\"register.php \">Back</a>";
          }
      }
  }
  ?>

When I type anything in the form the code sends me to a page where only the Header is displayed. Nothing else happend.

Maybe im blind of anything but I can´t find the Problem.

Moritz
  • 31
  • 5

2 Answers2

0

Fix the error :

if(isset($_GET["page"])){  // error in this line
      if($_GET["page"] == "2") {
          $user = strtolower($_POST["user"]);
          $pw = md5($_POST["pw"]);
          $pw2 = md5($_POST["pw2"]);

          if($pw != $pw2 ){
              echo $pw;
              echo " The Passwords are diffrent! Please try again..<a href=\"register.php \">Back</a>";
          }
      }
  }

if(isset($_GET["page"])) instead of if(!isset($_GET["page"]))

Rijin
  • 625
  • 1
  • 4
  • 13
0

this is the whole corrected code:

<div data-role="page" id="RegisterPage">
      <div data-role="header">
            <h1>Register</h1>
          </div>
      <div data-role="content">
      <?php
      if(!isset($_GET["page"])){
      ?>
      <form action="register.php?page=2" method="post">
        Username:<input type="text" name="user" placeholder="Username" /><br />
        Password:<input type="text" name="password" placeholder="Password" /><br />
        Repeat Password:<input type="text" name="pw2" placeholder="Repeat Password" /><br />
        <input type="submit" value="Submit" />
    </form>
    <?php
      }
      if(isset($_GET["page"])){ //error was here with !isset(). you did that 2 times
          if($_GET["page"] == "2") {
              $user = strtolower($_POST["user"]);
              $pw = md5($_POST["pw"]);
              $pw2 = md5($_POST["pw2"]);

              if($pw != $pw2 ){
                  echo $pw;
                  echo " The Passwords are diffrent! Please try again..<a href=\"register.php \">Back</a>";
              }
          }
      }
      ?>
Blueblazer172
  • 588
  • 2
  • 15
  • 44