NapsterZ Posted February 12, 2014 at 12:43 PM Report #545018 Posted February 12, 2014 at 12:43 PM Boas, Estou no 12º Ano e estou a desenvolver o meu projeto (PAP). Estou a trabalhar no dreaweaver e de momento não estou a conseguir verificar a password pois tenho um campo de confirmação da password e não estou a conseguir verificá-la gostaria que me dessem umas luzes pois sou amador no que toca a php e dreamweaver. Desde já um Obrigado
HappyHippyHippo Posted February 12, 2014 at 01:17 PM Report #545030 Posted February 12, 2014 at 01:17 PM que código já tens desenvolvido ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
bioshock Posted February 12, 2014 at 02:15 PM Report #545033 Posted February 12, 2014 at 02:15 PM Basicamente o que tens de fazer é verificar se determinado campo é totalmente igual ao outro. Se campo1 = campo2 então mensagem: as senhas coincidem Se não mensagem: as senhas não coincidem
NapsterZ Posted February 13, 2014 at 08:34 AM Author Report #545114 Posted February 13, 2014 at 08:34 AM <?php header('Content-Type: text/html; charset=iso-8859-1'); if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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"] == "registo")) { $insertSQL = sprintf("INSERT INTO cliente (`User`, Password, Nome, Apelido, Email, Morada, CodigoPostal, Localidade, N_Contribuinte, Telefone, CC) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['User'], "text"), GetSQLValueString($_POST['Password'], "text"), GetSQLValueString($_POST['Nome'], "text"), GetSQLValueString($_POST['Apelido'], "text"), GetSQLValueString($_POST['Email'], "text"), GetSQLValueString($_POST['Morada'], "text"), GetSQLValueString($_POST['CodigoPostal'], "text"), GetSQLValueString($_POST['Localidade'], "text"), GetSQLValueString($_POST['N_Contribuinte'], "text"), GetSQLValueString($_POST['Telefone'], "text"), GetSQLValueString($_POST['CC'], "text")); /*if( $_POST['Password'] !== $_POST['Password2'] ) { die('Ocorreu um erro ao registar: a password e a sua confirmação devem ser iguais'); }*/ //else //{ if( $_POST['Email'] !== $_POST['Email2'] ) { die('rgrtgtrhthryhhyyhhhy'); } //} mysql_select_db($database_DB, $DB); $Result1 = mysql_query($insertSQL, $DB) or die(mysql_error()); } Depois da password tambem é para verificar se o email tambem coincide mas gostava de fazer enquanto se efetua o registo ou seja em tempo real.
bioshock Posted February 13, 2014 at 09:15 AM Report #545116 Posted February 13, 2014 at 09:15 AM Precisas de jQuery para isso.
Cafunfa Posted February 13, 2014 at 05:35 PM Report #545172 Posted February 13, 2014 at 05:35 PM Precisas de jQuery para isso. É uma solução (que eu utilizava)... mas a partir deste código também deveria chegar lá. Isso não é um problema de parêntesis? Tenta mudar por isto... if( $_POST['Password'] !== $_POST['Password2'] ) { die('Ocorreu um erro ao registar: a password e a sua confirmação devem ser iguais'); } else { if( $_POST['Email'] !== $_POST['Email2'] ) { die('Email errado!'); } else{ //password e email correto mysql_select_db($database_DB, $DB); $Result1 = mysql_query($insertSQL, $DB) or die(mysql_error()); } } //fim de else
yoda Posted February 13, 2014 at 11:57 PM Report #545224 Posted February 13, 2014 at 11:57 PM Não consegues fazer essa verificação em "realtime" sem usares javascript, ou jQuery como te foi indicado. before you post, what have you tried? - http://filipematias.info sense, purpose, direction
Rui Carlos Posted February 17, 2014 at 11:56 PM Report #545631 Posted February 17, 2014 at 11:56 PM Queres que te apareça um erro enquanto escreves ou apenas depois de submeteres o formulário? Só no segundo caso é que consegues fazer sem Javascript. Rui Carlos Gonçalves
I-NOZex Posted February 18, 2014 at 02:43 PM Report #545678 Posted February 18, 2014 at 02:43 PM em client-side so com js/jquery/wtver_based_on_js podes fzr validação so com js, ou com recurso a javascript, neste caso a validação cliente e servidor podia ficar apenas num ficheiro php... B2R » Beat2Revolution v3.0b | Regista e divulga-nos beat2revolution.net
NapsterZ Posted February 23, 2014 at 01:10 PM Author Report #546338 Posted February 23, 2014 at 01:10 PM Boas, obrigado por todas as respostas consegui o pretendido. Agora tenho mais um problema. É a primeira vez que trabalho com o dreamweaver e jurei para nunca mais vou só acabar a minha PAP aqui pois ainda não percebo muito de PHP mas o que percebo o Dreamweaver parece não me ajudar na minha aprendizagem. Ora bem o problema é que o dreamweaver não me vai buscar a variável à base de dados: Faço o seguinte Select: $query_Recordset1 = sprintf("SELECT Password FROM cliente WHERE Email = %s", GetSQLValueString($colname_Recordset1, "text")); e se fizer um teste o resultado é o da declaração da variável: $colname_Recordset1 = "-1"; o problema acho que está na parte do: GetSQLValueString($colname_Recordset1, "text") pois já na pagina de login ele não me aceitava o Username e dava-me o erro: unknown 'Napster' Column in table 'cliente' e dado esse erro exprimentei fazer: $LoginRS__query=sprintf("SELECT User, Password FROM cliente WHERE User='".$loginUsername."' AND Password='".$password."'"); e aceitou agora neste recordset ele não me aceita o select. Tenho o seguinte código: <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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; } } $colname_Recordset1 = "-1"; if (isset($_POST['Email'])) { $colname_Recordset1 = $_POST['Email']; } mysql_select_db($database_DB, $DB); $query_Recordset1 = sprintf("SELECT Password FROM cliente WHERE Email = %s", GetSQLValueString($colname_Recordset1, "text")); $Recordset1 = mysql_query($query_Recordset1, $DB) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); if($totalRows_Recordset1==0) { $erro="Não existe nenhum utilizador com o endereço de e-mail: ".$colname_Recordset1; } else { mysql_free_result($colname_Recordset1); } ?> Gostava mesmo que me ajudassem pois de momento o prazo para acabar isto está a ficar curto e não me é possivel dedicar à linguagem PHP a 100% pois o horário é preenchido durante a semana e entretanto no dia 24 de março começo o estágio e não tenho tempo nem para Jogar CS:GO xD. Obrigado.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now