Location: PHPKode > projects > phpMyPrepaid > phpmyprepaid/www/include/divers/save_card_tpl.php
<?php
include_once('../../config.inc.php');
if (!isset($_SESSION['oreon'])) Session::Start();
$oreon=$_SESSION['oreon'];
$html=addslashes($_GET["html"]);
$tpl_name=addslashes($_GET["tplname"]);
$cards_x=$_GET["cards_x"];
$cards_y=$_GET["cards_y"];
$margin_cell=$_GET["margin_cell"];
$margin_top=$_GET["margin_top"];
$locID=$_GET['locID'];
$new=$_GET['new'];
if ($locID<1)  {
	$locID=$_SESSION['locID'];
	$new='True';
}

$result = $_SESSION["oreon"]->database->database->query("SELECT * FROM cards_tpl WHERE tpl_name='$tpl_name' AND tpl_location='$locID'");
$nr=$oreon->database->database->result_num_rows($result);
if ($nr>0 and $new=='True') {
	$error="You can't add two cards with same name !";
	echo $error;
	return ;
}

if ($nr==0 and $new!='True') {
	$new='True';
}


if ($new == 'True')  {
	$result = $_SESSION["oreon"]->database->database->query("INSERT INTO cards_tpl (tpl_name,tpl_value,tpl_location,cards_x,cards_y,margin_cell,margin_top) VALUES('$tpl_name','$html','$locID','$cards_x','$cards_y','$margin_cell','$margin_top')");
echo "Suscessfull save the new card $tpl_name";
}
else
{
	$result = $_SESSION["oreon"]->database->database->query('UPDATE cards_tpl SET tpl_value=\''.$html.'\',cards_x='.$cards_x.',cards_y='.$cards_y.',margin_cell='.$margin_cell.',margin_top='.$margin_top.' WHERE tpl_name=\''.$tpl_name.'\' AND tpl_location=\''.$locID.'\'');
	echo "Suscessfull modified card $tpl_name";
}
?>
Return current item: phpMyPrepaid