Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 119,783 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 1,389 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Index page+Login Page all in one not working!

 
Reply to this topicStart new topic

Index page+Login Page all in one not working!, It's doesn't work correctly!

maximator5
post 27 Jun, 2008 - 08:54 AM
Post #1


New D.I.C Head

*
Joined: 4 Jun, 2008
Posts: 1

Hi there, here is the code of my page:

CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta name="author" content="MaximatoR">
<meta name="generator" content="Liberty Hood">
<title>|==-==| Liberty Hood |==-==| Crime never sleeps! |==-==|</title>

<style type="text/css">
/*----------Text Styles----------*/
.ws6 {font-size: 8px;}
.ws7 {font-size: 9.3px;}
.ws8 {font-size: 11px;}
.ws9 {font-size: 12px;}
.ws10 {font-size: 13px;}
.ws11 {font-size: 15px;}
.ws12 {font-size: 16px;}
.ws14 {font-size: 19px;}
.ws16 {font-size: 21px;}
.ws18 {font-size: 24px;}
.ws20 {font-size: 27px;}
.ws22 {font-size: 29px;}
.ws24 {font-size: 32px;}
.ws26 {font-size: 35px;}
.ws28 {font-size: 37px;}
.ws36 {font-size: 48px;}
.ws48 {font-size: 64px;}
.ws72 {font-size: 96px;}
.wpmd {font-size: 13px;font-family: 'Arial';font-style: normal;font-weight: normal;}
/*----------Para Styles----------*/
DIV,UL,OL /* Left */
{
margin-top: 0px;
margin-bottom: 0px;
}
</style>

<style type="text/css">
div#container
{
    position:relative;
    width: 800px;
    margin-top: 0px;
    margin-left: auto;
    margin-right: auto;
    text-align:left;
}
body {text-align:center;margin:0}
</style>

<script language="JavaScript1.4" type="text/javascript">
<!--
function jsPlay(soundobj) {
var thissound= eval("document."+soundobj);
try {
     thissound.Play();
}
catch (e) {
     thissound.DoPlay();
}
}
//-->
</script>

<script language="javascript" type="text/javascript">
<!--
function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//-->
</script>

</head>

<body background="images/bg.JPG" bgColor="#000000">

<div id="container">
<div id="image1" style="position:absolute; overflow:hidden; left:0px; top:15px; width:800px; height:78px; z-index:0"><img src="images/logo.JPG" border=0 width=800 height=78></div>

<div id="image2" style="position:absolute; overflow:hidden; left:0px; top:92px; width:800px; height:36px; z-index:1"><img src="images/bar.JPG" border=0 width=800 height=36></div>

<div id="image3" style="position:absolute; overflow:hidden; left:0px; top:566px; width:800px; height:34px; z-index:2"><img src="images/bar2.JPG" border=0 width=800 height=34></div>

<div id="text2" style="position:absolute; overflow:hidden; left:560px; top:567px; width:238px; height:19px; z-index:3"><div class="wpmd">
<div><font class="ws9" color="#FFFFFF" face="Symbol">ã</font> <font class="ws8" color="#FFFFFF">Copyright MaximatoR 2008 All rights reserved!</font></div>
</div></div>

<div id="nav1" style="position:absolute; left:96px; top:92px; z-index:4"><a onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('nav10','','images/nav122741090a.gif',1)" href="#"><img name="nav10" onLoad="MM_preloadImages('images/nav122741090a.gif')" alt="" border=0 src="images/nav122741090i.gif"></a></div>
<div id="nav1" style="position:absolute; left:198px; top:92px; z-index:4"><a onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('nav11','','images/nav122741091a.gif',1)" href="#"><img name="nav11" onLoad="MM_preloadImages('images/nav122741091a.gif')" alt="" border=0 src="images/nav122741091i.gif"></a></div>
<div id="nav1" style="position:absolute; left:300px; top:92px; z-index:4"><a onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('nav12','','images/nav122741092a.gif',1)" href="#"><img name="nav12" onLoad="MM_preloadImages('images/nav122741092a.gif')" alt="" border=0 src="images/nav122741092i.gif"></a></div>
<div id="nav1" style="position:absolute; left:402px; top:92px; z-index:4"><a onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('nav13','','images/nav122741093a.gif',1)" href="#"><img name="nav13" onLoad="MM_preloadImages('images/nav122741093a.gif')" alt="" border=0 src="images/nav122741093i.gif"></a></div>
<div id="nav1" style="position:absolute; left:504px; top:92px; z-index:4"><a onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('nav14','','images/nav122741094a.gif',1)" href="#"><img name="nav14" onLoad="MM_preloadImages('images/nav122741094a.gif')" alt="" border=0 src="images/nav122741094i.gif"></a></div>
<div id="nav1" style="position:absolute; left:606px; top:92px; z-index:4"><a onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('nav15','','images/nav122741095a.gif',1)" href="#"><img name="nav15" onLoad="MM_preloadImages('images/nav122741095a.gif')" alt="" border=0 src="images/nav122741095i.gif"></a></div>

<div id="image4" style="position:absolute; overflow:hidden; left:0px; top:127px; width:217px; height:122px; z-index:5"><img src="images/loginbox.JPG" border=0 width=217 height=122></div>

<div id="text1" style="position:absolute; overflow:hidden; left:13px; top:141px; width:193px; height:105px; z-index:6"><div class="wpmd">
<div><font color="#FFFFFF" face="Cambria">Username:</font></div>
<div><font color="#FFFFFF" face="Cambria"><BR></font></div>
<div><font color="#FFFFFF" face="Cambria">Password:</font></div>
<div><font color="#FFFFFF" face="Cambria"><BR></font></div>
<div><font color="#FFFFFF" face="Cambria"><BR></font></div>
<div><font color="#FFFFFF" face="Cambria"><BR></font></div>
<div><font color="#FFFFFF" face="Cambria">Don't have an account? REGISTER!</font></div>
</div></div>

<?php
    session_start();
    if($_POST) {
        require_once 'config.php';
        $username = $_POST['username'];
        $password = $_POST['password'];        
        $conn = mysql_connect($dbhost,$dbuser,$dbpass)
            or die ('Error connecting to mysql');
        mysql_select_db($dbname);
        $query = sprintf("SELECT COUNT(id) FROM users WHERE UPPER(username) = UPPER('%s') AND password='%s'",
            mysql_real_escape_string($username),
            mysql_real_escape_string(md5($password)));
        $result = mysql_query($query);
        list($count) = mysql_fetch_row($result);
        if($count == 1) {
            $_SESSION['authenticated'] = true;
            $_SESSION['username'] = $username;
            $query = sprintf("UPDATE users SET last_login = NOW() WHERE UPPER(username) = UPPER('%s') AND password = '%s'",
                mysql_real_escape_string($username),
                mysql_real_escape_string(md5($password)));
            mysql_query($query);
            $query = sprintf("SELECT is_in_jail FROM users WHERE UPPER(username) = UPPER('%s') AND password='%s'",
                mysql_real_escape_string($username),
                mysql_real_escape_string(md5($password)));
            $result = mysql_query($query);
            list($is_admin) = mysql_fetch_row($result);
            if($is_admin == 1) {
                header('Location:jail.php');            
            } else {
                header('Location:details.php');                
            }
        } else {    ?>
<span style='color:red'>Error: that username and password combination does not match any currently within our database.</span>
<?php    }
    }
?>

<form name="login" method="POST">
<input name="username" type="text" maxlength=15 style="position:absolute;width:125px;left:77px;top:139px;z-index:7">
<input name="password" type="password" maxlength=15 style="position:absolute;width:125px;left:77px;top:169px;z-index:8">
<input name="submit" type="submit" value="Enter the Hood!" style="position:absolute;left:43px;top:199px;z-index:9">
</form>


</div></body>
</html>


When I try to log in or something like this, it's doesn't work :-? !

This post has been edited by maximator5: 27 Jun, 2008 - 08:55 AM
User is offlineProfile CardPM

Go to the top of the page


level1
post 27 Jun, 2008 - 09:27 AM
Post #2


New D.I.C Head

*
Joined: 12 Jun, 2008
Posts: 34



Thanked 5 times
My Contributions


Do you have a file named config.php? Notice it is being included just inside the if($_POST) statement. I'm also guessing this is where all your dB info is going to be. If you don't have one make one with the variables needed by the code and it should get you going.

User is offlineProfile CardPM

Go to the top of the page

JBrace1990
post 27 Jun, 2008 - 06:15 PM
Post #3


D.I.C Regular

Group Icon
Joined: 9 Mar, 2008
Posts: 464



Thanked 20 times

Dream Kudos: 350
My Contributions


session_start() should be at the beginning of the file, not just the PHP section.... using NuSphere PHP Editor and hitting Run, it came up with that error...
User is offlineProfile CardPM

Go to the top of the page

akozlik
post 30 Jun, 2008 - 10:54 PM
Post #4


D.I.C Addict

Group Icon
Joined: 25 Feb, 2008
Posts: 549



Thanked 20 times

Dream Kudos: 750
My Contributions


Why are your login page and index all in one page?
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/15/08 09:46PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month