Solved

div parent page load

Posted on 2011-03-08
6
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

707 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