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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.