Jump to content

LDAP and session help


nadman123

Recommended Posts

The code is like this

<?php
session_start();  
define("COMPANYX_DIR", "ldap.companyx.com");
    define("COMPANYX_FILTER","o=Company x, c=au");
?>
<html>
<head>
  <title>Login</title>
</head>

<body>

    <form method="post" action="login.php">
      <center>Please log in using your Authcate Details
      </center><p />

      <table border="0" align="center" cellspacing="5">
      <tr>
        <td>Authcate Username</td>
        <td>Authcate Password</td>
      </tr>
      <tr>
        <td><input type="text" name="uname" 
          size="15"></td>
        <td><input type="password" name="pword" 
          size="15"></td>
      </tr>
      </table><p />

      <center>
        <input type="submit" value="Log in">
        <input type="reset" value="Reset">
      </center>
<?php
if(!isset($_POST["uname"]))
  {
header( "Location:login.php" );   

}
  else
  {
    	
    $LDAPconn=@ldap_connect(COMPANYX_DIR);
    if($LDAPconn)
    {
      $LDAPsearch=@ldap_search($LDAPconn,COMPANYX_FILTER,
        "uid=".$_POST["uname"]);

      if($LDAPsearch)
      {
        $LDAPinfo = @ldap_first_entry($LDAPconn,$LDAPsearch);
        if($LDAPinfo)
        {
          $LDAPresult=@ldap_bind($LDAPconn, 
            ldap_get_dn($LDAPconn, $LDAPinfo), $_POST["pword"]);
        }
        else
        {
          $LDAPresult=0;
        }
      }
      else
      {
        $LDAPresult=0;
      }
    }
    else
    {
      $LDAPresult=0;
    }

    if($LDAPresult)
    {
     header( "Location: property.php" ); 
    }
    else
    {
      echo "Invalid User";
    }
  }
?>
</body>
</html>

 

i get this error message

Warning: Cannot modify header information - headers already sent by (output started at e:\inetpub\students\fit2028\21400644\login.php:24) in e:\inetpub\students\fit2028\21400644\login.php on line 76

 

I really dont get it how to do it...the header information??? ??? ??? ??? ??? ???

Link to comment
https://forums.phpfreaks.com/topic/125912-ldap-and-session-help/
Share on other sites

Headers are sent once HTML is produced.  If you try to edit headers once HTML is produced, PHP will say "headers already been sent". Thus you have to put your script BEFORE any HTML. I do not know the details about your script, but you have to make it work by putting it above HTML.

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.