Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

manogaucho

[Resolvido] Apos Salvar Redirecionar para outra pagina

Recommended Posts

Tudo bem!

 

Estou de volta, tentei procurar o que precisava, mas não tive sorte, postei ate em outros foruns,para não ocupar os amigos deste, mas não fui ajudado, então aqui estou

 

Tenho um formulário rodando (ele é Modificado )já funcionando há uns 2 meses,nome da pagina é products.php, mas sempre quando clico em salvar os dados são salvos corretamente, mas retorna para pagina products.php, que fica toda em branco, assim tenho que fechar ele, e retornar para cadastrar novo produto, então queria que após clicar em salvar, redirecionasse para a pagina adicionar_precos.php, ou podendo ate voltar para mesma pagina products.php, mas não em branco.

 


<?php

//ADMIN :: products managment

ini_set("display_errors", "1");

include("./cfg/connect.inc.php");
include("./includes/database/mysql.php");
include("./cfg/category_functions.php");


//connect 2 database
db_connect(DB_HOST,DB_USER,DB_PASS) or die (db_error());
db_select_db(DB_NAME) or die (db_error());

session_start();
include("./checklogin.php");
if (!isset($_SESSION["log"]) || strcmp($_SESSION["log"],ADMIN_LOGIN)) //unauthorized
{
	die ("You are not authorized to view this page");
}

//get currency ISO 3 code
$currency_iso_3 = (defined('CONF_CURRENCY_ISO3')) ? CONF_CURRENCY_ISO3 : "USD" ;

//current language
include("./cfg/language_list.php");
if (!isset($_SESSION["current_language"]) ||
	$_SESSION["current_language"] < 0 || $_SESSION["current_language"] > count($lang_list))
		$_SESSION["current_language"] = 0; //set default language

if (isset($lang_list[$_SESSION["current_language"]]) && file_exists("./languages/".$lang_list[$_SESSION["current_language"]]->filename))
	include("./languages/".$lang_list[$_SESSION["current_language"]]->filename); //include current language file
else
{
	die("<font color=red><b>ERROR: Couldn't find language file!</b></font>");
}

if (!isset($_GET["productID"])) $_GET["productID"] = 0;

if (isset($_POST["save_product"])) //save item to the database
{

	if (!isset($_POST["price"]) || !$_POST["price"] || $_POST["price"] < 0)
		$_POST["price"] = 0; //price can not be negative

	if (!isset($_POST["name"]) || trim($_POST["name"])=="") $_POST["name"] = "not defined";

	$instock = (isset($_POST["in_stock"])) ? 1 : 0;

	if ($_POST["save_product"]) { //if $_POST["save_product"] != 0 then update item



		$pid = $_POST["save_product"];

	}
	else
	{
		//add new product
		db_query("INSERT INTO ".PRODUCTS_TABLE." (categoryID, name, description, customers_rating, Price, in_stock, customer_votes, items_sold, enabled, brief_description, list_price, product_code, picture, thumbnail, big_picture) VALUES ('".$_POST["categoryID"]."','".$_POST["name"]."','".$_POST["description"]."', 0, '".$_POST["price"]."', ".$instock.", 0, 0, 1, '".$_POST["brief_description"]."', '".$_POST["list_price"]."', '".$_POST["product_code"]."','','','');") or die (db_error());
		$pid = db_insert_id();

		$dont_update = 1; //don't update product

		$s  = "";
		$s1 = "UPDATE ".PRODUCTS_TABLE." SET categoryID=categoryID";
	}

	if (!isset($dont_update)) //update product info
	{
		$s .= " WHERE productID='".$_POST["save_product"]."'";
		db_query($s) or die (db_error());
		$productID = $_POST["save_product"];
	}
	else //don't update (insert query is already completed)
	{
		$s1.= " WHERE productID=$pid";
		db_query($s1) or die (db_error());
		$productID = $pid;
	}

	update_products_Count_Value_For_Categories(0);

	//close window
	echo "<script>\n";
	echo "window.opener.location.reload();\n";
	echo "window.close();\n";
	echo "</script>\n</body>\n</html>";
	exit;
}
else //get product from db
{
	if ($_GET["productID"])
	{

		$q = db_query("SELECT categoryID, name, description, customers_rating, Price, picture, in_stock, thumbnail, big_picture, brief_description, list_price, product_code FROM ".PRODUCTS_TABLE." WHERE productID='".$_GET["productID"]."'") or die (db_error());
		$row = db_fetch_row($q);
			if (!$row) //product wasn't found
		{
			echo "<center><font color=red>".ERROR_CANT_FIND_REQUIRED_PAGE."</font>\n<br><br>\n";
			echo "<a href=\"javascript:window.close();\">".CLOSE_BUTTON."</a></center></body>\n</html>";
			exit;
		}

		if (isset($_GET["delete"])) //delete product
		{


			$q = db_query("DELETE FROM ".PRODUCTS_TABLE." WHERE productID='".$_GET["productID"]."'") or die (db_error());

			//close window
			echo "<script>\n";
			echo "window.opener.location.reload();\n";
			echo "window.close();\n";
			echo "</script>\n</body>\n</html>";
			exit;
		}

		$title = $row[1];

	}
	else //creating new item
	{
		$title = ADMIN_PRODUCT_NEW;
		$cat = isset($_GET["categoryID"]) ? $_GET["categoryID"] : 0;
		$row = array($cat,"","","",0,"",1,"","","",0,"");
	}
}



?>

<html>

<head>
<link rel=STYLESHEET href="images/backend/style-backend.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo DEFAULT_CHARSET;?>">
<title><?php echo ADMIN_PRODUCT_TITLE;?></title>

</head>

<body bgcolor=#FFFFE2>
<center>
<p>
<b><?php echo $title; ?></b>

<form enctype="multipart/form-data" action="products.php" method=post>

<table width=100% border=0 cellpadding=3 cellspacing=0>

<tr>
<td align=right><?php echo ADMIN_CATEGORY_PARENT;?></td>
<td>
<select name="categoryID">
<option value="0"><?php echo ADMIN_CATEGORY_ROOT;?></option>
<?php
//show categories select element
$cats = fillTheCList(0,0);
for ($i=0; $i<count($cats); $i++)
{
	echo "<option value=\"".$cats[$i][0]."\"";
	if ($row[0] == $cats[$i][0]) //select category
		echo " selected";
	echo ">";
	for ($j=0;$j<$cats[$i][5];$j++) echo "  ";
	echo $cats[$i][1];
	echo "</option>";
}
?>
</select>
</td>
</tr>

<tr>
<td align=right><?php echo ADMIN_PRODUCT_NAME;?></td>
<td><input type="text" name="name" value="MANINHO - TESTE<?php echo str_replace("\"",""",$row[1]); ?>"></td>
</tr>

<tr>
<td align=right><?php echo ADMIN_PRODUCT_CODE;?></td>
<td><input name="product_code" type="text" value="01 <?php echo str_replace("\"",""",$row[11]); ?>" maxlength="2">
 <strong>  <font color="#FF0000">Não Apagar ou Modificar </font></strong> </td>
</tr>

<?php	if ($_GET["productID"]) { ?>

<?php }; ?>

<tr>
<td align=right><?php echo ADMIN_PRODUCT_PRICE;?><br>
</td>
<td><input type="text" name="price" value=<?php echo $row[4]; ?>></td>
</tr>

<?php
if ($row[6]<0) $is = 0;
else $is = $row[6];

?>
<tr>
<td align=right><?php echo ADMIN_PRODUCT_INSTOCK;?>:</td>
<td><input type="checkbox" name="in_stock"<?php if ($is > 0) echo " checked"; ?>></td>
</tr>

</table>


<p><center>
<input type="submit" value="<?php echo SAVE_BUTTON;?>" width=5>
<input type="hidden" name="save_product" value=<?php echo $_GET["productID"]; ?>>
<input type="button" value="<?php echo CANCEL_BUTTON;?>" onClick="window.close();">
<?php	if ($_GET["productID"]) echo "<input type=button value=\"".DELETE_BUTTON."\" onClick=\"confirmDelete('".QUESTION_DELETE_CONFIRMATION."','products.php?productID=".$_GET["productID"]."&delete=1');\">"; ?>
</center></p>
</form>


</center>
</body>

</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

ola, você pode usar uma janela popup por exemplo, a hora q você faz o cadastro abre a janela pop up, com uma mensagem de erro ao cadastrar ou cadatro correto, e nesse pop up você redireciona para qualquer lugar q você quiser.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.