Jump to content

[SOLVED] I need help with sessions


FirePhoenix

Recommended Posts

I am trying to make a simple password program and when you hit the submit button it gives me this error:

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/www/myserver.com/index.php:3) in /home/www/myserver.com/index.php on line 27

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/www/myserver.com/index.php:3) in /home/www/myserver.com/index.php on line 27

 

Here is my script for index.php (I know its messy)

        <?php
          
          if ($_POST["username"]=="") { ?> 
            <html>
            
            <body>
            <center>
            Please Login:<BR>
            <form method="post" action="index.php">
            Username: <input type="text" name="username" size="20"><BR>
            Password: <input type="password" name="password" size="20"><BR> 
            <input type="Submit" value="Submit">
            </form>
            </center>
            </body>
            </html>

        <?php }else{ 
          $username=$_POST["username"];
          $password=$_POST["password"];

          session_start();
            if ($username=="user1" AND $password=="password1"){ $permission="yes";}
            if ($username=="user2" AND $password=="password2"){ $permission="yes";}

            $username=$_POST["username"];
            session_register("permission");   
            session_register("username");  

              if ($permission=="yes"){
        ?> 
          <html>
          <body>
          <center>
          Please choose the service you would like to update: <BR>
          <A HREF="access1.php">Dish Network</A><BR>
          <A HREF="access2.php">Direct TV</A>   
          </center>
          </body>
          </html>

        <?php }else{ ?>

        Error in username or password

        <?php } ?>
        <?php } ?>
  
  </body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/39588-solved-i-need-help-with-sessions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.