Page 2 of 2

Re: php login details won't display properly when moved to top

Posted: Tue Mar 25, 2008 8:25 pm
by ashebrian
no changes....same prob

Re: php login details won't display properly when moved to top

Posted: Tue Mar 25, 2008 8:38 pm
by micknc
I just noticed the second if statement on line 69.
I thought the } on line 71 was finishing the else (sorry).

Put another } on line 71 and delete lines 145 through 147:

Re: php login details won't display properly when moved to top

Posted: Wed Mar 26, 2008 7:05 am
by ashebrian
ok.... had to get rid of

Code: Select all

<?php
} ?>
It had php in front of it but on the code displayed in my other msg its:

Code: Select all

<?
} ?>
with the php which was an accident.

No my only problem here. is once i login the page is displayed correctly only for the login form being displayed after being logged in.

Re: php login details won't display properly when moved to top

Posted: Wed Mar 26, 2008 1:27 pm
by micknc
Close...
Cut your form lines

Code: Select all

<form action="process.php" method="POST">
#   <table align="left" border="0" cellspacing="0" cellpadding="3">
#   <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<?php echo $form->value("user"); ?>"></td><td><?php echo $form->error("user"); ?></td></tr>
#   <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<?php echo $form->value("pass"); ?>"></td><td><?php echo $form->error("pass"); ?></td></tr>
#   <tr><td colspan="2" align="left"><input type="checkbox" name="remember" <?php if($form->value("remember") != ""){ echo "checked"; } ?>>
#   <font size="2">Remember me next time &nbsp;&nbsp;&nbsp;&nbsp;</font>
#   <input type="hidden" name="sublogin" value="1">
#   <input type="submit" value="Login"></td></tr>
#   <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
#   <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr>
#   </table>
#   </form>
Ultimately you are going to put it between the two }s on line 71 but you will need to end your php first so from line 71 it would look like:

Code: Select all

} ?>
<form action="process.php" method="POST">
#   <table align="left" border="0" cellspacing="0" cellpadding="3">
#   <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<?php echo $form->value("user"); ?>"></td><td><?php echo $form->error("user"); ?></td></tr>
#   <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<?php echo $form->value("pass"); ?>"></td><td><?php echo $form->error("pass"); ?></td></tr>
#   <tr><td colspan="2" align="left"><input type="checkbox" name="remember" <?php if($form->value("remember") != ""){ echo "checked"; } ?>>
#   <font size="2">Remember me next time &nbsp;&nbsp;&nbsp;&nbsp;</font>
#   <input type="hidden" name="sublogin" value="1">
#   <input type="submit" value="Login"></td></tr>
#   <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
#   <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr>
#   </table>
#   </form>
<? } ?>
 
That should get it back inside your else statement where it was originally.
I think that will get it all worked out.

Re: php login details won't display properly when moved to top

Posted: Wed Mar 26, 2008 8:38 pm
by ashebrian
not really all worked out. Its the right way to bring it back to the if statement. If i do it this way i'd have other prob's. If your moving the form above the links then the links will be displayed below the form in the login section. This section is displayed below the login section in the login page:

Code: Select all

<table class="maintable">
              <tr class="td2">
 
                <td>
                        <a href="underConstruction.html" class="header-links">Shopping Cart</a>
                    <span class="header-links">&nbsp;&nbsp;l&nbsp;&nbsp;</span>
                        <a href="underConstruction.html" class="header-links">Checkout</a>
                    <span class="header-links">&nbsp;&nbsp;l&nbsp;&nbsp;</span>
                        <a href="underConstruction.html" class="header-links">Site Map</a>
                    <span class="header-links">&nbsp;&nbsp;l&nbsp;&nbsp;</span>
                        <a href="" class="header-links">Enquires</a>
                </td>
              </tr>
            </table>


Due to this I've gotten rid of the following code which was also below it:

Code: Select all

<div class="seqdiv" id="imageContainer"> 
            <img src="images/stock2.gif" alt="" name="stock2" hspace="0" vspace="0" id="stock4" class="stock1" /> 
                <img src="images/stock1.jpg" alt="" name="stock3" hspace="0" vspace="0" id="stock3" /> 
                <img src="images/stock3.jpg" alt="" name="home2" hspace="0" vspace="0" id="stock2" />
        <img src="images/stock4.jpg" alt="" name="home2" hspace="0" vspace="0" id="stock2" /> 
                <img src="images/stock5.jpg" alt="" name="stock1" hspace="0" vspace="0" id="stock1" /> 
                <div id='blackLayer'> &nbsp; </div>
as it annoyed me and isn't going to be displayed properly in either before or after the login page. Either way its out.

Now, the links is what i want. I can leave them below where they are at the moment as its not too bad BUT its MUCH better to have it above the login section. I'd say there's no other way as if i move it above it will be displayed elsewhere in my other page after login.

Re: php login details won't display properly when moved to top

Posted: Fri Mar 28, 2008 1:04 pm
by micknc
I think I finally have an understanding of what you are after... So what you need to do is really create two if statements. The first is to display the login info if needed and the second will only display the form if needed. Here is what it would look like:

Code: Select all

<?php
 include("include/session.php");
 ?>
  
 <html>
 <head>
 <title>....</title>
  
 <meta name="description" content="..... />
 <meta name="keywords" content="......" />
 <link href="eeeee.css" rel="stylesheet" type="text/css" />
 <script src="seeee/eeee.js" type="text/javascript"></script>
 <script src= "seeee/eeeee.js"  type="text/javascript"></script>
 <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
 </head>
 <body>
 <!-- Start of Outer table -->
 <table class="table1">
  <tr>
   <td class="td1">
 <!-- Banner Div -->
     <div class="wrapper">
         <div class="header"><br /><br />
             <div class="headershops">
                 <table class="headerphone">
                     <tr style="width:100%">
                                                 <td></td>
                         <td style="text-align:right; font-size:10px; padding-left:180px; color:000000">Welcome <b style="color:FF0000"><?php echo $session->username; ?></b> you are logged in !!</td>
                     </tr>
                 </table>
             </div>
             <table class="maintable">
               <tr class="td2">
  
                 <td>if($session->logged_in){
    echo "<h1>Logged In</h1>";
    echo "Welcome <b>$session->username</b>, you are logged in. <br><br>"."<a href=\"userinfo.php?user=$session->username\">My Account</a> &nbsp;&nbsp;"."<a href=\"useredit.php\">Edit Account</a> &nbsp;&nbsp;";
    if($session->isAdmin()){
       echo "<a href=\"admin/admin.php\">Admin Center</a> &nbsp;&nbsp;";
    }
    echo "<a href=\"process.php\">Logout</a>";
 }
 else {};?>
                         <a href="useredit.php">Edit Account</a>
                     <span class="header-links">&nbsp;&nbsp;l&nbsp;&nbsp;</span>
                         <a href="underConstruction.html" class="header-links">Cart Contents </a>
                     <span class="header-links">&nbsp;&nbsp;l&nbsp;&nbsp;</span>
                         <a href="underConstruction.html" class="header-links">Checkout</a>
                     <span class="header-links">&nbsp;&nbsp;l&nbsp;&nbsp;</span>
                         <a href="underConstruction.html" class="header-links">Site Map</a>
                     <span class="header-links">&nbsp;&nbsp;l&nbsp;&nbsp;</span>
                         <a href="mailto:info@eeeee.com" class="header-links">Enquires</a>              
                 </td>
               </tr>
             </table>
         </div>
    
 <!-- End Banner -->
 <!-- Start Content / Nav Table -->
     <table class='maintable'>
         <tr>
             <td class="td3">
 <!-- Start Navigation List -->
                 <div class="navdiv">
                     <a href="index.html" class="nav-txt">Home</a><br />
                     <a href="underConstruction.html" class="nav-txt">Products</a><br>
                     <a href="underConstruction.html" class="nav-txt">Training Seminars</a><br />
                     <a href="underConstruction.html" class="nav-txt">Education & Science</a><br />
                     <a href="underConstruction.html" class="nav-txt">Promotional Advice</a><br />
                     <a href="underConstruction.html" class="nav-txt">PR Media</a><br />
                     <a href="underConstruction.html" class="nav-txt">Recruitment</a><br />
                     <a href="underConstruction.html" class="nav-txt">Awards</a><br />
                     <a href="underConstruction.html" class="nav-txt">Our Team</a><br />
                     <a href="underConstruction.html" class="nav-txt">Contact Us</a><br /><br />
                 </div>
             </td>
             <td class="content">
 <!-- Image Sequencer -->
                
               <div class="seqdiv" id="imageContainer">
                 <img src="images/stock2.gif" alt="" name="stock2" hspace="0" vspace="0" id="stock4" class="stock1" />
                 <img src="images/stock1.jpg" alt="" name="stock3" hspace="0" vspace="0" id="stock3" />
                 <img src="images/stock3.jpg" alt="" name="home2" hspace="0" vspace="0" id="stock2" />
         <img src="images/stock4.jpg" alt="" name="home2" hspace="0" vspace="0" id="stock2" />
                 <img src="images/stock5.jpg" alt="" name="stock1" hspace="0" vspace="0" id="stock1" />
                 <div id='blackLayer'> &nbsp; </div>
               </div>
                 <br />
                 <script src= "scripts/currentDate.js" type="text/javascript"></script><br />
 <table>
 <tr><td>
  
  
 <?php
  
// User has already logged in, so display relavent links, including
// a link to the admin center if the user is an administrator.
  
 if($session->logged_in){} 
 else{
 ?>
 <h1>Login</h1>
 <?php
 /* 
 User not logged in, display the login form.
   If user has already tried to login, but errors were
   found, display the total number of errors.
   If errors occurred, they will be displayed.
  */
 if($form->num_errors > 0){
    echo "<font size=\"2\" color=\"ff0000\">".$form->num_errors." error(s) found</font>";
 }
 ?>
 <form action="process.php" method="POST">
 <table align="left" border="0" cellspacing="0" cellpadding="3">
 <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<?php echo $form->value("user"); ?>"></td><td><?php echo $form->error("user"); ?></td></tr>
 <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<?php echo $form->value("pass"); ?>"></td><td><?php echo $form->error("pass"); ?></td></tr>
 <tr><td colspan="2" align="left"><input type="checkbox" name="remember" <?php if($form->value("remember") != ""){ echo "checked"; } ?>>
 <font size="2">Remember me next time &nbsp;&nbsp;&nbsp;&nbsp;</font>
 <input type="hidden" name="sublogin" value="1">
 <input type="submit" value="Login"></td></tr>
 <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
 <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr>
 </table>
 </form>
  
 <?php
 }
 ?>
                 </td>
             </tr>
         </table>
  
         </td>
         </tr>
     </table>
 <!-- Footer Div -->
     <div class="push">
     </div>
  
     <div class="footer">
         <div class='maindiv'>
             <a href="underConstruction.html" class="footer-links">Privacy Policy</a>
             <span class="footer-links">&nbsp;&nbsp;|&nbsp;&nbsp;</span>
             <a href="underConstruction.html" class="footer-links">Copyright</a>
             <span class="footer-links">
                 <span class="footer-links">&nbsp;&nbsp;|&nbsp;&nbsp;</span>
             </span><a href="underConstruction.html" class="footer-links">Terms & Conditions </a>
                         <span class="footer-links">
                 <span class="footer-links">&nbsp;&nbsp;|&nbsp;&nbsp;</span>
             </span><a href="underConstruction.html" class="footer-links">Feedback</a>
         </div>
     </div>
 <!-- End of Outer Table -->
 </div>
 <!-- Wrapper Div -->
     </td>
   </tr>
 </table>
 </body>
 </html>
You may need further edits to display exaclty what you are looking for but this will give you a framework.

Re: php login details won't display properly when moved to top

Posted: Fri Mar 28, 2008 6:56 pm
by ashebrian
Thank you ..... spot on. You got it.

Any chance you can tell me how you can allow the users to view a page once they have logged in? The page should not (cannot) be displayed if they haven't logged in and just typed the correct address to that page on the browser address bar.

I know its prob just a small code, BUT have never tried it before. I have the pages done aside from the user/admin login page.

Would this be the appropriate code to add for each page:

Code: Select all

<?php if($session->logged_in){
      echo "<h1>Logged In</h1>";
      echo "Welcome <b>$session->username</b>, you are logged in. <br /><br />"."<a href=\"userinfo.php?user=$session->username\" class=\"header-links\">My Account</a> <span class=\"header-links\">&nbsp;&nbsp;l&nbsp;&nbsp;&nbsp;</span>"."<a href=\"useredit.php\" class=\"header-links\">Edit Account</a> <span class=\"header-links\">&nbsp;&nbsp;l&nbsp;&nbsp;&nbsp;</span>";
      if($session->isAdmin()){
         echo "<a href=\"admin/admin.php\" class=\"header-links\">Admin Center</a> <span class=\"header-links\">&nbsp;&nbsp;l&nbsp;&nbsp;&nbsp;</span>";
      }
      echo "<a href=\"process.php\" class=\"header-links\">Logout</a>  <span class=\"header-links\">&nbsp;&nbsp;l&nbsp;&nbsp;&nbsp;</span>";
          }
   else{
/*
 User not logged in, display the error page.
  */
    header("Location: error.php");
 }

Re: php login details won't display properly when moved to top

Posted: Fri Mar 28, 2008 7:05 pm
by micknc
I just had to do that myself for a project and I used this tutorial:

http://www.phpeasystep.com/workshopview.php?id=6

It has all the meat in it that you need. Just pick and choose the parts that you are looking for.

Specifically Step 4 will be of interest to your question.