Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Why do I keep getting the Cannot modify header information error PHP? [closed]
- <?php
- $check = 0;
- if (isset($_POST['submit']))
- {
- $username = htmlentities($_POST['name']);
- $username = strtolower($username);
- $password = htmlentities($_POST['apw']);
- $filename = getcwd() . "/passwd.txt";
- $lines = file( $filename , FILE_IGNORE_NEW_LINES );
- foreach($lines as $key => $line)
- {
- list($name, $pw) = explode(':', $line);
- if($name == $username && $pw == $password)
- {
- $check++;
- break;
- }
- }
- if ($check == 1){
- checkifPlayed($username);
- }
- else{
- printf("Your username or password are invalid. Please try again.");
- }
- }
- $played = 0;
- function checkifPlayed($username) {
- $results = getcwd() . "/results.txt";
- $lines = file( $results , FILE_IGNORE_NEW_LINES );
- foreach($lines as $key => $line)
- {
- list($name, $score) = explode(':', $line);
- if($name == $username)
- {
- $played++
- break; }
- if ($played != 1){
- //Redirect to page
- header("location: news.php");}
- else {
- printf "You've already played and scored $score / 60.";
- }
- }
- }
- ?>
- <form method = "POST" action = "<?php echo $_SERVER['PHP_SELF']; ?>">
- <p>
- Username:<br />
- <input type = "text" id="name" name="name" size="20" maxlength="40" />
- </p>
- <p>
- Password:<br />
- <input type = "password" id="apw" name="apw" size="20" maxlength="40" />
- </p>
- <input type="submit" id="submit" name ="submit" name ="submit" value="Log in" />
- <p>
- <a href="register.php">Register</a></p>
- </form>
Add Comment
Please, Sign In to add comment