Ir para conteúdo
Fórum Script Brasil

Makie

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre Makie

Makie's Achievements

0

Reputação

  1. Boa noite a todos Estou com problemas no formulário que montei. O formulário é bem simples, é somente para cadastro de usuários, mas não está funcionando. Criei dois arquivos (Cadastro.php) e (inserir.php) Eu utilizo o Xampp e o Dreamweaver CS5. A conexão com o banco de dados está funcionando normalmente. Segue abaixo a tabela e o código: `cad_usuario` -- CREATE TABLE IF NOT EXISTS `cad_usuario` ( `Id` int(2) NOT NULL AUTO_INCREMENT, `Nome` varchar(100) NOT NULL, `Email` varchar(30) NOT NULL, `Login` varchar(30) NOT NULL, `Senha` varchar(20) NOT NULL, `preferência` tinyint(1) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; //Cadastro.php <body> <form name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <p class="titulo"><b>Faca ja o seu cadastro!!</b></p> <br> <table> <tr> <td class="teste"><label><b>*Nome:</b></label></td> <td><input type="text" name="Nome" size="40" value="<?php echo $_SESSION['Nome']?>"></td> </tr> <tr> <td class="teste"><label><b>*Email:</b></label></td> <td><input type="text" name="Email1" size="40" value="<?php echo $_SESSION['Email1']?>"></td> </tr> <tr> <td class="teste"><label><b>*Confirme seu email:</b></label></td> <td><input type="text" name="Email2" size="40" value="<?php echo $_SESSION['Email2']?>"></td> </tr> <tr> <td class="teste"><label><b>*Senha:</b></label></td> <td><input type="password" name="Senha1" size="40" value="<?php echo $_SESSION['Senha1']?>"></td> </tr> <tr> <td class="teste"><label><b>*Confirme sua senha:</b></label></td> <td><input type="password" name="Senha2" size="40" value="<?php echo $_SESSION['Senha2']?>"></td> <td class="teste"><label>Minimo 6 caracteres</label></td> </tr> </table> <p><b> * Campos de preenchimento obrigatorio</b></p> <p><label><b> Selecione a sua preferência:</b></label></p> <input type="checkbox" name="interesses1"><b>Doce</b> <input type="checkbox" name="interesses2"><b>Salgado</b> <p><input type="submit" value="Enviar"> <input type="reset" value="Limpar" /></p> <input type="hidden" name="MM_insert" value="form1"> </form> </body> inserir.php <?php require_once('Connections/conexao.php'); ?> <?php error_reporting(0); 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 .= "?" . $_SERVER['QUERY_STRING']; } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO cad_usuario (Nome, Email, Senha, Doce, Salgado) VALUES (%s, %s, %s, %s, %s)", GetSQLValueString($_POST['Nome'], "text"), GetSQLValueString($_POST['Email'], "text"), GetSQLValueString($_POST['Senha1'], "text"), GetSQLValueString($_POST['Doce'], "text"), GetSQLValueString($_POST['Salgado'], "text")); $_SESSION["Nome"] = $_POST['Nome']; $_SESSION["Email"] = $_POST['Email']; $_SESSION["Senha1"] = $_POST['Senha1']; $_SESSION["Senha2"] = $_POST['Senha2']; if ($_POST['Nome'] == "") { echo "<center>Por favor preencha o campo <b>nome</b>.</center><br>"; include "Cadastro.php"; exit; } if ($_POST['Email'] == "") { echo "<center>Por favor preencha o campo <b>email</b>.</center><br>"; include "Cadastro.php"; exit; } if ($_SESSION["senha1"] != $_SESSION["senha2"]) { echo "<center>Os valores de <b>senha</b> não conferem, por favor, tente de novo. </center><br>"; include "Cadastro.php"; exit; } if ($_POST['senha1'] == "") { echo "<center>Por favor preencha o campo <b>senha</b>.</center><br>"; include "Cadastro.php"; exit; } if ($_POST['senha2'] == "") { echo "<center>Preencha o campo <b>senha</b> novamente.</center><br>"; include "Cadastro.php"; exit; } mysql_select_db($database_conexao, $conexao); $Result1 = mysql_query($insertSQL, $conexao) or die(mysql_error()); $insertGoTo = "finalizar.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } ?> Quando eu rodo o Cadastro.php ele apresenta o seguinte erro em todos os campos (Nome, email, confirmação de email, senha e confirme sua senha) <br /><b>Notice</b>: Undefined variable: _SESSION in <b>D:\Programas\xampp\htdocs\TCC\Cadastro.php</b> on line <b>31</b><br /> O que pode ser?? Grata
×
×
  • Criar Novo...