More Related Content
Similar to Conexion php (20)
Conexion php
- 1. <?php
/*Esta lineaespara incluirel archivoconlasvariables*/
include "registro.php";
/* CONECTARCON BASEDE DATOS**************** */
$con = mysql_connect($hostname,$user,$pass);
if (!$con){die('ERRORDECONEXION CON MYSQL: ' . mysql_error());}
/* ********************************************** */
/* CONECTA CON LA BASEDE DATOS **************** */
$database = mysql_select_db("inventario",$con);
if (!$database){die('ERRORCONEXIONCON BD:'.mysql_error());}
/* ********************************************** */
//REALIZARCONSULTA
$sql = "INSERT INTOregistrarVALUES
(NULL,'".$_POST['cod_patrimonial']."','".$_POST['fecha_registrar']."','".$_POST['area']."','".$_POST
['encargado']."','".$_POST['hardware']."','".$_POST['marca']."','".$_POST['modelo']."','".$_POST['de
scripcion']."')";
$result= mysql_query($sql);
if (! $result){
echo"La consultaSQLcontiene errores.".mysql_error();
exit();
}else {echo"<center><fontcolor='RED'>DATOSINSERTADOS
CORRECTAMENTE</font><aref='http://localhost/inventario2/index.php'>Volver</a>'";
}
?>
<?php
$hostname = "localhost";//enmi casoes localhost
$user = "root"; //enmi caso root
$pass = "";
?>