taudujas Posted July 30, 2004 Report Share Posted July 30, 2004 Pessoal, estou fazendo um cadastro assim:<form name="form1" method="post" action="<?echo $PHP_SELF;?>?entrar=s"> <table width="68%" border="0" align="center"> <tr> <td width="32%">Nome:</td> <td width="68%"><input name="nome" type="text" id="nome" maxlength="80"></td> </tr> <tr> <td>Email:</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td>Login:</td> <td><input name="login" type="text" id="login"></td> </tr> <tr> <td>Senha:</td> <td><input name="senha" type="text" id="senha"></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Cadastrar"></td> </tr> </table></form><?include "config.php";if($entrar == 's') {foreach ($_POST as $campo => $valor) { $$campo = strip_tags($valor); }$sql = "insert into usuarios(nome, email, login, senha)VALUES('$nome', '$email', '$login', '$senha')";$exec = mysql_query($sql);} ?>o que tem errado?? Quote Link to comment Share on other sites More sharing options...
0 rog Posted July 30, 2004 Report Share Posted July 30, 2004 deve ser if($entrar == 's') dê um echo de $entrar que deve ser null e indefinidaps se você colocar as mesnsagems de error, você poderas tirar bug sozinho Quote Link to comment Share on other sites More sharing options...
0 richenrique Posted July 30, 2004 Report Share Posted July 30, 2004 qual a mensagem de erro apresentada? Quote Link to comment Share on other sites More sharing options...
0 Fabyo Posted July 30, 2004 Report Share Posted July 30, 2004 index.php:<form name="form1" method="post" action="index.php?entrar=s"> <table width="68%" border="0" align="center"> <tr> <td width="32%">Nome:</td> <td width="68%"><input name="nome" type="text" id="nome" maxlength="80"></td> </tr> <tr> <td>Email:</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td>Login:</td> <td><input name="login" type="text" id="login"></td> </tr> <tr> <td>Senha:</td> <td><input name="senha" type="text" id="senha"></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Cadastrar"></td> </tr> </table></form><?include "config.php";if(isset($_GET["entrar"])){$entrar = $_GET["entrar];if($entrar == 's') {foreach ($_POST as $campo => $valor) { $$campo = strip_tags($valor); }$sql = "insert into usuarios(nome, email, login, senha)VALUES('$nome', '$email', '$login', '$senha')";$exec = mysql_query($sql);}}?> Quote Link to comment Share on other sites More sharing options...
0 rog Posted July 30, 2004 Report Share Posted July 30, 2004 oi fabyoeu não sei porque tudo mundo tem mania de redefinir variaveis aqui já existem##################if(isset($_GET["entrar"])){$entrar = $_GET["entrar"];if($entrar == 's') {##################if(isset($_GET["entrar"])){if($_GET["entrar"] == 's') {foreach ($_POST as $campo => $valor) { $$campo = strip_tags($valor); }# tambem não sei porque colocar a requesta numa variavel se não for usa lamysql_query("insert into usuarios(nome, email, login, senha)VALUE ('$nome', '$email', '$login', '$senha')");}}##################quanto menor for o codigo melhor ele erog Quote Link to comment Share on other sites More sharing options...
0 taudujas Posted July 30, 2004 Author Report Share Posted July 30, 2004 Fabyo o $_PHPSELF não funciona mais?? eu pensava que ele ainda funcionava, tentei achar referencias sobre ele no manual mas não achei. Errei feio.hehehe Quote Link to comment Share on other sites More sharing options...
0 Illidan Posted July 30, 2004 Report Share Posted July 30, 2004 Fabyo o $_PHPSELF não funciona mais?? eu pensava que ele ainda funcionava, tentei achar referencias sobre ele no manual mas não achei. Errei feio.hehehe funciona, mas é $_SERVER['PHP_SELF'] Quote Link to comment Share on other sites More sharing options...
0 taudujas Posted July 30, 2004 Author Report Share Posted July 30, 2004 Hum, obrigado Carlos, é que no imasters eu vi este exemplo já faz um tempinho e ai hoje lembrei e fui tentar fazer, mas como uso register_globals off acho que por isso não funcionou, mas vou usar o nome da pagina mesmo como o fabyo postou.obrigado. Quote Link to comment Share on other sites More sharing options...
0 Fabyo Posted July 30, 2004 Report Share Posted July 30, 2004 Rog:oi fabyoeu não sei porque tudo mundo tem mania de redefinir variaveis aqui já existemE eu não sei porque você tem mania de ficar só criticando ate hj não vi você ajudar ninguém em nada, só fala, fala, mas na hora do vamo ver se correeu faço meus script muito bem elaborados, mas aqui no forum eu apenas corrigo os script, sem auterar o que a pessoa já fez,se quer ajudar que ajude, ou então post o seu jeito melhor de fazercada um analisa e escolhe o que achar melhore você goste de deixar seus script bem pequenos mysql_query("insert into usuarios VALUE ('$nome', '$email', '$login', '$senha')");assim tabom professor rog ? Quote Link to comment Share on other sites More sharing options...
0 taudujas Posted July 30, 2004 Author Report Share Posted July 30, 2004 Eu corrigi aqui, mas ainda não esta cadastrando o que tem de errado? ele não retorna nada de erro.o codigo que estou usando é esse:<form name="form1" method="post" action="cadastro.php?entrar=s"> <table width="68%" border="0" align="center"> <tr> <td width="32%">Nome:</td> <td width="68%"><input name="nome" type="text" id="nome" maxlength="80"></td> </tr> <tr> <td>Email:</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td>Login:</td> <td><input name="login" type="text" id="login"></td> </tr> <tr> <td>Senha:</td> <td><input name="senha" type="text" id="senha"></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Cadastrar"></td> </tr> </table></form><?include "config.php";if(isset($_GET["entrar"])){$entrar = $_GET["entrar"];if($entrar == 's') {foreach ($_POST as $campo => $valor) { $$campo = strip_tags($valor); }$sql = "insert into usuarios(nome, email, login, senha)VALUES('$nome', '$email', '$login', '$senha')";$exec = mysql_query($sql);}}?> Quote Link to comment Share on other sites More sharing options...
0 Fabyo Posted July 30, 2004 Report Share Posted July 30, 2004 Aqui eu testei e esta normal, verifica seu banco se esta com os nomes corretos Quote Link to comment Share on other sites More sharing options...
0 rog Posted July 30, 2004 Report Share Posted July 30, 2004 oi fabyoisso e meio gozado :dê uma olhada nos desaios e percebi que la tambem o tamanho do codigo era muito importante para os que julgam eleseu não considero os usuarios desse forum php como usuarios de produçao, quase todos são iniciantesassim no meu ponto de vista e melhor :- explicar como achar um bug do que tirar ele por eles- tambem apontar algo que não da bug mas que esta errado- dar alerta de segurança- apontar um erro de logica - uma funçao mal utilizadaetc################e tem outra, a internet virou uma peneira onde se pode entrar na maioria dos sites pro sem ter autorisaçao a causa :eu vejo iniciantes pegando aplicaçao de empresa para fazer (não so no php) sem ter um decimo das competencias que deveria ser requisitadas nesse caso eu não ajudo mesmo----------------------------------------------------@taudujasps se você colocar as mesnsagems de error, você poderas tirar bug sozinho Quote Link to comment Share on other sites More sharing options...
0 Fabyo Posted July 30, 2004 Report Share Posted July 30, 2004 Eu não entendi a metade do que você disse, mas se você gosta de analisar os errosporque você não viu que ele não estava pegando a variavel $entrar ?if($entrar == 's') você não é o cara?ou você também usa os register_globals em on ? então porque você não viu o erro dele antes e só critou quem queria ajudar ele Quote Link to comment Share on other sites More sharing options...
0 taudujas Posted July 30, 2004 Author Report Share Posted July 30, 2004 Rog, posta os negocios certo cara, você diz do esquema de erros, mas cade as mensagens de erro?? voce não posto nada.. poxa assim não da.. vlw.Olha o meu banco:CREATE TABLE `usuarios` ( `id` int(10) unsigned NOT NULL auto_increment, `nome` varchar(80) NOT NULL default '', `email` varchar(60) NOT NULL default '', `login` varchar(8) NOT NULL default '', `senha` varchar(8) NOT NULL default '', PRIMARY KEY (`id`)) TYPE=MyISAM AUTO_INCREMENT=1 ;esta tudo certo. Quote Link to comment Share on other sites More sharing options...
0 Fabyo Posted July 30, 2004 Report Share Posted July 30, 2004 tenta assim la tulio:$sql = "insert into usuarios VALUES('','$nome', '$email', '$login', '$senha')";$exec = mysql_query($sql); Quote Link to comment Share on other sites More sharing options...
0 rog Posted July 30, 2004 Report Share Posted July 30, 2004 @fabyoeu acho que meu premeiro post foideve ser if($entrar == 's') dê um echo de $entrar que deve ser null e indefinida@taudujaserror_reporting(E_ALL);no inicio do script Quote Link to comment Share on other sites More sharing options...
0 taudujas Posted July 30, 2004 Author Report Share Posted July 30, 2004 Beleza Fabyo, obrigado, mas tambem não deu certo. eu acho que não tem nada errado, mas o que sera que pode estar havendo?olhem o codigo:<form name="form1" method="post" action="cadastro.php?entrar=s"> <table width="68%" border="0" align="center"> <tr> <td width="32%">Nome:</td> <td width="68%"><input name="nome" type="text" id="nome" maxlength="80"></td> </tr> <tr> <td>Email:</td> <td><input name="email" type="text" id="email" maxlength="60"></td> </tr> <tr> <td>Login:</td> <td><input name="login" type="text" id="login" maxlength="8"></td> </tr> <tr> <td>Senha:</td> <td><input name="senha" type="text" id="senha" maxlength="8"></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Cadastrar"></td> </tr> </table></form><?include "config.php";if(isset($_GET["entrar"])){$entrar = $_GET["entrar"];if($entrar == 's') {foreach ($_POST as $campo => $valor) { $$campo = strip_tags($valor); }$sql = "insert into usuarios VALUES('','$nome', '$email', '$login', '$senha')";$exec = mysql_query($sql);}}?>o banco:CREATE TABLE `usuarios` ( `id` int(10) unsigned NOT NULL auto_increment, `nome` varchar(80) NOT NULL default '', `email` varchar(60) NOT NULL default '', `login` varchar(8) NOT NULL default '', `senha` varchar(8) NOT NULL default '', PRIMARY KEY (`id`)) TYPE=MyISAM AUTO_INCREMENT=1 ; Quote Link to comment Share on other sites More sharing options...
0 Fabyo Posted July 30, 2004 Report Share Posted July 30, 2004 rog :deve serif($entrar == 's')dê um echo de $entrar que deve ser null e indefinida@taudujaserror_reporting(E_ALL);no inicio do script cara se prefere esconder os erros em vez de tentar arrumar?eu não escondo erros nenhum , e meus script nunca tem errosagora se fica setando pra não aparecer erros que feio Quote Link to comment Share on other sites More sharing options...
0 taudujas Posted July 30, 2004 Author Report Share Posted July 30, 2004 não mostrou nenhum erro com esse negocio ai rog, ai eu tirei ele. Mesmo assim não deu nada certo. Quote Link to comment Share on other sites More sharing options...
0 will Posted July 30, 2004 Report Share Posted July 30, 2004 Ae tulio .... <?php //arquido de conecxão require_once('m.php'); function willgueto($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_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO usuarios (nome, email, login, senha) VALUES (%s, %s, %s, %s)", willgueto($_POST['nome'], "text"), willgueto($_POST['email'], "text"), willgueto($_POST['login'], "text"), willgueto($_POST['senha'], "text")); mysql_select_db($database_m, $m); $Result1 = mysql_query($insertSQL, $m) or die(mysql_error()); // o endereço do ok $insertGoTo = "ok.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } mysql_select_db($database_m, $m); $query_Recordset1 = "SELECT * FROM usuarios"; $Recordset1 = mysql_query($query_Recordset1, $m) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <form name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <table width="68%" border="0" align="center"> <tr> <td width="32%">Nome:</td> <td width="68%"><input name="nome" type="text" id="nome" maxlength="80"></td> </tr> <tr> <td>Email:</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td>Login:</td> <td><input name="login" type="text" id="login"></td> </tr> <tr> <td>Senha:</td> <td><input name="senha" type="text" id="senha"></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Cadastrar"></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1"> </form> <?php mysql_free_result($Recordset1); ?> eu sou o will Quote Link to comment Share on other sites More sharing options...
0 taudujas Posted July 30, 2004 Author Report Share Posted July 30, 2004 Assim funcionou Will, thank´s Quote Link to comment Share on other sites More sharing options...
0 Guest Guest Posted July 30, 2004 Report Share Posted July 30, 2004 Nossa que codigo enorme usou muitas funções a toa da pra deixar tudo em poucas linhassó aprender mais e limpar o codigo Quote Link to comment Share on other sites More sharing options...
0 Guest Guest Posted July 30, 2004 Report Share Posted July 30, 2004 Esse tadujas é burro pra cacete da te reiva Quote Link to comment Share on other sites More sharing options...
0 taudujas Posted July 30, 2004 Author Report Share Posted July 30, 2004 Esse tadujas é burro pra cacete da te reiva Pior é voce que nem sabe escrever.. Quote Link to comment Share on other sites More sharing options...
0 Guest Guest Posted July 30, 2004 Report Share Posted July 30, 2004 $tajuda = strrev('etecac arp orrub')print($tajuda); Quote Link to comment Share on other sites More sharing options...
0 taudujas Posted July 30, 2004 Author Report Share Posted July 30, 2004 Se não é o bom?? cade o ; ??coloca ai o ; e veja o resultado. Quote Link to comment Share on other sites More sharing options...
Question
taudujas
Pessoal, estou fazendo um cadastro assim:
o que tem errado??
Link to comment
Share on other sites
28 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.