Laisbn 0 Denunciar post Postado Março 26, 2011 Olá galera! Estou fazendo um sisteminha em PHP, utilizando a ferramenta Dreamwear, e gostaria de trazer os dados cadastrados no banco de dados do cliente logado e nao estou conseguinho. Alguem pode me ajudar. Segue o codigo abaixo. <?php require_once('Connections/bd_trespatas.php'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE cadastro SET nome=%s, data_nasc=%s, rg=%s, cpf=%s, sexo=%s, logradouro=%s, numero=%s, complemento=%s, bairro=%s, cep=%s, cidade=%s, tel_fixo=%s, tel_movel=%s, email=%s, idstatus=%s, login=%s, senha=%s WHERE id=%s", GetSQLValueString($_POST['nome'], "text"), GetSQLValueString($_POST['data_nasc'], "date"), GetSQLValueString($_POST['rg'], "text"), GetSQLValueString($_POST['cpf'], "text"), GetSQLValueString($_POST['sexo'], "text"), GetSQLValueString($_POST['logradouro'], "text"), GetSQLValueString($_POST['numero'], "text"), GetSQLValueString($_POST['complemento'], "text"), GetSQLValueString($_POST['bairro'], "text"), GetSQLValueString($_POST['cep'], "text"), GetSQLValueString($_POST['cidade'], "text"), GetSQLValueString($_POST['tel_fixo'], "text"), GetSQLValueString($_POST['tel_movel'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['idstatus'], "text"), GetSQLValueString($_POST['login'], "text"), GetSQLValueString($_POST['senha'], "text"), GetSQLValueString($_POST['id'], "int")); mysql_select_db($database_bd_trespatas, $bd_trespatas); $Result1 = mysql_query($updateSQL, $bd_trespatas) or die(mysql_error()); } $colname_Recordset1 = "-1"; if (isset($_GET['login'])) { $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['login'] : addslashes($_GET['login']); } mysql_select_db($database_bd_trespatas, $bd_trespatas); $query_Recordset1 = sprintf("SELECT * FROM cadastro WHERE login = '%s' ORDER BY login ASC", $colname_Recordset1); $Recordset1 = mysql_query($query_Recordset1, $bd_trespatas) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?><!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Consultar Cadastro</title> </head> <body> <table width="1316" height="470" border="1" align="center"> <tr> <td height="212" colspan="3" bgcolor="#507BAF"><div align="center"></div> <div align="center"><img src="imagenstitulo.png" alt="titulo" width="791" height="185"></div></td> </tr> <tr> <td width="235" bgcolor="#7395BF"> </td> <td width="1065" colspan="2"><div align="center"> <form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Id:</td> <td><?php echo $row_Recordset1['id']; ?></td> </tr> <tr valign="baseline"> <td nowrap align="right">Nome:</td> <td><input type="text" name="nome" value="<?php echo $row_Recordset1['nome']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Data_nasc:</td> <td><input type="text" name="data_nasc" value="<?php echo $row_Recordset1['data_nasc']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Rg:</td> <td><input type="text" name="rg" value="<?php echo $row_Recordset1['rg']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Cpf:</td> <td><input type="text" name="cpf" value="<?php echo $row_Recordset1['cpf']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Sexo:</td> <td><input type="text" name="sexo" value="<?php echo $row_Recordset1['sexo']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Logradouro:</td> <td><input type="text" name="logradouro" value="<?php echo $row_Recordset1['logradouro']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Numero:</td> <td><input type="text" name="numero" value="<?php echo $row_Recordset1['numero']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Complemento:</td> <td><input type="text" name="complemento" value="<?php echo $row_Recordset1['complemento']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Bairro:</td> <td><input type="text" name="bairro" value="<?php echo $row_Recordset1['bairro']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Cep:</td> <td><input type="text" name="cep" value="<?php echo $row_Recordset1['cep']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Cidade:</td> <td><input type="text" name="cidade" value="<?php echo $row_Recordset1['cidade']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Tel_fixo:</td> <td><input type="text" name="tel_fixo" value="<?php echo $row_Recordset1['tel_fixo']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Tel_movel:</td> <td><input type="text" name="tel_movel" value="<?php echo $row_Recordset1['tel_movel']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Email:</td> <td><input type="text" name="email" value="<?php echo $row_Recordset1['email']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Idstatus:</td> <td><input type="text" name="idstatus" value="<?php echo $row_Recordset1['idstatus']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Login:</td> <td><input type="text" name="login" value="<?php echo $row_Recordset1['login']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Senha:</td> <td><input type="text" name="senha" value="<?php echo $row_Recordset1['senha']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Update record"></td> </tr> </table> <input type="hidden" name="MM_update" value="form1"> <input type="hidden" name="id" value="<?php echo $row_Recordset1['id']; ?>"> </form> <p> </p> </div></td> </tr> </table> </body> </html> <?php mysql_free_result($Recordset1); ?> Compartilhar este post Link para o post Compartilhar em outros sites
Wess 1 Denunciar post Postado Março 28, 2011 Laisbn, é nesta QUERY que você pega os dados do usuário, pois foi isso que entendi no seu código. $query_Recordset1 = sprintf("SELECT * FROM cadastro WHERE login = '%s' ORDER BY login ASC", $colname_Recordset1); Seguinte troque no WHERE o sinal de = por LIKE: $query_Recordset1 = sprintf("SELECT * FROM cadastro WHERE login LIKE '%s' ORDER BY login ASC", $colname_Recordset1); Veja se isso lhe ajude. Compartilhar este post Link para o post Compartilhar em outros sites