after include login.php in homepage, the print message cant display in homepage

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

    after include login.php in homepage, the print message cant display in homepage

    Below is my login function, it can work well, but after i include it at my homepage, the print message is in the login page...
    What should it do to make the print message invalid username or password and please enter you enter both username and password display in homepage, please help me...
    [PHP]<?php
    ob_start();
    session_start() ;
    ?>

    <html>
    <head>
    <style type="text/css">
    /* clsForgotPasswo rd */
    a.clsForgotPass word:link {color: #0000FF}
    a.clsForgotPass word:visited {color: #0000FF}
    a.clsForgotPass word:hover {color: #000099}
    a.clsForgotPass word:active {color: #000099}
    a.clsRegister:l ink {color: #0000FF}
    a.clsRegister:v isited {color: #0000FF}
    a.clsRegister:h over {color: #000099}
    a.clsRegister:a ctive {color: #000099}
    </style>
    </head>

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

    $_SESSION['loggedin'] = 0;

    $result = mysql_query("SE LECT * FROM alumni WHERE username='{$_PO ST['username']}' AND password='{$_PO ST['password']}'")
    or die(mysql_error ());

    $row = mysql_fetch_arr ay( $result ); //okay

    if (isset($_POST['submit'])){

    if ((!empty ($_POST['username']))&&(!empty($_P OST['password'])) ){//no forgot field

    if($row['username'] == ''){
    print '<p><strong>Inv alid username or password.</strong><br />Please try again.</p>';

    }else{

    $_SESSION['loggedin'] = 1;
    $_SESSION['loggedin'] = time();
    $_SESSION['username'] = $row['username'];
    $_SESSION['company_ID'] = $row['company_ID'];

    header ('Location: welcome.php');
    exit();
    }

    }else{//Forgot a field.
    print'<p><stron g>Please make sure you enter both <br />username and password!</strong></p>';
    }

    }
    ?>[/PHP]

    [HTML]<form action="alumniL ogin.php" method="POST">
    <TABLE width="166" cellPadding=0 cellSpacing=0 bgcolor=#8870AB style="BORDER-RIGHT: #9B77CB 1px double; PADDING-RIGHT: 0px; BORDER-TOP: #9B77CB 1px double; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 10px; BACKGROUND-IMAGE: PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: top; BORDER-LEFT: #9B77CB 1px double; WIDTH: 140px; COLOR: #000000; PADDING-TOP: 0px; BORDER-BOTTOM: #9B77CB 1px double; FONT-STYLE: normal; FONT-FAMILY: Verdana; TEXT-DECORATION: none" >
    <tr align="center" bgcolor="#BA517 9">
    <td width> <center>
    <font color="#FFFFFF" size="3" face="Verdana"> <strong>ALUMN I LOGIN</strong></font> </center>
    </td>
    </tr>
    <tr bgcolor="#FFD7E 6">
    <td width><font size="2" face="Verdana"> <strong>&nbsp;& nbsp;&nbsp;User name</strong></font></td>
    </tr>
    <tr bgcolor="#FFD7E 6">
    <td width><font size="2" face="Verdana"> &nbsp;
    <input type="text" name="username" size="24">&nbsp ;
    </font></td>
    </tr>
    <tr bgcolor="#FFD7E 6">
    <td><font size="2" face="Verdana"> <strong>&nbsp;& nbsp;&nbsp;Pass word</strong></font></td>
    </tr>
    <tr bgcolor="#FFD7E 6">
    <td><font size="2" face="Verdana"> &nbsp;
    <input type="password" name="password" size="24">&nbsp ;
    </font></td>
    </tr>
    <tr bgcolor="#FFD7E 6"><td colspan="2"><fo nt size="2" face="Verdana"> &nbsp;
    <input type="submit" name="submit" value="Login">
    </font></td>
    </tr>
    <tr bgcolor="#FFD7E 6">
    <td colspan="2">&nb sp;&nbsp;&nbsp; <a href="forgotPas sword.php" class="clsForgo tPassword"><fon t size="1.8" face="Verdana"> Forgot
    password?</font></a></td>
    </tr>
    <tr bgcolor="#FFD7E 6">
    <td colspan="2"><fo nt size="1.8" face="Verdana"> &nbsp;&nbsp;&nb sp;Not Register Yet? <br>&nbsp;&nbsp ;&nbsp;<a href="alumniReg ister.php" class="clsRegis ter">Register
    Now!</a></font></td>
    </tr>
    <tr bgcolor="#FFD7E 6">
    <td colspan>&nbsp;</td>
    </tr>
    </table>
    </form>[/HTML]
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Pass the error indicator to the home page. You can do that by invoking the home page (using the header() function) and passing the error indicator in the url.

    Something like [php]header('Locatio n: homepage.php?sh owerror=1');[/php]
    Your home page then must check for the error trigger set in the $_GET array and print the message, like:
    [php]
    if (isset($_GET['showerror']) AND $_GET['showerror'] == 1) {
    print'<p><stron g>Please make sure you enter both <br />username and password!</strong></p>';
    }[/php]

    Ronald :cool:

    Comment

    • bb nicole
      New Member
      • Jan 2007
      • 127

      #3
      Originally posted by ronverdonk
      Pass the error indicator to the home page. You can do that by invoking the home page (using the header() function) and passing the error indicator in the url.

      Something like [php]header('Locatio n: homepage.php?sh owerror=1');[/php]
      Your home page then must check for the error trigger set in the $_GET array and print the message, like:
      [php]
      if (isset($_GET['showerror']) AND $_GET['showerror'] == 1) {
      print'<p><stron g>Please make sure you enter both <br />username and password!</strong></p>';
      }[/php]

      Ronald :cool:
      Thanks... It work for me...
      But if i want the pop up window for the users when they don't enter the username or password or they insert invalid username or password, is it need to use javascript??
      how to code it??? Thanks.. :)

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Your question (and thread title) was to display it at the home page. Are you telling me that that was wrong and now you want it as a popup screen?

        If so, start developing some of the JS code and we will have a look at it when you envounter errors.

        Ronald :cool:

        Comment

        Working...