<?php
session_start();
if ($finame>=1){
echo "Prego effettuare il login <a href=\"/admin/index.php\"> Qui<br>
&copy;Bloghosteria.com<br>
</a>";
}
 elseif  ( empty( $finame ) ) {
?> Prego effettuare il login <a href="/admin/index.php"> Qui<br>
&copy;Bloghosteria.com<br>
</a>
<?php
} elseif ($finame==$_SESSION['finame']) { 
include ("headnavadmin.php");
echo "
<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;	
}
.style2 {
color: #009933;
font-weight: bold;
}
.style3 {
color: #FF0000;
font-weight: bold;

}
</style>
<p class=style2>Salve, 
". $_SESSION['laname'] ."  <a href=logout.php> Logout</a></p>";
  echo " <form method=POST action=searchtest2.php>
    <p align=center>Cerca Cliente/Fornitore, inserire almeno tre caratteri.</p>
	 <p align=center>
  <input type=Text size=20 maxlength=100 name=\"keywords\">&nbsp;</p>
    <p align=center><input type=Submit name=Submit value=Submit> </p>
    </form>";

          include "init2.php";
		  include "database.php";
       echo"<table width=95% align=center border=1 cellspacing=0 cellpadding=0.3><tr>
<td align=center bgcolor=#ffffff>Id</td> 
<td align=center bgcolor=#ffffff>CLI/FOR</td> 
<td align=center bgcolor=#ffffff>Azienda</td> 
<td align=center bgcolor=#ffffff>Email</td>
<td align=center bgcolor=#ffffff>Login</td> 
<td align=center bgcolor=#ffffff>Password</td> 
</tr>";
  if (strlen($_POST['keywords'])<1) { 
    echo "<p>ATTENZIONE!!!! Devi inserire almeno 1 caratteri</p>";
	exit();
	} 
    if (!empty($_POST['keywords'])) {
      $searchStr = $_POST['keywords'];
      if (ereg("^[a-zA-Z ]+$", $searchStr)) {
        $db = connect();
        if ($db) {
          print "<p class=\"whiteTxt\">Risultati per \"$searchStr\"</p><br>";
          $keys = explode(" ", $searchStr);

          for ($x = 0; $x < count($keys); $x++) {
            $querystr = "SELECT * FROM " . $db_table . " WHERE (((last_name = \"$keys[$x]\") OR (last_name LIKE \"%$keys[$x]%\")))";
            $result = mysql_query($querystr,$db);
            if ($frow = mysql_fetch_array($result)) {
               $found = true;
               do {
			  
                 print"<tr>
<td align=center><a href=\"dele.php?userid=". $frow["userid"] ."&first_name=". $frow["first_name"] ."\">CN</a>". $frow["first_name"] ."</td>
<td align=center><a href=\"modfdati.php?userid=". $frow["userid"] ."&last_name=". $frow["last_name"] ."\">mod</a> ". $frow["last_name"] ."</td> 
<td align=center><a href=\"/#\" onclick=\"window.open('dati.php?userid=". $frow["userid"] ."&last_name=". $frow["last_name"] ."','dati','scrollbars=yes,width=350,height=300,left='+(screen.availWidth/2-150)+',top='+(screen.availHeight/2-150)+'');return false;\">". $frow["last_name"] ."</a></td> 
<td align=center><a href=mailto:". $frow["email_address"] .">". $frow["email_address"] ."</a></td>
<td align=center>". $frow["username"] ."</td>
<td align=center>". $frow["decrypted_password"] ."</td> 
</tr>";
               } while ($frow = mysql_fetch_array($result));
			   
            } 
            
          }
          if (!$found) {
            print("<p class=\"whiteTxt\">Nessun risultato.<br>");
            
          }
          
          
            
        }
        else {
          print("<p class=\"whiteTxt\">Il database non è in funzione.</p>");
        }
      }
      else {
         print("<p class=\"whiteTxt\">Errore ! Hai inserito dei caratteri riservati..</p>");
       }
    }
    else {
       print("<p class=\"whiteTxt\">Deci inserire una parola chiave.</p>");
    }
  
 echo "</table>";
 } else {
echo "Prego effettuare il login <a href=\"/admin/index.php\"> Qui<br>
&copy;Bloghosteria.com<br>
</a>";
}
              
  ?>

