Jump to content

[SOLVED] help on iframe


pixeltrace

Recommended Posts

guys,

 

i have a problem and i need help. i got a page and has an iframe.

my problem now, i have a form that is being loaded inside the iframe

and after sending the form, instead of going back to its page (i mean the pages inside the iframe)

i loads back on the top.

meaning, if my page is www.form.com and on that page i have iframe with name="iframe"

after the form is sent, instead of loading back inside iframe it loads on top changing

www.form.com url to what i have set in my codes.

 

need help on how to solve this please.

below is my codes for the formsend page that needs to be loaded back inside the iframe name="iframe"

<?

include '../db_connect.php';
include("validate.php");
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$job_title = $_POST['job_title'];
$username = $_POST['username'];
$password = $_POST['password'];
$user_level = $_POST['user_level'];


$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email = stripslashes($email);
$job_title = stripslashes($job_title);
$username = stripslashes($username);
$password = stripslashes($password);
$user_level = stripslashes($user_level);

if ($first_name=='' or $last_name=='' or $username=='' or $password='')  { 
         error ('Some required fields are blank.\\n'.
              'Please fill them in and try again.');
    }
$sql_username_check = mysql_query("SELECT username FROM admin_user WHERE username='$username'");
  $username_check = mysql_num_rows($sql_username_check);
	if($username_check > 0){
		echo '<script language=javascript> alert("Username is already used!");top.location = "add.php";</script>';
		unset($username);
		exit();
	} 	 

  $db_password = md5($password);

  $sql = mysql_query("INSERT INTO admin_user (first_name, last_name, email, job_title, username, password, user_level)
	VALUES('$first_name', '$last_name', '$email', '$job_title', '$username', '$db_password', '$user_level')") or die (mysql_error());
  
     if(!$sql){
    echo '<script language=javascript> alert("Error creating account!");top.location = "add.php";</script>';
	exit();
     } else {
   $userid = mysql_insert_id();	   

   echo '<script language=javascript> alert("New account has been added!");top.location = "add.php";</script>';
     }
?>

 

i think the problem is in the javascript (top.location) how do i change this so it will load back to iframe?

thanks!

Link to comment
https://forums.phpfreaks.com/topic/47840-solved-help-on-iframe/
Share on other sites

any help for this?

 

i just need to fix this line

<script language=javascript> alert("Username is already used!");top.location = "add.php";</script>';

 

what code should i add or replace here so it will go back to the frame name "iframe" instead of going back on the top?

 

thanks!

Link to comment
https://forums.phpfreaks.com/topic/47840-solved-help-on-iframe/#findComment-233762
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.