Ver Mensaje Individual
  #4 (permalink)  
Antiguo 29/11/2008, 13:12
markitus_11
 
Fecha de Ingreso: noviembre-2008
Mensajes: 100
Antigüedad: 15 años, 5 meses
Puntos: 1
Respuesta: Con esto ya termino, conexion SQL

Otra duda, como puedo hacer para que haga la comprovación al final de todo? Es que sino le pasa delante a los scripts, y primero tiene que saltar los scripts.

Y finalmente me gustaria que en lugar de usar echo se usara alert, pero por lo que he visto no hay suficiente con poner alert ('text'), me salta un error, asi que me gustaria tambien que me dijeseis como hacerlo

Este es el codigo actual:

Código:
<script language="javascript">
function jsRegistrar()
{
	var Nom = document.getElementById('Nom').value;
	var Cognoms = document.getElementById('Cognoms').value;

        if(Nom == ""){
              alert("Has d'ingresar el teu nom");
              document.getElementById('Nom').focus();
              if (no_pasa_la_validación) return false;
        }
        if(Cognoms == ""){
              alert("Has d'ingresar els teus cognoms");
              document.getElementById('Cognoms').focus();
              if (no_pasa_la_validación) return false;
        }
}
</script>

<script type="text/javascript">
function verify_passwords(password1, password2)
{
	// do various checks, this will save people noticing mistakes on next page
	if (password1.value == '' || password2.value == '')
	{
		alert('Escriu la contrasenya i la seva confirmació.');
		return false;
	}
	else if (password1.value != password2.value)
	{
		alert('Les contrasenyes no concorden.');
		return false;
	}
	else
	{
		

		var junk_output;

		md5hash(password1, document.forms.register.Contrasenya_md5, junk_output, 0);
		md5hash(password2, document.forms.register.Contrasenyaconfirmacio_md5, junk_output, 0);

		

		return true;
	}
	return false;
}

function verify_emails(email1, email2)
{
	// do various checks, this will save people noticing mistakes on next page
	if (email1.value == '' || email2.value == '')
	{
		alert('Escriu l´email i la seva confirmació.');
		return false;
	}
	else if (email1.value != email2.value)
	{
		alert('Els emails no concorden.');
		return false;
	}
	else
	{
		

		var junk_output;

		md5hash(email1, document.forms.register.Email_md5, junk_output, 0);
		md5hash(email2, document.forms.register.Emailconfirm_md5, junk_output, 0);

		

		return true;
	}
	return false;
}
</script>

<?
if($registrar) {

$host = "localhost";
$user = "ampasant_basquet";
$pass = "50202050";
$db = "ampasant_basquet";

$conectar = mysql_connect($host,$user,$pass);
mysql_select_db($db,$conectar);


$Nom = $_POST['Nom'];
$Email = $_POST['Email'];



$resp = mysql_query("select * from usuarios where Email='$Email'") or die (mysql_error());
$existe = mysql_num_rows($resp);
if($existe == "0") {
mysql_query("insert into usuarios (Nom,Cognoms,Contrasenya,Email) values ('$Nom','$Cognoms','$Contrasenya','$Email')");
echo "Has estat registrat correctament.";
}
else {
echo "Aquest email ja es troba registrat.";
mysql_close($conectar); }
}
else {
?>

<form action="registrar.php" name="Formulari" method="post" onsubmit="return (verify_passwords(Contrasenya, Contrasenyaconfirmacio) && jsRegistrar() && verify_emails(Email, Emailconfirm));">

<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">

<tr>
	<td class="tcat">Registrar-se a la web de l´AMPA</td>
</tr>
<tr>
	<td class="panelsurround" align="center">
	<div class="panel">
		<div style="width:640px" align="left">

			<div class="smallfont" style="margin-bottom:3px">
				Si et registres, rebràs les ultimes noticies i informacions directament al teu correu
			</div>

			<div class="smallfont" style="margin-bottom:3px">
				<strong>Nom</strong>:<br />
				<input type="text" class="bginput" name="Nom" size="25" maxlength="" value="" id="Nom" style="width: 212px" /><span id="Nom"></span>
			</div> 
                        <div class="smallfont" style="margin-bottom:3px">
				<strong>Cognoms</strong>:<br />
				<input type="text" class="bginput" name="Cognoms" size="25" maxlength="" value="" id="Cognoms" style="width: 212px"/><span id="Cognoms"></span>
			</div>
<fieldset class="fieldset">
				<legend>Contrasenya</legend>

				<table cellpadding="0" cellspacing="3" border="0" width="400">
				<tr>
					<td colspan="2">Introduix la contrasenya per a la teva conta</td>
				</tr>
				<tr>
					<td>
						Contrasenya:<br />
						<input type="password" class="bginput" name="Contrasenya" size="25" maxlength="50" value="" onblur="varfield(1);" id="password_1"/>

					</td>
					<td>
						Confirmar Contrasenya:<br />
						<input type="password" class="bginput" name="Contrasenyaconfirmacio" size="25" maxlength="50" value="" onblur="varfield(2);" id="password_2"/>
						</td>
					</tr>
					<tr>
						<td colspan="2">

							<span id="password_1_status"></span>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<span id="password_2_status"></span>
					</td>
				</tr>
				</table>

			</fieldset>
			<fieldset class="fieldset">
				<legend>Direcció de Correo Electrònic</legend>
				<table cellpadding="0" cellspacing="3" border="0" width="400">
				<tr>
					<td colspan="2">Escriu una direcció de correu vàlida.</td>
				</tr>

				<tr>
					<td>
						Direcció de Correo Electrònic:<br />
						<input type="text" class="bginput" name="Email" size="25" maxlength="50" value="" onblur="varfield(1);" id="email1"/>
					</td>
					<td>
						Confirmar Direcció de Correo Electrònic:<br />
						<input type="text" class="bginput" name="Emailconfirm" size="25" maxlength="50" value="" onblur="varfield(2);" id="email2"/>

						</td>
					</tr>
					<tr>
						<td colspan="2">
							<span id="email1_status"></span>
						</td>
					</tr>
					<tr>
						<td colspan="2">

							<span id="email2_status"></span>
					</td>
				</tr>

<input type="submit" name="registrar" value="Registrar">
</form>
<?
}
?>