php css not working?

OK i have all my php code working for my log in n the like yey! :O

but am trying to allso have div tags and text with css styling on the same page as my php log in code. the css is not working when i load the page up untill i log in. how can i get the css to work?
<?php
session_start();

if(isset($_POST['submit1'])) {
logout();
}

if(isset($_POST['submit'])) {
login();
}






function login()
{
		//get form data
$username = $_POST['username'];
$password = $_POST['password'];
if ($username&&$password)
{
	include("conf.php");

	
	$connection = mysql_connect($databaseURL,$databaseUName,$databasePWord) or die ("Error while connecting to localhost");
    $db = mysql_select_db($databaseName,$connection) or die ("Error while connecting to database");

$query = mysql_query("SELECT * FROM members WHERE username='$username'");
					 
$numrows = mysql_num_rows ($query);

if ($numrows!=0)

{
	
	while ($row = mysql_fetch_assoc($query))
	{
	$dbusername = $row['username'];
	$dbpassword = $row['password'];
	
	}
	// check to see if they are matching !? :)
	if ($username==$dbusername&&$password==$dbpassword)
	{
		
	
	$_SESSION['username']=$username;
	if ($_SESSION['username'])
echo "Welcome, ".$_SESSION['username'];
	
	
	}
	else
	echo "password incorrect!";
}


else
echo("That user name does not exist!");


	
}
else
echo("please enter a username and password!");

}

function logout()
{
session_destroy();
if ($_SESSION=='username'){
echo "fail";}
else{
        echo "You've been logged out.";
}

}


?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<style type="text/css">
<!--
#1 {
	position: absolute;
	left: 123px;
	top: 233px;
}
#2 {
	position: absolute;
	left: 502px;
	top: 15px;
	height: 28px;
}
#3 {
	position: absolute;
	left: 569px;
	top: 15px;
}
-->
</style>

</head>
<body>



<div id="1">
<form action="<?=$_SERVER['PHP_SELF'];?>" method="POST">
Username:<input type='text' name='username'>
Password:
<input type='password' name='password'>
<input type="submit" name="submit" value="Submit">
</form>
</div>

<div id="2">

<form action="<?=$_SERVER['PHP_SELF'];?>" method="POST">
<input type="submit" name="submit1" value="Log out">
</form>
</div>

<div id="3">

<form action="mysql_insert.html" method="get">
  <input type="submit" name="submit2" value="Need to Register?" />
</form>
</div>
</body>
</html>

Open in new window

LVL 1
helpchrisplzAsked:
Who is Participating?
 
john-formbyConnect With a Mentor Commented:
Hi,

CSS will not allow you to name styles beginning with a number.  Change your code to the following and it will work.

Hope this helps,

John
<?php 
session_start(); 
 
if(isset($_POST['submit1'])) { 
logout(); 
} 
 
if(isset($_POST['submit'])) { 
login(); 
} 
 
 
 
 
 
 
function login() 
{ 
                //get form data 
$username = $_POST['username']; 
$password = $_POST['password']; 
if ($username&&$password) 
{ 
        include("conf.php"); 
 
         
        $connection = mysql_connect($databaseURL,$databaseUName,$databasePWord) or die ("Error while connecting to localhost"); 
    $db = mysql_select_db($databaseName,$connection) or die ("Error while connecting to database"); 
 
$query = mysql_query("SELECT * FROM members WHERE username='$username'"); 
                                          
$numrows = mysql_num_rows ($query); 
 
if ($numrows!=0) 
 
{ 
         
        while ($row = mysql_fetch_assoc($query)) 
        { 
        $dbusername = $row['username']; 
        $dbpassword = $row['password']; 
         
        } 
        // check to see if they are matching !? :) 
        if ($username==$dbusername&&$password==$dbpassword) 
        { 
                 
         
        $_SESSION['username']=$username; 
        if ($_SESSION['username']) 
echo "Welcome, ".$_SESSION['username']; 
         
         
        } 
        else 
        echo "password incorrect!"; 
} 
 
 
else 
echo("That user name does not exist!"); 
 
 
         
} 
else 
echo("please enter a username and password!"); 
 
} 
 
function logout() 
{ 
session_destroy(); 
if ($_SESSION=='username'){ 
echo "fail";} 
else{ 
        echo "You've been logged out."; 
} 
 
} 
 
 
?> 
 
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
 
<style type="text/css"> 
<!-- 
#one { 
        position: absolute; 
        left: 123px; 
        top: 233px; 
} 
#two { 
        position: absolute; 
        left: 502px; 
        top: 15px; 
        height: 28px; 
} 
#three { 
        position: absolute; 
        left: 569px; 
        top: 15px; 
} 
--> 
</style> 
 
</head> 
<body> 
 
 
 
<div id="one"> 
<form action="<?=$_SERVER['PHP_SELF'];?>" method="POST"> 
Username:<input type='text' name='username'> 
Password: 
<input type='password' name='password'> 
<input type="submit" name="submit" value="Submit"> 
</form> 
</div> 
 
<div id="two"> 
 
<form action="<?=$_SERVER['PHP_SELF'];?>" method="POST"> 
<input type="submit" name="submit1" value="Log out"> 
</form> 
</div> 
 
<div id="three"> 
 
<form action="mysql_insert.html" method="get"> 
  <input type="submit" name="submit2" value="Need to Register?" /> 
</form> 
</div> 
</body> 
</html>

Open in new window

0
 
helpchrisplzAuthor Commented:
lol this was so simple silly me :)
0
All Courses

From novice to tech pro — start learning today.