NOTA: apenas me inicio en el php por si acaso.
Código PHP:
<?php require_once('../Connections/transporte.php'); ?>
<?php
$cedula = htmlspecialchars(trim($_POST['cedula']));
$nombre= htmlspecialchars(trim($_POST['nombre']));
$apellido= htmlspecialchars(trim($_POST['apellido']));
$email= htmlspecialchars(trim($_POST['email']));
$direccion= htmlspecialchars(trim($_POST['direccion']));
$telefono= htmlspecialchars(trim($_POST['telefono']));
$activo= htmlspecialchars(trim($_POST['activo']));
$clave = trim($_POST['clave']);
$nivel= htmlspecialchars(trim($_POST['nivel']));
/*Hacemos la consulta */
mysql_select_db($database_transporte, $transporte);
$query = sprintf("SELECT login FROM usuario WHERE login='%s'", // Ahora
mysql_real_escape_string($_POST['login'],$transporte));
$result=mysql_query($query,$transporte);
if(mysql_num_rows($result))
{
echo "<script type='text/javascript'>
alert('El usuario ya se encuentra en la base de datos');
window.location= 'reg_usu.php';
</script>";
}else{
mysql_free_result($result);
/* encriptamos la clave */
if (isset($_POST['clave']))
{
$_POST['clave'] = sha1($_POST['clave']);
};
$query = sprintf ("INSERT INTO cliente
(cedula, nombre, apellido, email, direccion, telefono, activo)
VALUES
('%s','%s','%s','%s','%s','%s','%s')",
$query = sprintf ("INSERT INTO usuario
(login, clave, nivel)
VALUES
('%s','%s','%s')",
mysql_real_escape_string($_POST['cedula'],$transporte), mysql_real_escape_string($_POST['nombre'],$transporte),
mysql_real_escape_string($_POST['apellido'],$transporte), mysql_real_escape_string($_POST['email'],$transporte),
mysql_real_escape_string($_POST['direccion'],$transporte), mysql_real_escape_string($_POST['telefono'],$transporte),
mysql_real_escape_string($_POST['activo'],$transporte), mysql_real_escape_string($_POST['login'],$transporte),
mysql_real_escape_string($_POST['clave'],$transporte), mysql_real_escape_string($_POST['nivel'],$transporte)));
mysql_select_db($database_transporte, $transporte);
$result=mysql_query($query,$transporte);
//$result=mysql_query($query1,$transporte);
if(mysql_affected_rows())
{
echo "<script type='text/javascript'>
alert('El registro se ha incluido con exito');
window.location= 'index.php';
</script>";
}else{
echo "<script type='text/javascript'>
alert('Error introduciendo usuario');
window.location= 'reg_usu.php';
</script>";
} /* Cierre del else que corresponde a if(mysql_affected_rows.....) */
} /* Cierre del else que corresponde a if(mysql_num_rows...) */
?>