Pagina cadastro
Boa noite fiz esta pagina de cadastro precisaria criar ou colocar um script nela para ao clicar no link Verificar disponibilidade ele verifique se o usuario escolhido na hora do cadastro ja existe ou não. segue abaixo o codigo da pagina cadastro.php
<?php require_once('Connections/AGENDAMAX.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$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":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formcadastro")) {
$insertSQL = sprintf("INSERT INTO tb_usuarios (nome_completo_usuario, email_usuario, endereco_usuario, cidade_usuario, estado_usuario, pais_usuario, idade_usuario, usuario, senha) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nome_completo_usuario'], "text"),
GetSQLValueString($_POST['email_usuario'], "text"),
GetSQLValueString($_POST['endereco_usuario'], "text"),
GetSQLValueString($_POST['cidade_usuario'], "text"),
GetSQLValueString($_POST['estado_usuario'], "text"),
GetSQLValueString($_POST['pais_usuario'], "text"),
GetSQLValueString($_POST['idade_usuario'], "text"),
GetSQLValueString($_POST['usuario'], "text"),
GetSQLValueString($_POST['senha'], "text"));
mysql_select_db($database_AGENDAMAX, $AGENDAMAX);
$Result1 = mysql_query($insertSQL, $AGENDAMAX) or die(mysql_error());
$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!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">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="css/style1.css" type="text/css" />
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<title>.: Cadastro AGENDAMAX :.</title>
<style type="text/css"><!--
.style3 {
font-size: 22px;
color: #FF6600;
font-family: Geneva, Arial, Helvetica, sans-serif;
}.style5 {color: #000066}
.style6 {color: #FF6600}
.style8 {
color: #FF6600;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
}.style10 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; }
.style12 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 14px; }
body {
background-image: url(img/grad.png);
}
.style14 {font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 11px;
}
select, input, textarea {
font-size:14px;
font-family:Geneva, Arial, Helvetica, sans-serif;
color: #003366;
background-color: #EEEEEE;
border: 1px solid #CCCCCC;
}-->
</style>
<script>
function valida(){
d = document.formcadastro;
if(d.nome_completo_usuario.value==""){
alert("O campo nome completo deve ser preenchido.");
d.nome_completo_usuario.focus();
return false;
}
if(d.idade_usuario.value==""){
alert("O campo idade deve ser preenchido.");
d.idade_usuario.focus();
return false;
}
if(d.email_usuario.value==""){
alert("O campo e-mail deve ser preenchido!");
d.email_usuario.focus();
return false;
}
if(d.confirma_email.value==""){
alert("O campo de confirmação de e-mail deve ser preenchido!");
d.confirma_email.focus();
return false;
}
if(d.email_usuario.value != d.confirma_email.value){
alert("A confirmação de e-mail não confere!");
d.confirma_email.focus();
return false;
}
if(d.endereco_usuario.value==""){
alert("O campo endereco deve ser preenchido.");
d.endereco_usuario.focus();
return false;
}
if(d.cidade_usuario.value==""){
alert("O campo cidade deve ser preenchido.");
d.cidade_usuario.focus();
return false;
}
if(d.estado_usuario.value==""){
alert("O campo estado deve ser preenchido.");
d.estado_usuario.focus();
return false;
}
if(d.pais_usuario.value==""){
alert("O campo pais deve ser preenchido.");
d.pais_usuario.focus();
return false;
}
if(d.usuario.value==""){
alert("Deve-se escolher um usuario para acesso ao AGENDAMAX.");
d.usuario.focus();
return false;
}
if(d.senha.value==""){
alert("O campo senha deve ser preenchido!");
d.senha.focus();
return false;
}
if(d.confirma_senha.value==""){
alert("O campo de confirmação de senha deve ser preenchido!");
d.confirma_senha.focus();
return false;
}
if(d.senha.value != d.confirma_senha.value){
alert("A confirmação de senha não confere!");
d.confirma_senha.focus();
return false;
}
alert("Você foi cadastrado com sucesso !!!");
return true
}
</script>
<script language= "JavaScript">
function redirinicio(){location.href="index.php"
}
</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="500" align="center"><br />
<table width="800" border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="center" class="bord"><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" align="center" background="img/bg_fund_menu.jpg"><span class="style3">Pagina de Cadastro no <span class="style5">AGENDA<span class="style6">MAX</span></span></span></td>
</tr>
<tr>
<td align="center" bgcolor="#F4F4F4"><form id="formcadastro" name="formcadastro" method="post" onsubmit="return valida()" action="<?php echo $editFormAction; ?>">
<table width="750" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td height="30" colspan="2" align="center"><span class="style12">Todos os campos são obrigatorios serem preenchidos</span></td>
</tr>
<tr>
<td width="126" height="30" align="right"><span class="style10">Nome Completo:</span></td>
<td width="610" align="left"><span class="style10">
<label>
<input name="nome_completo_usuario" type="text" id="nome_completo_usuario" size="30" />
Idade:
<input name="idade_usuario" type="text" id="idade_usuario" size="5" />
</label>
</span></td>
</tr>
<tr>
<td height="30" align="right"><span class="style10"> E-mail:
</span></td>
<td height="30" align="left"><span class="style10">
<input name="email_usuario" type="text" id="email_usuario" size="30" />Repita o E-mail:
<input name="confirma_email" type="text" id="confirma_email" size="30" />
</span></td>
</tr>
<tr>
<td height="30" align="right"><span class="style10"> Endereço:
</span></td>
<td height="30" align="left"><span class="style10">
<input name="endereco_usuario" type="text" id="endereco_usuario" size="30" />
</span></td>
</tr>
<tr>
<td height="30" align="right"><span class="style10">Cidade:
</span></td>
<td height="30" align="left"><span class="style10">
<input name="cidade_usuario" type="text" id="cidade_usuario" size="30" />Estado:
<input name="estado_usuario" type="text" id="estado_usuario" size="20" />
Pais:
<input name="pais_usuario" type="text" id="pais_usuario" size="20" />
</span></td>
</tr>
<tr>
<td height="30" align="right"><span class="style10"> Usuario:</span></td>
<td height="30" align="left"><span class="style8">
<input name="usuario" type="text" id="usuario" size="30" />
<a href="verifica_disp.php" class="link_horizontal"> verificar disponibilidade</a></span></td>
</tr>
<tr>
<td height="30" align="right"><span class="style10"> Senha:
</span></td>
<td height="30" align="left"><span class="style10">
<input name="senha" type="password" id="senha" size="30" />Confirma Senha:
<input name="confirma_senha" type="password" id="confirma_senha" size="30" />
</span></td>
</tr>
<tr>
<td height="43" colspan="2" align="center"><label>
<input type="submit" name="bt_envia" id="bt_envia" value="CADASTRAR" />
<input type="button" name="bt_cancela" id="bt_cancela" value="CANCELAR" onclick="redirinicio()" />
</label></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="formcadastro" />
</form></td>
</tr>
</table></td>
</tr>
</table>
<table width="800" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td align="center" bgcolor="#F4F4F4" class="bord"><table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="40" align="center"><span class="style14">Web Agenda Desenvolvida por Tairone GuideTTi | </span><span ><a href="creditos.php" class="link_novidades">taironeguidetti@hotmail.com</a></a></span><span class="style14"><br />
Todos os direitos reservados</span></td>
</tr>
</table></td>
</tr>
</table> <p> </p></td>
</tr>
</table>
</body>
</html>
Obrigado até mais :D
Discussão (2)
Carregando comentários...