Solved

div parent page load

Posted on 2011-03-08
6
210 Views
Last Modified: 2012-05-11
I have the following code that logs the user in, the only issue is the script is in a div, so when it loads the contents needed, it loads it within that same div instead of loading it on the parent level.  
Help Please!

This is the login page that holds the div
<body>

<table  border="0" cellpadding="0" cellspacing="0" hspace="0">
<tr>
  <td><table  border="0" cellpadding="0" cellspacing="0" hspace="0">
    <tr>
      <td><img src="images/login.png" border="0" usemap="#Map"></td>
    </tr>
  </table></td>
</tr>
</table>

<div class="login" style="left:757px; top:190px; overflow:no;">
<object data="scripts/login_field.html" type="text/html" name="foo" width="460" height="195" id="foo" style="width:460px; height:150px;"></object>
</div>
</body>

Open in new window



Here is the actual form
</head>

<body>
<table width="300" border="0" align="left" cellpadding="0" cellspacing="1">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78" align="right">Email</td>
<td width="6">:</td>
<td width="294"><input name="email1" type="text" id="email1"></td>
</tr>
<tr>
<td align="right">Password</td>
<td>:</td>
<td><input name="password1" type="password" id="password1"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</body>

Open in new window

0
Comment
Question by:MsKrissy
  • 3
  • 3
6 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 35076532
This javascript will push the PHP page to the parent frame but you can see it move.  I assume you have more code on those pages or you wouldn't be doing this this way.  I don't know how to make it open first in the parent window.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>checklogin.php</title>
<script type="text/javascript">
<!--
function breakout_of_frame()
{
  if (top.location != location) {
    top.location.href = document.location.href ;
  }
}
// -->
</script>
</head>
<body onload="breakout_of_frame()">
<h1>checklogin.php</h1>
</body>
</html>

Open in new window

0
 

Author Comment

by:MsKrissy
ID: 35076977
I do have other code on these pages.  I have added the code you offered, here is how I have it implemented.  Let me know if this is correct, because I am still getting the same results:

<?php
include_once "connections/connect_to_mysql.php";
		 
		$id = 'id';
		$username = 'username';
		$email1 = 'email1';

// username and password sent from form
   		$email1 = $_POST['email1'];
        $password1 = $_POST['password1'];


// To protect MySQL injection
         $email1=strip_tags($email1);
		 $email1=mysql_real_escape_string($email1);
		 $email1=eregi_replace("'","",$email1);
		 
         $password1=strip_tags($password1);
         $password1=mysql_real_escape_string($password1);
         $password1=eregi_replace("'","",$password1);
         $password1=md5($password1);


$sql = mysql_query("SELECT * FROM userreg WHERE email1='$email1' AND password1='$password1'"); 
         $login_check=mysql_num_rows($sql);
       
        if ($login_check != 0){
while($row = mysql_fetch_array($sql)){
		// Set a session variable for their ID
		$id = $row["id"]; 
		session_register('id'); // Register the session variable's id
		$_SESSION['id'] = $id; // Put the value you want in that session variable

		// Set a session variable for their username
		$username = $row["username"]; 
		session_register('username'); // Register the session variable's username
		$_SESSION['username'] = $username; // Put the value you want in that session variable

		// Set a session variable for their name
		$email1 = $row["email1"]; 
		session_register('email1'); // Register the session variable's email
		$_SESSION['email1'] = $email1; // Put the value you want in that session variable
		
        mysql_query("UPDATE userreg SET last_log_date=now() WHERE username='$username'"); 
    } // close while
	
header("location:../main.php");
}
else {
echo "Wrong Username or Password";
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>checklogin.php</title>
<script type="text/javascript">
<!--
function breakout_of_frame()
{
  if (top.location != location) {
    top.location.href = document.location.href ;
  }
}
// -->
</script>
</head>
<body onload="breakout_of_frame()">
<h1>checklogin.php</h1>
</body>
</html>

Open in new window



The login.html calls the form from the login_field.html file, and the checklogin.php is the logic.
0
 

Author Comment

by:MsKrissy
ID: 35077047
Okay,
I misspoke, it does work if the user puts in the incorrect username or password.  But it doesn't work if they put in the correct information.
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 35077067
Yep, that's the way it works.  I did prototype it with those file names.
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 400 total points
ID: 35077072
Then you would need to add that code to 'main.php'.
0
 

Author Closing Comment

by:MsKrissy
ID: 35077549
Thank you for the help, I will research how to get the page to load without loading the frame first.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question