Solved

div parent page load

Posted on 2011-03-08
6
206 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 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
Yep, that's the way it works.  I did prototype it with those file names.
0
 
LVL 82

Accepted Solution

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

Author Closing Comment

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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Do you want to insert HTML5 video into your site? This is the tutorial how to do so. What are the main advantages of HTML5 video? 1) Have good compression, good image quality, and low decode processor use. 2) It is royalty-free 3) It is easi…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now