Can not view company profile after user login: session problem??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bb nicole
    New Member
    • Jan 2007
    • 127

    #1

    Can not view company profile after user login: session problem??

    The company profile showed blank after user login and click the company profile button. Supposed the company profile should not be blank and will show the company information which call from database. I use the session in login page. Thus, in the begining of companyProfile' s coding, i put session_start() ;. What is the problem of my php code?? Thanks..

    [PHP]<?php
    ob_start();
    session_start() ;

    include_once("d atabase.php");

    if($_GET['ret'] == 'general' ){

    //User General Information Retriving
    //find the user
    $general_result = mysql_query("SE LECT * FROM company WHERE username='{$_SE SSION['username']}'")
    or die(mysql_error ());
    $general_row = mysql_fetch_arr ay( $general_result ); //set $row to result

    //table to display general user inforamtion
    echo "<hr><table width=100% border=0>
    <tr>
    <td><div align=center>
    <img src= width=100 height=100>
    </div></td>
    </tr>
    <tr>
    <td><table width=70% border=0 align=center>
    <tr>
    <td width=40% ><font face=Arial size=2>Company Name</font></td>
    <td width=2%>:</td>
    <td width=58%>" . $general_row['companyName'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Company Type</font></td>
    <td>:</td>
    <td>" . $general_row['companyType'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Contact Name</font></td>
    <td>:</td>
    <td>" . $general_row['contactName'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Descript ion</font></td>
    <td>:</td>
    <td>" . $general_row['description'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Username </font></td>
    <td>:</td>
    <td>" . $general_row['username'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Password </font></td>
    <td>:</td>
    <td>" . $general_row['password'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Email Address</font></td>
    <td>:</td>
    <td>" . $general_row['emailAdd'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>ContactN umber</font></td>
    <td>:</td>
    <td>" . $general_row['contactNum'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Fax</font></td>
    <td>:</td>
    <td>" . $general_row['fax'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Contact Addresss</font></td>
    <td>:</td>
    <td>" . $general_row['contactAddress '] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>City </font></td>
    <td>:</td>
    <td>" . $general_row['city'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Postcode </font></td>
    <td>:</td>
    <td>" . $general_row['postcode'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>State</font></td>
    <td>:</td>
    <td>" . $general_row['state'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Country</font></td>
    <td>:</td>
    <td>" . $general_row['country'] . "</td>
    </tr>
    </table></td>
    </tr>
    </table><br><br>" ;



    }//end selection on general information retriving


    ?>[/PHP]
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Originally posted by bb nicole
    The company profile showed blank after user login and click the company profile button. Supposed the company profile should not be blank and will show the company information which call from database. I use the session in login page. Thus, in the begining of companyProfile' s coding, i put session_start() ;. What is the problem of my php code?? Thanks..

    [PHP]<?php
    ob_start();
    session_start() ;

    include_once("d atabase.php");

    if($_GET['ret'] == 'general' ){

    //User General Information Retriving
    //find the user
    $general_result = mysql_query("SE LECT * FROM company WHERE username='{$_SE SSION['username']}'")
    or die(mysql_error ());
    $general_row = mysql_fetch_arr ay( $general_result ); //set $row to result

    //table to display general user inforamtion
    echo "<hr><table width=100% border=0>
    <tr>
    <td><div align=center>
    <img src= width=100 height=100>
    </div></td>
    </tr>
    <tr>
    <td><table width=70% border=0 align=center>
    <tr>
    <td width=40% ><font face=Arial size=2>Company Name</font></td>
    <td width=2%>:</td>
    <td width=58%>" . $general_row['companyName'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Company Type</font></td>
    <td>:</td>
    <td>" . $general_row['companyType'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Contact Name</font></td>
    <td>:</td>
    <td>" . $general_row['contactName'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Descript ion</font></td>
    <td>:</td>
    <td>" . $general_row['description'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Username </font></td>
    <td>:</td>
    <td>" . $general_row['username'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Password </font></td>
    <td>:</td>
    <td>" . $general_row['password'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Email Address</font></td>
    <td>:</td>
    <td>" . $general_row['emailAdd'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>ContactN umber</font></td>
    <td>:</td>
    <td>" . $general_row['contactNum'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Fax</font></td>
    <td>:</td>
    <td>" . $general_row['fax'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Contact Addresss</font></td>
    <td>:</td>
    <td>" . $general_row['contactAddress '] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>City </font></td>
    <td>:</td>
    <td>" . $general_row['city'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Postcode </font></td>
    <td>:</td>
    <td>" . $general_row['postcode'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>State</font></td>
    <td>:</td>
    <td>" . $general_row['state'] . "</td>
    </tr>
    <tr>
    <td><font face=Arial size=2>Country</font></td>
    <td>:</td>
    <td>" . $general_row['country'] . "</td>
    </tr>
    </table></td>
    </tr>
    </table><br><br>" ;



    }//end selection on general information retriving


    ?>[/PHP]

    Not sure...It could very well depend on what is inside the database.php file. Have you put echos inside your if statement to make sure you are in fact getting in there?

    Comment

    • bb nicole
      New Member
      • Jan 2007
      • 127

      #3
      I know what you are talking about... The database.php is just connect to server and database.
      If i delete
      [PHP]include_once("d atabase.php");[/PHP]
      and add
      [PHP]//connect to server and select database
      $conn = mysql_connect(" localhost", "root", "")
      or die (mysql_error()) ;
      mysql_select_db ("ums e-job portal",$conn) or die(mysql_error ());[/PHP]

      The result also same, it will display the blank page...
      What is the problem??
      Thanks..

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        Originally posted by bb nicole
        I know what you are talking about... The database.php is just connect to server and database.
        If i delete
        [PHP]include_once("d atabase.php");[/PHP]
        and add
        [PHP]//connect to server and select database
        $conn = mysql_connect(" localhost", "root", "")
        or die (mysql_error()) ;
        mysql_select_db ("ums e-job portal",$conn) or die(mysql_error ());[/PHP]

        The result also same, it will display the blank page...
        What is the problem??
        Thanks..
        Put an echo inside your if() block to see if you are getting in there.

        Comment

        • bb nicole
          New Member
          • Jan 2007
          • 127

          #5
          Sorry.. I don't really understand what you said... I already put echo inside the if() statement as below to dispaly the company profile, is it like this??
          [PHP]<?
          echo "<hr><table width=100% border=0>
          <tr>
          <td><div align=center>
          <img src= width=100 height=100>
          </div></td>
          </tr>
          <tr>
          <td><table width=70% border=0 align=center>
          <tr>
          <td width=40% ><font face=Arial size=2>Company Name</font></td>
          <td width=2%>:</td>
          <td width=58%>" . $general_row['companyName'] . "</td>
          </tr>
          <tr>
          <td><font face=Arial size=2>Company Type</font></td>
          <td>:</td>
          <td>" . $general_row['companyType'] . "</td>
          </tr>
          <tr>
          <td><font face=Arial size=2>Contact Name</font></td>
          <td>:</td>
          <td>" . $general_row['contactName'] . "</td>
          </tr>
          <tr>
          <td><font face=Arial size=2>Descript ion</font></td>
          <td>:</td>
          <td>" . $general_row['description'] . "</td>
          </tr>
          <tr>
          <td><font face=Arial size=2>Username </font></td>
          <td>:</td>
          <td>" . $general_row['username'] . "</td>
          </tr>
          <tr>
          <td><font face=Arial size=2>Password </font></td>
          <td>:</td>
          <td>" . $general_row['password'] . "</td>
          </tr>
          <tr>
          <td><font face=Arial size=2>Email Address</font></td>
          <td>:</td>
          <td>" . $general_row['emailAdd'] . "</td>
          </tr>
          <tr>
          <td><font face=Arial size=2>ContactN umber</font></td>
          <td>:</td>
          <td>" . $general_row['contactNum'] . "</td>
          </tr>
          <tr>
          <td><font face=Arial size=2>Fax</font></td>
          <td>:</td>
          <td>" . $general_row['fax'] . "</td>
          </tr>
          <tr>
          <td><font face=Arial size=2>Contact Addresss</font></td>
          <td>:</td>
          <td>" . $general_row['contactAddress '] . "</td>
          </tr>
          <tr>
          <td><font face=Arial size=2>City </font></td>
          <td>:</td>
          <td>" . $general_row['city'] . "</td>
          </tr>
          <tr>
          <td><font face=Arial size=2>Postcode </font></td>
          <td>:</td>
          <td>" . $general_row['postcode'] . "</td>
          </tr>
          <tr>
          <td><font face=Arial size=2>State</font></td>
          <td>:</td>
          <td>" . $general_row['state'] . "</td>
          </tr>
          <tr>
          <td><font face=Arial size=2>Country</font></td>
          <td>:</td>
          <td>" . $general_row['country'] . "</td>
          </tr>
          </table></td>
          </tr>
          </table><br><br>" ;

          ?>[/PHP]

          Comment

          • bb nicole
            New Member
            • Jan 2007
            • 127

            #6
            Can anyone help??? What is the problem with my coding??? Why it is a blank page after click inside it???

            Comment

            • Motoma
              Recognized Expert Specialist
              • Jan 2007
              • 3236

              #7
              Originally posted by bb nicole
              Can anyone help??? What is the problem with my coding??? Why it is a blank page after click inside it???
              The only reason I can see for not seeing anything is that your first test:
              if($_GET['ret'] == 'general')
              isn't succeeding.

              Comment

              • bb nicole
                New Member
                • Jan 2007
                • 127

                #8
                Thanks, i will try to look at it... :)

                Comment

                • bb nicole
                  New Member
                  • Jan 2007
                  • 127

                  #9
                  I try to edit my company profile, which the user can view their profile after they login... But it still show the blank page... But when i move it outside the htdocs and press F12, it will show the table... And i try to check it one by one, which means i try to cut the interface out, and it able display the interface... Emm.. I really don't what is the problem... Thanks... Below is my coding for company profile...

                  [PHP]<?php
                  //ob_start();
                  session_start() ;

                  //connect to server and select database

                  $conn=mysql_con nect("localhost ", "root", "") or die (mysql_error()) ;
                  mysql_select_db ("ums e-job portal", $conn) or die(mysql_error ());


                  // construct SQL statement
                  $sql = mysql_query("SE LECT * FROM company WHERE company_ID='{$_ SESSION['company_ID']}'");

                  while($rows=mys ql_fetch_array( $sql)){

                  //table to display company profile

                  echo" <div align='center'> <font face='Arial' size='3'><stron g>Company Profile</strong></font></div>
                  <table width='48%' border='1'>

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Compan y Name</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'>{$rows['companyName']}</strong></td>
                  </tr>

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Compan y Type</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'>{$rows['companyType']}</strong></td>
                  </tr>

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Contac t Name</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'>{$rows['contactName']}</strong></td>
                  </tr>

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Descri ption</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'>{$rows['description']}</strong></td>
                  </tr>

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Userna me</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'>{$rows['username']}</strong></td>
                  </tr>

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Passwo rd</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'>{$rows['password']}</strong></td>
                  </tr>

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Email Address</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'>{$rows['emailAdd']}</strong></td>
                  </tr>

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Contac tNumber</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'>{$rows['contactNum']}</strong></td>
                  </tr>

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Fax</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'>{$rows['fax']}</strong></td>
                  </tr>

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Contac t Addresss</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Verdana' size='2'>{$rows['contactAdd']}</strong></td>
                  </tr>]

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>City</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'>{$rows['city']}</strong></td>
                  </tr>

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Postco de</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'>{$rows['postcode']}</strong></td>
                  </tr>

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>State</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'>{$rows['state']}</strong></td>
                  </tr>

                  <tr>
                  <td width=27% align=left bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Countr y</strong></td>
                  <td width=73% align=left bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'>{$rows['country']}</strong></td>
                  </tr>

                  </table>";

                  }


                  //end selection on general information retriving


                  ?>
                  [/PHP]

                  Comment

                  • bb nicole
                    New Member
                    • Jan 2007
                    • 127

                    #10
                    Hi... Is it anyone have an idea how to edit or repair my code, i really no idea...
                    Emm... i think the code is correct, but don't why the result is the blank page..
                    It doesn't show any error... Is it the coding can't get the user id from database?

                    Comment

                    • bb nicole
                      New Member
                      • Jan 2007
                      • 127

                      #11
                      Originally posted by Motoma
                      The only reason I can see for not seeing anything is that your first test:
                      if($_GET['ret'] == 'general')
                      isn't succeeding.


                      Emm... I have change the code but still cannot function...
                      Do you have any idea, motoma??? Thanks..

                      Comment

                      • Motoma
                        Recognized Expert Specialist
                        • Jan 2007
                        • 3236

                        #12
                        In your code you have this:
                        [PHP]
                        echo"...
                        [/PHP]

                        There is no space between echo and "
                        Try this:

                        [PHP]
                        echo "...
                        [/PHP]

                        Boy, I will be upset if that solves it.

                        Comment

                        • Atli
                          Recognized Expert Expert
                          • Nov 2006
                          • 5062

                          #13
                          If your using php 5.2.0.
                          by default, no error reports will be shown.

                          Try adding this to the top of you code and run the script. It will show all errors and warning. Might help you identify your problem.

                          [PHP]error_reporting (E_ALL);[/PHP]

                          I did most likely find the error tho.

                          Switch ob_start(); and session_start() ;
                          session_start() ; should always be the top line of your code, unless you have a good reason not to. Its just good practice.

                          Add ob_end_flush(); to the bottom of your code.
                          This ends the output buffering and sends the buffer to the browser. Tho this shouldn't be required it seemes not closing the buffer interferes with the database connection in a weird way.
                          I always close ob_start() with ob_end_flush(). It just doesnt feel right to leave the buffer hanging like that.

                          Comment

                          • bb nicole
                            New Member
                            • Jan 2007
                            • 127

                            #14
                            Thanks, Motoma... Thanks, Alti... I have try many way, but still can't work... I don't know wheather is my login function got error or what, it still can't work... And after i add [PHP]<?error_reporti ng(E_ALL);?>[/PHP], the error message as below:
                            Notice: Undefined variable: company_ID in C:\Apache2\Apac he2\htdocs\comp anyProfile.php on line 14
                            which line 14 is
                            [PHP]<? $sql =mysql_query("S ELECT * FROM company WHERE company_ID='{$_ SESSION['company_ID']}'"); ?>[/PHP]
                            Below is my modify code for company profile and login, what is happening, i want to give up ledy...
                            company profile
                            [PHP]<?php
                            error_reporting (E_ALL);
                            session_start() ;
                            ob_start();

                            //connect to server and select database

                            $conn=mysql_con nect("localhost ", "root", "") or die (mysql_error()) ;
                            mysql_select_db ("ums e-job portal", $conn) or die(mysql_error ());



                            // construct SQL statement
                            $sql =mysql_query("S ELECT * FROM company WHERE company_ID='{$_ SESSION['company_ID']}'");




                            ?>

                            <div align='center'> <font face='Arial' size='3'><stron g>Company Profile</strong></font></div>
                            <table width='88%' border='1'>
                            <tr>

                            <?
                            while($rows=mys ql_fetch_array( $sql)){
                            ?>


                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Compan y Name</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'><? echo $rows['companyName'];?></strong></td>
                            </tr>

                            <tr>
                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Compan y Type</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'><? echo$rows['companyType'];?></strong></td>
                            </tr>

                            <tr>
                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Contac t Name</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'><? echo $rows['contactName'];?></strong></td>
                            </tr>

                            <tr>
                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Descri ption</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'><? echo $rows['description'];?></strong></td>
                            </tr>

                            <tr>
                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Userna me</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'><? echo $rows['username'];?></strong></td>
                            </tr>

                            <tr>
                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Passwo rd</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'><? echo $rows['password'];?></strong></td>
                            </tr>

                            <tr>
                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Email Address</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'><? echo $rows['emailAdd'];?></strong></td>
                            </tr>

                            <tr>
                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Contac tNumber</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'><? echo $rows['contactNum'];?></strong></td>
                            </tr>

                            <tr>
                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Fax</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'><? echo $rows['fax'];?></strong></td>
                            </tr>

                            <tr>
                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Contac t Addresss</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Verdana' size='2'><? echo $rows['contactAdd'];?></strong></td>
                            </tr>

                            <tr>
                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>City</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'><? echo $rows['city'];?></strong></td>
                            </tr>

                            <tr>
                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Postco de</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'><? echo $rows['postcode'];?></strong></td>
                            </tr>

                            <tr>
                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>State</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'><? echo $rows['state'];?></strong></td>
                            </tr>

                            <tr>
                            <td width=27% align=center bgcolor='#E8E8E 8'>&nbsp;<font face='Arial' size='2'>Countr y</strong></td>
                            <td width=73% align=center bgcolor='#f1f1f 1'>&nbsp;<font face='Arial' size='2'><? echo $rows['country'];?></strong></td>
                            </tr>

                            </table>


                            <?

                            }


                            ob_end_flush();
                            ?>[/PHP]

                            Login
                            [PHP]<?php
                            ob_start();
                            session_start() ;

                            extract ($_POST);

                            mysql_connect(" localhost","roo t","")
                            or die("Cannot connect to the server");

                            mysql_select_db ("ums e-job portal")
                            or die("Cannot connect to the database");

                            $_SESSION['loggedin'] = 1;

                            $sql="select username from company where username='$user name'";

                            $result=mysql_q uery($sql)
                            or die("Cannot execute query");

                            $num=mysql_num_ rows($result);


                            if($num==1) //username valid
                            {
                            $sql="select username from company where username='$user name' and password='$pass word'";

                            $result2=mysql_ query($sql)
                            or die("Cannot execute query");

                            $num2=mysql_num _rows($result2) ;
                            if($num2>0)
                            {
                            $_SESSION['loggedin'] = 1;
                            $_SESSION['loggedin'] = time();
                            $_SESSION['username'] = $username;
                            $_SESSION['company_ID'] = $company_ID;

                            include("welcom e.php");

                            exit();
                            }
                            else //message send to emp_login.php when wrong password
                            {
                            $message="The username, $username exists, but you have not entered the correct password! Please try again.<br>";
                            include("emp_lo gin.php");
                            }
                            }


                            else
                            $_SESSION['loggedin'] = 0;
                            //message send to emp_login.php when username not valid
                            {
                            $message="The username you entered does not exist! Please try again.<br>";
                            include("emp_lo gin.php");
                            }



                            ?>[/PHP]

                            Comment

                            • Atli
                              Recognized Expert Expert
                              • Nov 2006
                              • 5062

                              #15
                              The $_SESSION['company_ID'] variable isnt set, so the query is looking for an empty string and naturally returns nothing.

                              It is most likely this line in the code.
                              [PHP]$_SESSION['company_ID'] = $company_ID;[/PHP]
                              Make sure the $company_ID is set correctly where ever it is you set it.

                              Comment

                              Working...