Jump to content


Photo

Unknown Problem.


  • Please log in to reply
1 reply to this topic

#1 shoaibi

shoaibi
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 19 August 2006 - 12:35 AM

Please copy these codes first and then read afterwards:

home.php
<?php
session_start();
if($_SESSION['loggedin']==1) $showlogin=0;
else $showlogin=1;
include_once "./login.php";
?>

<title>Welcome to MySite</title>
<style type="text/css">
body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color:#C4B2B2; cursor:crosshair;
  scrollbar-arrow-color: #2C3A5D;
  scrollbar-track-color: #19181E;
  scrollbar-face-color: #19181E;
  scrollbar-highlight-color: #47272C;
  scrollbar-3dlight-color: #19181E;
  scrollbar-darkshadow-color: #19181E;
  scrollbar-shadow-color: #47272C;}
table { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px}

.menu {font-family: Geneva, Arial, Helvetica, san-serif;
        font-size:12px; color:#C4B2B2;
        text-align:center;
        background-image:url('images/linkback.jpg');
		border: #323951;
		border-style: solid;
		border-top-width: 1px;
		border-right-width: 1px;
		border-bottom-width: 1px;
		border-left-width: 1px }

A:link, a:visited, a:active {color: #C4B2B2; text-decoration: none;}
A:hover{color:#C4B2B2;text-decoration:underline}

</style>

<body bgcolor=#FFFFFF background="images/background.jpg">


<img border="0" src="images/mainimage.jpg" style="position:absolute; left:0; top:0; width=765; height=600;">

</div>


<div id="navigation" style="position:absolute; left:16px; top:145px; width:197px; height: 290px;">
 <center>
<p class="menu">Navigation</p></center>
<!----- This is navigation menu, add links--->
 
<center>
<p class="menu">User's Menu</p></center>
<?php 
if ($showlogin==0)
{
           //Welcome user, show PMs, give link to Control panel and options etc etc
        	}
else
{
	echo "Welcome Guest! <BR>Please Login Below<BR>";
	loginform();
	echo "<BR><BR><BR>";
}
?>

 <center>
<BR><BR>


 
</div>

<div id="navigation2" style="position:absolute; left:239px; top:367px; width:156px; height: 286px;">
</div>


<div id="content" style="position:absolute; left:414px; top:564px; width:338px; height: 350px;">
<center><p class="menu">Updates</p></center>
<br><br>
</div>




</body>





login.php
<?php
ob_start();
session_start();

function loginform()
{
	
	?>
	<FORM METHOD="POST" ACTION="login.php">
		<input type="hidden" name="action" value="ausr">
     
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ID&nbsp;&nbsp;<INPUT TYPE="TEXT" NAME="id" SIZE="8" style="color: #460046; font: 11px Verdana; background-color: #FFFFFF; border-width: 1; border-color: #000000; border-style: solid;"><BR>
         Password&nbsp;&nbsp;<INPUT TYPE="PASSWORD" NAME="pwd" SIZE="15" style="color: #460046; font: 11px Verdana; background-color: #FFFFFF; border-width: 1; border-color: #000000; border-style: solid;">
		 <center><INPUT TYPE="SUBMIT" VALUE="LOGIN" style="color: white; font-family: verdana; font-size: 8pt; font-weight: bold;border-color: red; border-width: 1px;background-color: black;"></center>
         </FORM>
		
		  &#xA7; <a href="forgotpassword.php">Forgot UserID/Password?</a> <br>
		   &#xA7; <a href="register.php" >New?</a> <br>
	    &#xA7; <a href="sendvcode.php" >NO Verification Email?</a> <br>
		<?php
}

function authuser($id, $pwd) {
   global $user;

	db_connect();
	$query = "SELECT * FROM $user
                             WHERE id = '$id'";
   $result = mysql_query($query);


  if(!mysql_num_rows($result)) return 0;
  else
  {
	  $arr=mysql_fetch_array($result);
	   if($pwd!=$arr['pwd']) return 1;
	  else if ($arr['status']==0) return 2;
	  else return 5;

	}
}

if($_POST['action']=="ausr")
{	
		
	$name = authuser($_POST['id'], $_POST['pwd']);
	

   if($name==0 OR $name==1 OR $name==2)
	 {
		  

	    echo "<h1>Authorization failed.</h1> ";
       if($name==2)
	      {
			echo "<BR>Ooops! Your account isn't verified as of yet.<BR>".
			        "<A HREF=\"verify.php\">Click Here</A> to verify your email address.<BR>".
                                                  "If you haven't recieved any Verification email <A HREF=\"sendvcode.php\">Click here</A><BR>";
			exit;
			}
		else if($name==0) echo "<BR>Ooops! Your provided UserID doesn't even exits!<BR>" ;

		else	echo "<BR>Ooops! Your password isn't correct!<BR>";

	 	echo "Click on the following link to try again.<BR>\n";
      echo "<A HREF=\"login.php\">Login</A><BR>";
      echo "If you're not a member yet, click " .
           "on the following link to register.<BR>\n";
      echo "<A HREF=\"$register_script\">Membership</A>";
      exit;



   }
   else
	{
	   
	   $usr=$_POST['id'];
	   $pwd=$_POST['pwd'];
	   $_SESSION['loggedin']=1;
	   $_SESSION['usr']=$usr;
	   $_SESSION['pwd']=$pwd;
	   header("Refresh: 5; URL=home.php");
	   echo "<center> Welcome back ";
	   echo $_SESSION['usr']."<BR> Please wait while you are redirected.<BR>".
		   "You are being redirected to Homepage in 5 seconds";
       exit;
	  }
	  
}	

?>

The problem is:
if i include login.php and try to visit home.php the page comes as blank, while if i visit login.php with a direct function call to login form then it goes well and good. What to do?


#2 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 19 August 2006 - 05:23 AM

Try this..
include_once "login.php";


Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users