Jump to content

pedromsouza

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pedromsouza's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. When I use a method within a class, I get this error: [28-Feb-2011 14:48:37] PHP Warning: checkdate() expects parameter 1 to be long, string given in /Applications/MAMP/htdocs/classe_PreparaData.inc on line 17 Class Itself class PreparaData { public $saida; function validar_input ($entrada) { if(!(strlen($entrada)==10) and (strstr($entrada,'/'))) {echo "A data deve respeitar a formatação dd/mm/aaaa!<br>";} } function montar_timestamp ($entrada) { $a_partes=explode("/",$entrada); echo $a_partes[1].$a_partes[0].$a_partes[2].'<br>'; if(checkdate('$a_partes[1]','$a_partes[0]','$a_partes[2]')) {function exibir_data ($a_partes){ if(!(empty($a_partes))) {echo "$a_partes[1].$a_partes[0].$a_partes[2]";} ;};} else {echo "Data inválida!<br>"; var_dump($a_partes);} } function gravar_output ($saida) { $query=mysql_query("insert into tabela value ('$saida')"); } } ?> Help!
  2. Hi, I have to build some reports based on mysql queries. Nothing fancy, just text, columns... There are a lot of paid softwares but I can't (and don't want to) spend any $$ right now... So, considering that I want very simple reports almost like a table with heading and subtotals, I should write it myself. But I don't know how (still...). I'm looking for tips, tutorials, ebooks... anything that explains how to make a very simply report. Regards, Pedro.
  3. Anyone got this hidden character issue on TEXTWRANGLER? MAC OSX App
  4. Thanks Vincent, I wrote this include to switch between index.php and login.php according to cookie's data. Is it ok if I put this in every page? I'll read later about enhancing security but now I just have to make "basic login function" work. Include... <?php $erro==0; include "include_database_db.inc"; if(isset($_COOKIE["login"]) {$login = $_COOKIE["login"]; $erro==0;} elseif(isset($_COOKIE["senha"]) {$senha = $_COOKIE["senha"]; $erro==0;} else {$erro==1;exit;} if($erro!=0) {header ("Location: login_page.php");} else {header ("Location: index.php"); exit;} ?>
  5. Hi! I wanted to develop a code for authentication... I have to allow/deny access to some pages according to user's login. And users that didn't login shouldn't have access to any page but the first one. I created simples pages for explaining... PS: "senha" means "password" (portuguese). I created a page called "pre_index.html". Anyone should be able to access this one. It contains a form where users can insert login and password. After submitting, it would automatically lead to "index.php", the page for registered users only. So... this is pre_index.html: <code> <xhtml> <head> <title>Pagina Teste</title> </head> <body> <form action= method="post"> <input type="text" name="login">Login: </input> <input type="pwd" name="senha">Senha: </input> </form> </body> </xhtml> </code> The form send data to "login.php"; <code> <xhtml> <head> <title>Pagina Teste</title> </head> <body> <?php //recuperando valores do formulario $login=$_POST["login"]; $senha=$_POST["senha"]; //conectando ao banco de dados include "include_conect_bd.inc"; //verificando valores $verif = mysql_query ("select * from usr where login = '$login' and senha = '$senha'"); $verif2 = mysql_num_rows($verif); //gerando cookies if($verif2!=0) {echo "Login realizado com sucesso!<br>"; setcookie("login",$login); setcookie("senha",$senha);} elseif($verif2==0) {echo "Login não realizado, verifique login e senha.<br>"; setcookie("login"); setcookie("senha"); header ("location: index.php");} ?> </body> </xhtml> </code> "login.php" leads to "index.php"; <code> <?php include "include_verif_cookie.inc"; ?> <xhtml> <head> <title>Pagina Teste dos Usuarios Logados</title> </head> <body> <div> <ul> <li><a href="#">Home</a></li> <li><a href="#">Um</a></li> <li><a href="#">Dois</a></li> </ul> </div> </form> </body> </xhtml> </code> "index.php" contains an include that should check if user is registered (and allow/deny access to "index.php") so, the include... <code> <?php include "include_database_db.inc"; if(isset($_COOKIE["login"]) {$login = $_COOKIE["login"];} if(isset($_COOKIE["senha"]) {$senha = $_COOKIE["senha"];} ?> </code> #1: is it correct? #2: how can I send user back to "pre_index.html" if he is not logged in? #3: is it safe enough? Thanks in advance!
  6. It works! "break" is unnecessary because of the "if" clause... If it was a loop, then I should use break, correct? Thanks! PS: how do I set this topic "solved"?
  7. That's it! I put quotes and mysql_error()... now it (query) seems to be working but a new error shows up... [27-Jan-2011 20:44:38] PHP Fatal error: Cannot break/continue 1 level in /Applications/MAMP/htdocs/recebe_dados_cadastro_usuario.php on line 33 I wanted it to do the following: 1. if $login is already in use, BREAK to avoid duplicate line... 2. if $login is new, insert into.... Thanks a lot for replying!
  8. hi! I need a query that checks if typed login is new or already in use... when I run it... [27-Jan-2011 20:13:59] PHP Warning: mysql_num_rows() expects parameter 1 to be resource, null given in /Applications/MAMP/htdocs/recebe_dados_cadastro_usuario.php on line 30 Please help me (newbie)! <?php include "include_conecta_bd.inc"; $nome = $_POST["nome"]; $cpf = $_POST["cpf"]; $cnpj = $_POST["cnpj"]; $login = $_POST["login"]; $email = $_POST["email"]; $ddd = $_POST["ddd"]; $tel = $_POST["tel"]; $sexo = $_POST["sexo"]; $senha1 = $_POST["senha1"]; $senha2 = $_POST["senha2"]; $erro=0; if(empty($nome)) {echo "Favor digitar um nome.<br>"; $erro=1;} elseif(strlen($nome)<15) {echo "Favor digitar nome completo.<br>"; $erro=1;} elseif(empty($login) or strlen($login)<5) {echo "O login precisa ter 5 caracteres no mínimo.<br>"; $erro=1;} elseif((($senha1)!==($senha2)) or (strlen($senha2)<2)) {echo "As senhas não são idênticas.<br>"; $erro=1;} else {echo "Dados digitados corretamente!<br>";} {echo "<p>NOME:$nome<br>CPF:$cpf<br>LOGIN:$login<br>EMAIL:$email<br>TEL:$ddd.$tel<br>SEXO:$sexo<br></p>";} $verif = mysql_query ("select * from usr where login = $login"); $chk = mysql_num_rows ($verif); if($chk != 0) {break; echo "Este LOGIN já está em uso!<br>"; } elseif($verif == 0) {$resultado = mysql_query ("insert into usr (nome,cpf,login,sexo,email,ddd,tel,senha) values ('$nome','$cpf','$login','$sexo','$email','$ddd','$tel','$senha1')") or die(mysql_error()); echo mysql_error(); $linhas = mysql_affected_rows (); mysql_close ($conexao); echo "$linhas linha(s) afetada(s)!";} ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.