Jump to content

What's wrong with my code?


bugzy

Recommended Posts

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??  :shrug:

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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