pixeltrace Posted April 20, 2007 Share Posted April 20, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/47840-solved-help-on-iframe/ Share on other sites More sharing options...
pixeltrace Posted April 20, 2007 Author Share Posted April 20, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/47840-solved-help-on-iframe/#findComment-233762 Share on other sites More sharing options...
Glyde Posted April 20, 2007 Share Posted April 20, 2007 Change top.location to window.location Quote Link to comment https://forums.phpfreaks.com/topic/47840-solved-help-on-iframe/#findComment-233764 Share on other sites More sharing options...
pixeltrace Posted April 20, 2007 Author Share Posted April 20, 2007 thanks! its working fine now Quote Link to comment https://forums.phpfreaks.com/topic/47840-solved-help-on-iframe/#findComment-233768 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.