Este es un registro que estado desarrollando y el siguiente problema o bueno lo que quisiera es que me ayuden ; al momento que doy clik en el boton registrar y hay campos vacios , me aparesca un script ; dando un mensaje "Faltan rellenar campos".
Código PHP:
 Ver original
<?php require_once('Connections/con_usuarios.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
break;
case "double":
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
// *** Redirect if username exists
$MM_flag="MM_insert";
$MM_dupKeyRedirect="ya_existe.php";
$loginUsername = $_POST['nombre_user'];
$LoginRS__query = sprintf("SELECT nombre_user FROM usuarios WHERE nombre_user=%s", GetSQLValueString($loginUsername, "text"));
//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
exit;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
}
$insertSQL = sprintf("INSERT INTO usuarios (nombre_user, nombre, apellido, password, email, imagen) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nombre_user'], "text"),
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['apellido'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['imagen'], "text"));
$insertGoTo = "entrada.php";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/base.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>.:Registro de usuarios::.</title>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
body {
margin-top: 0px;
background-image: url(fondo.jpg);
background-repeat: repeat-x;
}
-->
</style>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body>
<table width="80%" border="0" align="center">
<tr>
<td align="center" bgcolor="#129ae8"><!-- InstanceBeginEditable name="contenido" -->
<h2><img src="imagenes/rgus.jpg" width="500" height="100" /></h2>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Usuario:</strong></td>
<td><input type="text" name="nombre_user" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Nombre:</strong></td>
<td><input type="text" name="nombre" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Apellido:</strong></td>
<td><input type="text" name="apellido" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Contraseña:</strong></td>
<td><input type="password" name="password" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>E-mail:</strong></td>
<td><input type="text" name="email" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Imagen:</strong></td>
<td><input type="text" name="imagen" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insertar usuario" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
<!-- InstanceEndEditable --></td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
 
 



