Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-02-2009, 08:33 AM   PM User | #1
UD2006
Regular Coder

 
Join Date: Jul 2007
Location: Velsen Noord, Netherlands
Posts: 206
Thanks: 6
Thanked 0 Times in 0 Posts
UD2006 is an unknown quantity at this point
page not center

I have a problem.

I created 2 pages which are the same, only 1 is html and 1 is saved as and uses php. The html page is perfect centered, but the php page doesn't want to center, can anyone help me to find out why not.

Here is the php page code:
PHP Code:
<?php
require("connect.php"); // connectie met database maken en database selecteren
session_start(); // start een sessie of zet een sessie voort

// controleer hier of iemand inlogt - dit moet _voor_ de <HTML>-tag gebeuren gebeuren
if(isset($_POST['login'])) {
  if(
trim($_POST['naam']) <> "" && trim($_POST['wacht']) <> "") {
    
// naam en wachtwoord zijn ingevuld. Haal het (versleutelde) wachtwoord en
    // het gebruikersniveau dat bij deze gebruikersnaam hoort uit de database op
    // en vergelijk dit wachtwoord met het in het formulier opgegeven wachtwoord.

    
$naam  $_POST['naam'];
    
$wacht md5($_POST['wacht']);
    
$res mysql_query("SELECT id, surname, famname, pass, level FROM users where name='".$naam."'") or die(mysql_error());

    
// Als er een resultaat is, oftewel er bestaat een gebruiker met de naam $naam
    
if(mysql_num_rows($res) > 0) {
      
$row mysql_fetch_assoc($res);
      
// aanname: het wachtwoord in de database is eenmalig gehashed mbv de functie md5()
      // vergelijk het opgehaalde wachtwoord met een versleutelde versie van het in het
      // formulier opgegeven wachtwoord
      
if(!strcmp($wacht$row['pass'])) {
        
// alle gegevens kloppen

        // v1.2 extra functionaliteit, onthouden login
        // wil de gebruiker zijn gegevens onthouden ?
        
if(isset($_POST['memory'])) {
          
// set cookie (voor 2 maanden) en onthoud het IP
          // gebruik hierbij het id van de gebruiker
          
setcookie("login_cookie"$row['id'].";".$row['pass'], time()+3600*24*31*2"/");
          
$ip $_SERVER['REMOTE_ADDR'];
          
mysql_query("UPDATE users SET last_ip='".$ip."' WHERE id=".$row['id']) or die(mysql_error());
        }

        
// vul sessievariabelen
        
$_SESSION['suser']    = $naam;         // gebruikersnaam van ingelogd persoon
        
$_SESSION['slevel']   = $row['level']; // bijbehorende gebruikersniveau
        
$_SESSION['stime']    = time();        // de huidige tijd
        
$_SESSION['smaxidle'] = 60 60;       // het aantal seconden inactiviteit
      
} else {
        
// wachtwoorden komen niet overeen, breek de sessie weer af
        
$_SESSION = array();
        
session_destroy();
      }
      
// geef de resultaten van deze query weer vrij
      
unset($row);
      
mysql_free_result($res);
    }
    
// ververs, of de gebruikersnaam/wachtwoord combinatie nou klopt of niet, de pagina
    
header("Location: login.php");
  }
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/default.css" type="text/css" rel="stylesheet" />
<link rel="shortcut icon" href="images/favicon.ico"/>
<title>Contactdatabase: NBS - VMB &middot; login</title>
</head>
<body>
<div id="container">
    <div id="wrapper">
        <div id="logo">
            <H1><font face="Verdana" size="4" color="#2852A8">Contact database NBS - VMB</font></H1>
                <table width="100%" border="1" bordercolor="#CCCCCC">
                      <tr>
                            <td align="center"><img src="images/logo_nbs.jpg" width="175" height="175" /></td>
                          <td align="center"><img src="images/imgimgimg_66_200_0_scl.jpg" width="200" height="153" /></td>
                      </tr>
                    </table>
        </div>
        <div id="content">
          <?php
                
// als de (een willekeurige) sessievariabele suser in het sessie-array nog geen waarde heeft
                // (dus als iemand nog niet is ingelogd)
                
if(!isset($_SESSION['suser'])) {
          
?>
          <p class="logintext">Log in met uw gebruikersnaam en <br /> 
            wachtwoord om toegang tot <br/>de contact database te krijgen.</p>
          <form action="login.php" method="post">
          <table width="350" border="1" bordercolor="#CCCCCC">
              <tr>
                  <td><font face="Verdana" size="2" color="#2852A8"><STRONG>Gebruikersnaam:</STRONG></font></td> 
                  <td colspan="2"><font color="#2852A8" face="Verdana"><input type="text" name="naam" size="15"></font></td>
              </tr>
              <tr>
                  <td><font face="Verdana" size="2" color="#2852A8"><STRONG>Wachtwoord:</STRONG></font></td> 
                  <td colspan="2"><font color="#2852A8" face="Verdana"><input type="password" name="wacht" size="15"></font></td>
              </tr>
              <tr>
                  <td><font face="Verdana"><font color="#2852A8">
                        <!-- v1.2 extra functionaliteit, login onthouden -->
                        <input type="checkbox" name="memory" value="1"></font><font size="2" color="#2852A8">Onthoud mijn login (gebruikt cookie)</font></font></td>
                  <td><font color="#2852A8"><input type="submit" name="login" value="log in"></font></td>
              </tr>
          </table>    
          </form>
          <p><font color="#2852A8" face="Verdana" size="2"><a href="mailto:helpdesk@brandwonden.nl">
          <font color="#2852A8">Klik hier als u uw wachtwoord en/of gebruikersnaam vergeten bent. Dan zullen wij deze voor u resetten.</font></a></font></p>
          <?php
          
} else {
                
// de gebruiker is ingelogd - geef een welkomstboodschap oid
                // hier kun je tevens kijken of alle sessievariabelen de goede
                // waarden hebben (debugging)
          
?>
              <br /><font face="Verdana" size="2" color="#2852A8">Hallo <b><?= $_SESSION['suser'?></font><br /><br />
          <?php
              $red 
mysql_query("SELECT stichting FROM users where name='".$naam."' ") or die(mysql_error());
              if(
mysql_num_rows($red) == "NBS") {
                echo 
"<a href='contact_nbs28BsY29Lm4'>Ga door naar de volgende pagina</a>";
                }
                elseif(
mysql_num_rows($red) == "VMB") {
                  echo 
"<a href='contact_vmbkYe293NB'>voorbeeld pagina</a><br />";
                  echo 
"<a href='logout.php'>uitloggen</a><br />";
                  }
                  else{
                    echo 
"geen toegang";
                    }
          
?>
          <?php
          
}
          
?>
          </div>
      </div>
</div>
</body>
</html>
And here the css (default.css):
Code:
body {
	background: #FFF;
}

#container {
	width: 810px;
	height: auto;
	margin: 0 auto;
}

#wrapper {
	width: 810px;
	margin: 0 auto;
}

#logo {
	width: auto;
	margin: 0 auto;
	text-align: center;
}

#content {
	width: 350px;
	margin: 0 auto;
}

.logintext {
	font-weight: bold;
	text-align: center;
	font-size: 12px;
	font-family: Verdana;
	color: #2852A8;
}

.toptext {
	text-align: center;
	font-size: 18px;
}
Thanks for any help.
UD2006 is offline   Reply With Quote
Old 12-02-2009, 08:40 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
If you don't have a DOCTYPE at the top, add it first. I'd recommend
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
to suit with your code.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Users who have thanked abduraooft for this post:
UD2006 (12-02-2009)
Old 12-02-2009, 08:50 AM   PM User | #3
UD2006
Regular Coder

 
Join Date: Jul 2007
Location: Velsen Noord, Netherlands
Posts: 206
Thanks: 6
Thanked 0 Times in 0 Posts
UD2006 is an unknown quantity at this point
Quote:
Originally Posted by abduraooft View Post
If you don't have a DOCTYPE at the top, add it first. I'd recommend
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
to suit with your code.
Ok, that was stupid of me, thanks for clearing that up
UD2006 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:21 PM.


Advertisement
Log in to turn off these ads.