I made a password script, but I am having trouble with the fopen, because it won't open up the website (ngemu.com is just the example site). Why won't it work? here is my code:

<?php

include 'conq.php';

if ($passfield == $conq){

$fp = fopen ("http://www.ngemu.com/", "r");

}
elseif ($passfield == "") {
}
else {
echo "Incorrect password";
}

echo '
<html><body>

<form method="post" action="login.php">

Enter clan Password
<input type="text" name="passfield"></input><br>

<input type="submit" name="submit" value="click"></input>

</form>

</body></html>
';
?>

    What error do you get? Where in the code do you read the file?

      I don't get an error, it just doesn't goto the site.

        check if $passfield is empty using if(empty($passfield)) echo "empty";

        if it is empty

        then possiblyyou have register_globals off, use $_POST['passfield'] instead

          hey I tryed , but it says file not exist , just check , if u get any clue :

          <?php 
          
          if($submit)
          {
          	include 'conq.php'; 
          
          $fp = @fopen ("http://www.ngemu.com/", "r"); 
          
          if ($fp)
          { 
          	print"The file exists!"; 
          }
          else
          { 
          	print"The file does not exist"; 
          	exit;
          }
          
          if ($passfield == $conq)
          { 
          	$fp = fopen ("http://www.ngemu.com/", "r"); 
          } 
          elseif ($passfield == "") 
          { 
          	print "comes here empty area";
          } 
          else 
          { 
          	echo "Incorrect password"; 
          } 
          }
          ?>
          
          <html><body> 
          
          <form method="post" action="<? echo $PHP_SELF ?>"> 
          
          Enter clan Password 
          <input type="text" name="passfield"></input><br> 
          
          <input type="submit" name="submit" value="click"></input> 
          
          </form> 
          
          </body></html> 
          
            1. Works for me:

              $fp = @fopen ("http://www.ngemu.com/", "r");
              
              if ($fp)
              { 
              print"The file exists!"; 
              echo fread($fp,1024);
              }
              else
              { 
              print"The file does not exist"; 
              exit;
              }
              
            2. Perhaps if you stopped suppressing error messages on your fopen() call you might see some error messages that might help. The @ shouldn't go on until you're sure there's no problem.

              Roble,

              If you are trying to redirect to http://www.ngemu.com/ then you want:

              header("Location: http://www.ngemu.com/");

              But you must make sure that your PHP script has not displayed any HTML yet. To make it simpler, you can add this line at the top of your PHP script before any HTML is displayed:

              ob_start();

                I tried this but now it redirects before I get a chance to do anything:

                <?php 
                
                {
                    include 'conq.php'; 
                
                if ($passfield == $conq)
                { 
                
                $fp = @fopen ("http://www.ngemu.com/", "r"); 
                
                if ($fp)
                { 
                    header("Location: [url]http://www.ngemu.com/[/url]");  
                }
                else
                { 
                    print"The file does not exist"; 
                    exit;
                }
                
                } 
                elseif ($passfield == "") 
                { 
                    print "Empty!";
                } 
                else 
                { 
                    echo "Incorrect password"; 
                } 
                
                ?>
                
                <html><body> 
                
                <form method="post" action="<? echo $PHP_SELF ?>"> 
                
                Enter clan Password 
                <input type="text" name="passfield"></input><br> 
                
                <input type="submit" name="submit" value="click"></input> 
                
                </form> 
                
                </body></html> 
                

                  Ok, instead of giving us code, tell us what you want to do.

                  Do you want one page if they HAVE entered their password and another page if they HAVE NOT entered their password?

                  If so, redirects are not the answer.

                    I want it so when they enter the correct password (which is $conq from conq.php which i included in this php) they are redirected to the members page (in this case, I used ngemu for an example).

                    If they type an incorrect password in, it says "Incorrect password".

                      if($_POST['password'] is correct)
                      { header('http://www.ngemu.com/');
                         // The browser will be redirected. If the page doesn't exist
                         // the user will get a 404 error from ngemu's server.
                          exit;
                      }
                      else
                      { password is incorrect.
                         Don't bother exiting, though, just set $errormessage
                      }
                      ?>
                      Display login form; if $errormessage is set, display it somewhere as well.
                      
                        Write a Reply...