<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	 
	<title>Codigos BCM</title>
	<link href="StyleSheet.css" rel="StyleSheet" />

</head>
<body>
<?php
function conectarse()
{
   if (!($link=@mysql_connect("localhost","keytecht_bcm2","cerrajeria2017"))) 
   {
      echo "Error conectando a la base de datos.";
      exit();
   }
   if (!mysql_select_db("keytecht_tamadre",$link))
   {
      echo "Error seleccionando la base de datos.";
      exit();
   }
   return $link;
}
$vin=(string)$_POST['entrada'];
$vin_patch= htmlentities($vin, ENT_QUOTES); 
$link=conectarse();
?>
    
	<img src="bcm.jpg" class="background" /> 
<form class="contact_form" action="index.php" method="post" id="contact_form" runat="server"> 
	<div id="consulta"> 
		<ul>  
			<li>
				<input type="text" name="entrada" value="" size="5" placeholder="BCM:" MAXLENGTH="5" required />
				<span class="form_hint">5 Digits</span>
			</li>
			<li>
				<button class="submit" type="submit">Check</button>
			</li>
    
    
 <?php    
if (!empty($vin_patch))
{
 echo ""; 

sleep (15);

$link=conectarse();

if($_SERVER["HTTP_X_FORWARDED_FOR"]){
        $IP=$_SERVER["HTTP_X_FORWARDED_FOR"];
 }else{
        $IP=$_SERVER["REMOTE_ADDR"];
 }

$sql = "INSERT INTO consultas".
       "(codigo, IP, fecha) ".
       "VALUES('$vin_patch', '$IP', NOW())";
mysql_select_db('freebcms_tamadre');
$retval = mysql_query( $sql, $link );

$res_id=mysql_query("
SELECT *
FROM `codigo`
WHERE `codigo` = '$vin_patch'
",$link);
                   while ($row_id=mysql_fetch_array($res_id)){
                   $old=$row_id["OLD"];
                   $new=$row_id["NEW"]; 
          echo '<li>';
 echo '<input type="text" name="new"" readonly value="';echo $old;echo '" />';
 echo '<span class="form_hint">Old</span>';
 echo '</li>';
 echo '<li>';
 echo '<input type="text" name="new" readonly value="';echo $new;echo '" />';
 echo '<span class="form_hint">New</span>';
 echo '</li>';
}        
         $row_id=NULL;
         mysql_free_result($res_id);                  
}
?>            
<img src="text.png">