Ir para conteúdo
Fórum Script Brasil

marcio_andrade92

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre marcio_andrade92

marcio_andrade92's Achievements

0

Reputação

  1. boa tarde sou novo com este tipo de conteúdo tanto é que nem sei formular uma pergunta direito, mas vamos la. estou fazendo um código de cadastro através do Dreamweaver. quase tudo funciona perfeitamente exceto que quando coloco o comando para impedir cadastro duplo ele me da a seguinte mensagem: Notice: Undefined index: nome_papel in C:\xampp\htdocs\sitegrafica\cadastrar_papel.php on line 38 já li muitos tutoriais mas não consegui entender os procedimentos que devo tomar. estou postando parte do código se alguém puder me ajudar a entender o que fazer fico muito agradecido já que não basta apenas funcionar tenho que entender e aprender para não mais errar. segue código: <?php require_once('Connections/conecta_grafica.php'); ?> <?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; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } $sqlduplo = mysql_query("SELECT * FROM papel WHERE nome_papel='".$_POST['nome_papel']."'"); // aqui o motivo do erro onde "papel" é a tabela no banco e "nome_papel" e o campo onde será armazenado o nome do papel e que esta sendo testado. if(mysql_num_rows($sqlduplo)>=1){ echo "<meta http-equiv='refresh' content='0; URL=administrador_logado.php?cadastrar_papel'> <script type=\"text/javascript\"> alert(\"ESTE CADASTRO JÁ EXISTE EM NOSSO BANCO DE DADOS\"); </script> "; return die; }else { if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form_cadastrar_e_editar")) { $insertSQL = sprintf("INSERT INTO papel (nome_papel, carac_papel, ideal_para) VALUES (%s, %s, %s)", GetSQLValueString($_POST['nome_papel'], "text"), GetSQLValueString($_POST['carac_papel'], "text"), GetSQLValueString($_POST['ideal_para'], "text")); mysql_select_db($database_conecta_grafica, $conecta_grafica); $Result1 = mysql_query($insertSQL, $conecta_grafica) or die(mysql_error()); } } mysql_select_db($database_conecta_grafica, $conecta_grafica); $query_cadastrar_papel = "SELECT * FROM papel"; $cadastrar_papel = mysql_query($query_cadastrar_papel, $conecta_grafica) or die(mysql_error()); $row_cadastrar_papel = mysql_fetch_assoc($cadastrar_papel); $totalRows_cadastrar_papel = mysql_num_rows($cadastrar_papel); ?>
×
×
  • Criar Novo...