Jump to content

Recommended Posts

<?php



  if(isset($_POST['login'])){ 
  
  
         $username = $_POST['accountname'];
	 $password = $_POST['password'];

	 $query = "SELECT * FROM users WHERE username = $username AND password = $password"; 
	 $check = mysql_query($query) or die(mysql_error());  
	 $num = mysql_num_rows($check); 

	     if($num == 1){ 
		 $_SESSION['loggedin'] = 1; 
		 echo "logged in!"; 

	     } else { 

		 echo "error";


		 }



}else{ 


    echo "You must log in to view this page."; 

} 

?>

 

This returns with a blank page =/ Not sure what's wrong.

 

 

Link to comment
https://forums.phpfreaks.com/topic/144695-login-problem/
Share on other sites

I'm going to go with something you removed from the page for posting it in the forum is preventing the page from executing, such as a require() statement that is failing or there is a parse error in your mysql_connect code.

 

What is the rest of the code on the page?

Link to comment
https://forums.phpfreaks.com/topic/144695-login-problem/#findComment-759279
Share on other sites

this is the entire code, was trying to not post the whole thing because I know how you guys don't like this.

 

<?php 
session_start();
include("connect.php"); 


if(isset($_SESSION['loggedin'])){ 





?> 


<!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>The New Rev-FM 94.3</title>
<link href="css/login.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  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() { //v3.0
  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) { //v4.01
  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() { //v3.0
  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>
<link href="p7vscroller/s5/p7VSC05.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="p7vscroller/p7vscscripts.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="stmenu.js"></script>
</head>

<body onload="MM_preloadImages('css/images/listenliveovr.png','css/images/surgery.png','css/images/fostercharitable.png')">
<div id="container">
<div id="topcontent">
    </div>
    <div id="contentbg">
    	<div id="menubg">
        	<div id="menu">
        	<script type="text/javascript" language="JavaScript1.2">
<!--
stm_bm(["menu5574",730,"","blank.gif",0,"","",1,0,250,0,1000,1,0,0,"","900",0,0,1,2,"default","hand",""],this);
stm_bp("p0",[0,4,0,0,0,7,5,0,100,"",-2,"",-2,50,0,0,"#999999","transparent","bg_01.gif",3,1,1,"#000000"]);
stm_ai("p0i0",[0,"Home","","",-1,-1,0,"index.html","_self","","","","",5,5,0,"","",0,0,0,1,1,"#FFFFF7",1,"#993333",1,"","bg_02.gif",3,1,0,0,"#FFFFF7","#000000","#FFFFFF","#FFFFFF","bold 9pt Arial","bold 9pt Arial",0,0]);
stm_aix("p0i1","p0i0",[0,"Jocks","","",-1,-1,0,"jocks.html","_self","","","","",5,5,0,"","",-1,-1]);
stm_bpx("p1","p0",[1,4,0,2,0,5,0,0,80,"progid:DXImageTransform.Microsoft.RandomDissolve(,enabled=0,Duration=0.30)",12,"progid:DXImageTransform.Microsoft.RandomDissolve(,enabled=0,Duration=0.30)",12,80,0,0,"#666666","#000000",""]);
stm_aix("p1i0","p0i0",[0,"Dave Dodson","","",-1,-1,0,"daved.html","_self","","","","",0,0,0,"","",0,0,0,0,1,"#F9E0CA",1,"#666666",0,"","",3,1,0,0,"#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","9pt Arial","9pt Arial"]);
stm_aix("p1i1","p1i0",[0,"Natalie Steele","","",-1,-1,0,"steele.html"]);
stm_aix("p1i2","p1i0",[0,"Justin Tenery","","",-1,-1,0,"jt.html"]);
stm_aix("p1i3","p1i0",[0,"Tommy Jenkins","","",-1,-1,0,"bone.html"]);
stm_aix("p1i4","p1i0",[0,"Danny Del Rossi","","",-1,-1,0,"ddrossi.html"]);
stm_aix("p1i5","p1i0",[0,"Big G","","",-1,-1,0,"bigg.html"]);
stm_ep();
stm_aix("p0i2","p0i0",[0,"Contests","","",-1,-1,0,"promos.html","_self","","","","",5,5,0,"","",0,0,0,1,1,"#FFFFF7",1,"#993333",1,"","bg_02.gif",3,1,0,0,"#FFFFF7","#000000","#FFFFFF","#FFFFFF","bold 9pt 'Arial','Verdana'"]);
stm_aix("p0i3","p0i0",[0,"Events","","",-1,-1,0,"","_self","","","","",5,5,0,"","",-1,-1,0,1,1,"#FFFFF7",1,"#993333",1,"","bg_02.gif",1]);
stm_bpx("p2","p1",[]);
stm_aix("p2i0","p1i0",[0,"Concerts","","",-1,-1,0,"concerts.html"]);
stm_aix("p2i1","p1i0",[0,"Community Calendar","","",-1,-1,0,"calendar.html"]);
stm_ep();
stm_aix("p0i4","p0i3",[0,"Media"]);
stm_bpx("p3","p1",[]);
stm_aix("p3i0","p1i0",[0,"Photo Gallery","","",-1,-1,0,"photos.html"]);
stm_aix("p3i1","p1i0",[0,"Video","","",-1,-1,0,"video.html"]);
stm_ep();
stm_aix("p0i5","p0i3",[0,"Advertising"]);
stm_bpx("p4","p1",[]);
stm_aix("p4i0","p1i0",[0,"Media Kit","","",-1,-1,0,"kit.html"]);
stm_aix("p4i1","p1i0",[0,"Staff Login","","",-1,-1,0,"staff.php"]);
stm_aix("p4i2","p1i0",[0,"Remotes","","",-1,-1,0,"remotes.html"]);
stm_aix("p4i3","p1i0",[0,"Contact Sales Staff","","",-1,-1,0,"contact.html"]);
stm_ep();
stm_ep();
stm_em();
//-->
</script>
</div>
</div>
<div id="content1">
<br><br></br></br><br><br></br></br>
<div id="login"> 


Welcome to the media Kit!!


</div>


    </div>
        	
        </div>	
</div>
        
        <div id="botcontent">
        </div>
        <div id="footer">
        <a href="index.html">HOME |</a> <a href="jocks.html">JOCKS |</a> <a href="promos.html">CONTESTS |</a><br />
        <br />
        <a href="links.html">Link Us</a>  <a href="ads.html">Advertising</a>  <a href="policy.html">Privacy Policy</a>
        </div>
</div>
</body>
</html>

<?php } else {



  if(isset($_POST['login'])){ 
  
  
         $username = $_POST['accountname'];
	 $password = $_POST['password'];

	 $query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'"; 
	 $check = mysql_query($query) or die(mysql_error());  
	 $num = mysql_num_rows($check); 

	     if($num == 1){ 
		 $_SESSION['loggedin'] = 1; 
		 echo "logged in!"; 

	     } else { 

		 echo "error";


		 }



}else{ 


    echo "You must log in to view this page."; 

} 

?>



Link to comment
https://forums.phpfreaks.com/topic/144695-login-problem/#findComment-759281
Share on other sites

<?php 
session_start();
include("connect.php"); 


if(isset($_SESSION['loggedin'])){ 
?>


<!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>The New Rev-FM 94.3</title>
<link href="css/login.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  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() { //v3.0
  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) { //v4.01
  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() { //v3.0
  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>
<link href="p7vscroller/s5/p7VSC05.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="p7vscroller/p7vscscripts.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="stmenu.js"></script>
</head>

<body onload="MM_preloadImages('css/images/listenliveovr.png','css/images/surgery.png','css/images/fostercharitable.png')">
<div id="container">
   <div id="topcontent">
    </div>
    <div id="contentbg">
       <div id="menubg">
           <div id="menu">
           <script type="text/javascript" language="JavaScript1.2">
<!--
stm_bm(["menu5574",730,"","blank.gif",0,"","",1,0,250,0,1000,1,0,0,"","900",0,0,1,2,"default","hand",""],this);
stm_bp("p0",[0,4,0,0,0,7,5,0,100,"",-2,"",-2,50,0,0,"#999999","transparent","bg_01.gif",3,1,1,"#000000"]);
stm_ai("p0i0",[0,"Home","","",-1,-1,0,"index.html","_self","","","","",5,5,0,"","",0,0,0,1,1,"#FFFFF7",1,"#993333",1,"","bg_02.gif",3,1,0,0,"#FFFFF7","#000000","#FFFFFF","#FFFFFF","bold 9pt Arial","bold 9pt Arial",0,0]);
stm_aix("p0i1","p0i0",[0,"Jocks","","",-1,-1,0,"jocks.html","_self","","","","",5,5,0,"","",-1,-1]);
stm_bpx("p1","p0",[1,4,0,2,0,5,0,0,80,"progid:DXImageTransform.Microsoft.RandomDissolve(,enabled=0,Duration=0.30)",12,"progid:DXImageTransform.Microsoft.RandomDissolve(,enabled=0,Duration=0.30)",12,80,0,0,"#666666","#000000",""]);
stm_aix("p1i0","p0i0",[0,"Dave Dodson","","",-1,-1,0,"daved.html","_self","","","","",0,0,0,"","",0,0,0,0,1,"#F9E0CA",1,"#666666",0,"","",3,1,0,0,"#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","9pt Arial","9pt Arial"]);
stm_aix("p1i1","p1i0",[0,"Natalie Steele","","",-1,-1,0,"steele.html"]);
stm_aix("p1i2","p1i0",[0,"Justin Tenery","","",-1,-1,0,"jt.html"]);
stm_aix("p1i3","p1i0",[0,"Tommy Jenkins","","",-1,-1,0,"bone.html"]);
stm_aix("p1i4","p1i0",[0,"Danny Del Rossi","","",-1,-1,0,"ddrossi.html"]);
stm_aix("p1i5","p1i0",[0,"Big G","","",-1,-1,0,"bigg.html"]);
stm_ep();
stm_aix("p0i2","p0i0",[0,"Contests","","",-1,-1,0,"promos.html","_self","","","","",5,5,0,"","",0,0,0,1,1,"#FFFFF7",1,"#993333",1,"","bg_02.gif",3,1,0,0,"#FFFFF7","#000000","#FFFFFF","#FFFFFF","bold 9pt 'Arial','Verdana'"]);
stm_aix("p0i3","p0i0",[0,"Events","","",-1,-1,0,"","_self","","","","",5,5,0,"","",-1,-1,0,1,1,"#FFFFF7",1,"#993333",1,"","bg_02.gif",1]);
stm_bpx("p2","p1",[]);
stm_aix("p2i0","p1i0",[0,"Concerts","","",-1,-1,0,"concerts.html"]);
stm_aix("p2i1","p1i0",[0,"Community Calendar","","",-1,-1,0,"calendar.html"]);
stm_ep();
stm_aix("p0i4","p0i3",[0,"Media"]);
stm_bpx("p3","p1",[]);
stm_aix("p3i0","p1i0",[0,"Photo Gallery","","",-1,-1,0,"photos.html"]);
stm_aix("p3i1","p1i0",[0,"Video","","",-1,-1,0,"video.html"]);
stm_ep();
stm_aix("p0i5","p0i3",[0,"Advertising"]);
stm_bpx("p4","p1",[]);
stm_aix("p4i0","p1i0",[0,"Media Kit","","",-1,-1,0,"kit.html"]);
stm_aix("p4i1","p1i0",[0,"Staff Login","","",-1,-1,0,"staff.php"]);
stm_aix("p4i2","p1i0",[0,"Remotes","","",-1,-1,0,"remotes.html"]);
stm_aix("p4i3","p1i0",[0,"Contact Sales Staff","","",-1,-1,0,"contact.html"]);
stm_ep();
stm_ep();
stm_em();
//-->
</script>
</div>
</div>
<div id="content1">
<br><br></br></br><br><br></br></br>
<div id="login">


Welcome to the media Kit!!


</div>

   
    </div>
           
        </div>   
</div>
       
        <div id="botcontent">
        </div>
        <div id="footer">
        <a href="index.html">HOME |</a> <a href="jocks.html">JOCKS |</a> <a href="promos.html">CONTESTS |</a><br />
        <br />
        <a href="links.html">Link Us</a>  <a href="ads.html">Advertising</a>  <a href="policy.html">Privacy Policy</a>
        </div>
</div>
</body>
</html>

<?php } else { // this is not being closed at the end.
  if(isset($_POST['login'])){ 
  
  
         $username = $_POST['accountname'];
       $password = $_POST['password'];
       
       $query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'"; 
       $check = mysql_query($query) or die(mysql_error());  
       $num = mysql_num_rows($check); 
       
           if($num == 1){ 
          $_SESSION['loggedin'] = 1; 
          echo "logged in!"; 
          
           } else { 
          
          echo "error";
          
          
          }
          
          
          
   }else{ 
          
          
    echo "You must log in to view this page."; 
          
   } 

}// added by premiso to correct a syntax issue.
  
?>       

 

It is not that we do not like it, it is ok, as long as it is necessary. In this case it was, cause you were not closing the "else" statement bracket to your first if.

Link to comment
https://forums.phpfreaks.com/topic/144695-login-problem/#findComment-759286
Share on other sites

And adding the two lines of code in your file for error reporting only helps if the error is not a fatal parse error, which it is in this case.

 

You should be learning php (or learning something new in php), developing php code, or debugging php code on a system where error_reporting is set to E_ALL and display_errors is set to ON before you code is parsed so that php will give you immediate feedback of all type of errors it detects.

Link to comment
https://forums.phpfreaks.com/topic/144695-login-problem/#findComment-759289
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.