<?php
session_start();
if ($first_name>=1){
echo "Prego effettuare il login <a href=\"/contenuti.php\"> Qui<br>
&copy;Bloghosteria.com<br>
</a>";
}
 elseif  ( empty( $first_name ) ) {
?> Prego effettuare il login <a href="/contenuti.php"> Qui<br>
&copy;Bloghosteria.com<br>
</a>
<?php
} elseif ($first_name==$_SESSION['first_name']) {
include ("langselect.php");
include ("config.php");
 echo "$lang0003, 
". $_SESSION['last_name'] ." <a href=logout.php> Logout</a> 
<style type=\"text/css\">

a:link, a:visited {
	color: #009933; text-decoration: none;
	font-weight: bold;
}

a:hover {
	color: #ff6600;	text-decoration: none;
	font-weight: bold;	
}
</style>
<p><a href=\"sample.php?last_name=$Ragione_Sociale\">$lang0004</a> | 
<a href=\"clgestord.php?Ragione_Sociale=$last_name\">$lang0005</a> |
<a href=mailto:$emailwebm>$lang0006</a> | 
<a href=\"gestpag.php?Ragione_Sociale=$last_name\">$lang0007</a></p>";
  echo"<p align=center> 
<div align=center>
";
  
$npag = ("nd");
$inpgm = ("$lang0151");   		
mysql_connect("$hhost","$login","$pass") or die ("Problem connecting to DataBase");
$query = "SELECT * FROM sd_ordini WHERE Ragione_Sociale = '$Ragione_Sociale' and Tipo_Pagamento='$npag' ";
$result = mysql_db_query("$dbname", $query); 
if ($result) {


$query ="update sd_ordini set Tipo_Pagamento='$Tipo_Pagamento', Status='$inpgm'
where Ragione_Sociale='$Ragione_Sociale' and Tipo_Pagamento='$npag' ";
$result = mysql_db_query("$dbname", $query);

echo "<p>$lang0135</p>";



}else{
echo "<p>$lang0121</p>
<p>$emailwebm</p>";
}
If ($Tipo_Pagamento=="Contras"){
$Banca="Contrassegno";

         mysql_connect("$hhost","$login","$pass") or die ("Problem connecting to DataBase");
		 $query = "SELECT * FROM pagam ";
$result = mysql_db_query("$dbname", $query);
 $sql = mysql_query("INSERT INTO pagam (Total, Ragione_Sociale, Banca, Ordini)
		VALUES('$Total', '$Ragione_Sociale', '$Banca', '$Ordini')") or die (mysql_error());

if(!$sql){
	echo '$lang0121';
} else {
	
echo "";
	
}
} else {
mysql_connect("$hhost","$login","$pass") or die ("Problem connecting to DataBase");
$query = "SELECT * FROM sd_banche where ID_Banca='$Tipo_Pagamento' ";
$result = mysql_db_query("$dbname", $query);
if ($result) {
while ($r = mysql_fetch_array($result)) {
$ID_Banca = $r["ID_Banca"];
$Banca = $r["Banca"];

}
mysql_connect("$hhost","$login","$pass") or die ("Problem connecting to DataBase");
 $query = "SELECT * FROM pagam ";
$result = mysql_db_query("$dbname", $query);
$sql = mysql_query("INSERT INTO pagam (Total, Ragione_Sociale, Banca, Ordini)
		VALUES('$Total', '$Ragione_Sociale', '$Banca', '$Ordini')") or die (mysql_error());

if(!$sql){
	echo '$lang0121';
} else {
	
echo "";
	
}
}

}
} else {
echo "Prego effettuare il login <a href=\"contenuti.php\"> Qui<br>
&copy;Bloghosteria.com<br>
</a>";
}		 
?>
