bugzy Posted April 22, 2012 Share Posted April 22, 2012 Everytime I'm I click the submit, it's opening up a new tab browser. I have no problem with the code as it's not giving me any error the only problem I'm getting is the next page is going to be open a new browser tab. <?php require_once("includes/connection.php"); ?> <?php require_once("includes/functions.php"); ?> <?php require("includes/header.php"); ?> <?php require("includes/navbar.php"); ?> <?php require("staff_sidebar.php"); ?> <div id="content"> <h1>Add Subject</h1><br> <table> <tr><td> <?php $datenow = date('Y/m/d H:i:s', time()); if(isset($_POST['submit'])) { $proj_name = me_mysql_prep(trim($_POST['proj_name'])); $proj_content = me_mysql_prep($_POST['proj_content']); if(empty($_POST['proj_name'])) { $empty_name = array('Project Name Cannot Be Empty'); } if(empty($_POST['proj_content'])) { $empty_content = array('Content Cannot Be Empty'); } if(isset($empty_name) && isset($empty_content)) { $error_merge = array_merge($empty_name, $empty_content); } else if(isset($empty_name)) { $error_merge = array_merge($empty_name); } else if(isset($empty_content)) { $error_merge = array_merge($empty_content); } else { $error_merge = array(); } if(!empty($error_merge)) { foreach($error_merge as $error) { echo "<span class=\"error_validation\">*". $error . "<br></span>"; } } else { $query = "INSERT into rec_projects (proj_name, content, date_reg) VALUES('{$proj_name}', '{$proj_content}', '{$datenow}')"; if($result = mysql_query($query,$connection)) { me_redirect_to("added_project.php?added=1"); } else { echo "Can\'t add the project: ". mysql_error() . ""; } } echo "<br><br>"; } ?> </td></tr> </table> <table> <form target="add_project.php" method="post" name="add_subject"> <tr> <td>Project Name:</td> <td><input type="text" size="50" name="proj_name"></td> </tr> <tr> <td>Content:</td> <td><textarea cols="70" rows="20" name="proj_content"></textarea></td> </tr> <tr> <td></td> <td><input type="submit" value="Add Project" name="submit" size="30"></td> </tr> </form> </table> </div> <?php require("includes/footer.php"); ?> I'm using this function to redirect to the next page <?php function me_redirect_to( $location = NULL ) { if ($location != NULL) { header("Location: {$location}"); exit; } } ?> I don't know why it's opening up a new tab?? Quote Link to comment Share on other sites More sharing options...
litebearer Posted April 22, 2012 Share Posted April 22, 2012 hmmm in your form, try changing this target="add_project.php" to this action ="add_project.php" Quote Link to comment Share on other sites More sharing options...
xyph Posted April 22, 2012 Share Posted April 22, 2012 This is a mark-up/HTML issue. http://reference.sitepoint.com/html/form/target http://reference.sitepoint.com/html/form/action Quote Link to comment Share on other sites More sharing options...
bugzy Posted April 22, 2012 Author Share Posted April 22, 2012 Thanks guys! Solved! Quote Link to comment 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.