Ir para conteúdo
Fórum Script Brasil
  • 0

Porque esse erro?


Mateus Conti

Pergunta

alguém pode me falar porque esta dadno esse errroo, porem no meu banco de dados existe a tabela " usu_id "

OBS: esse erro é na variavel, $id = $_GET ['usu_id']; Notice: Undefined index: usu_id in C:\xampp\........... on line 236
<?php 
    
$id = $_GET ['usu_id'];

$select = mysql_query("SELECT * FROM usuarios WHERE usu_id = '$id'");
    while($res_select = mysql_fetch_array($select)){
    
    $senha = $res_select['usu_senha'];
        
        
?>

<?php if(iseet($_POST['atualizar'])){
    
    $nova_senha = $_POST['usu_senha'];
    
    $update = mysql_query("UPDATE in usuarios SET usu_senha = '$nova_senha' WHERE usu_id = '$id'");
    
    if($update == ''){
    
        echo "Ocorreu um erro ao atualizar os dados!";
    }else{
        echo "Dados atualizados com sucesso!"; 
        
    }
    
}?>

    <td rowspan="2" align="center"><table width="49%" border="0">
<tr>
<td width="37%">Login</td>
<td width="63%"><form id="form1" name="form1" method="POST" >
<label>
<input name="login" type="text" id="login" />
</label>
</form></td>
</tr>
<tr>
<td>Senha Alterior</td>
<td><form id="form2" name="form2" method="post" action="">
<label>
<input name="senha_alterior" type="password" id="senha_alterior" />
</label>
</form></td>
</tr>
<tr>
<td>Nova Senha</td>
<td><form id="form3" name="form3" method="post" action="">
<label>
<input name="nova_senha" type="password" id="senha" value="<?php echo $senha; ?>"/>
</label>
</form></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><form id="form4" name="form4" method="post" action="">
<input type="submit" name="atualizar" id="atualizar" value="atualizar" />
</form></td>
</tr>
</table> &nbsp;</td>

Editado por Mateus Conti
Link para o comentário
Compartilhar em outros sites

11 respostass a esta questão

Posts Recomendados

  • 0
Passei Varias vezes por isso veja se resolve assim.

$id = isset($_GET['usu_id']);
a tabela de alterar agora some... deve ser o final onde eu tenho q colocar <?php } ?> mais se eu coloko ele no final da minha tabela ele some, e se eu coloko no começo ele não tem ação Aff meu que saco não vai.. vou postar todo o codigo dessa minha pagina mais só dei importancia ao campo tabela
<?php require_once('../Connections/mural.php'); ?>
<?php require_once('../Connections/nivel_acesso.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']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
  $insertSQL = sprintf("INSERT INTO mural (Mensagem) VALUES (%s)",
                       GetSQLValueString($_POST['Mensagem'], "text"));

  mysql_select_db($database_mural, $mural);
  $Result1 = mysql_query($insertSQL, $mural) or die(mysql_error());

  $insertGoTo = "Perfil.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

$colname_busca = "-1";
if (isset($_GET['busca'])) {
  $colname_busca = $_GET['busca'];
}
mysql_select_db($database_nivel_acesso, $nivel_acesso);
$query_busca = sprintf("SELECT usu_nome, usu_sobrenome, usu_pais, usu_estado, usu_cidade FROM usuarios WHERE usu_nome LIKE %s", GetSQLValueString("%" . $colname_busca . "%", "text"));
$busca = mysql_query($query_busca, $nivel_acesso) or die(mysql_error());
$row_busca = mysql_fetch_assoc($busca);
$totalRows_busca = mysql_num_rows($busca);
?>

<!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>
<style type="text/css">
    @import url(menu_style_2.css); 
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>
<link href="../Menu/menu_buscar.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#apDiv1 {
    position:absolute;
    left:35px;
    top:152px;
    width:151px;
    height:160px;
    z-index:201;
    background-color:#990000;
    text-align: center;
}
body,td,th {
    font-family: Verdana, Geneva, sans-serif;
}
.uiScrollableAreaGripper.hidden_elem .menu .applemenu .submenu {
    font-weight: normal;
}
body {
    margin-top: 0px;
}
#apDiv2 {
    position:absolute;
    left:766px;
    top:0px;
    width:308px;
    height:34px;
    z-index:201;
}
.uiScrollableAreaGripper.hidden_elem .menu table tr td #form2 h3 {
    font-size: 24px;
}
</style>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title></title>
<link rel="stylesheet" href="menu_style.css" type="text/css" />
</head>
<body>
<div class="uiScrollableAreaGripper hidden_elem">
  <div class="menu">
    <ul>
            <li><a href="Perfil.php" >Início</a></li>
            <li><a href="#" id="current">Configurações</a>
                <ul>
                    <li><a href="Alterar_dados.php">Alterar dados</a></li>
                    <li><a href="#">Teste 2</a></li>
                    <li><a href="#">Teste 3</a></li>
                    <li><a href="#">Teste 4</a></li>
               </ul>
          </li>
            <li><a href="/faq.php">Albuns</a>
                <ul>
                <li><a href="Fotos.php">Fotos</a></li>
                <li><a href="Videos.php">Videos</a></li>
                <li><a href="Armazenagem.php">Armanezagem</a></li>
                </ul>
          </li>
      <li><a href="/contact/contact.php">Contato</a></li>
      <?php      mysql_set_charset('utf8') ?>
      <li><form id="form1" name="form1" method="get" action="Resultado.php">
        <input name="busca" type="text" id="busca" onfocus="if (this.value == 'Buscar...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Buscar...';}" value="Buscar..." size="35" maxlength="30" x-webkit-speech />
      </form>
      </li>
      <li><a href="Resultado.php"><img src="../backgroup imagen/1335055473_search.png" alt="" name="busca" width="25" height="25" align="texttop" id="busca2" /></a></li>
      <table width="167" height="35" border="0" align="right">
            
        <tr> </tr>
      </table>
       
    </ul>
    

</ul>
<table width="100%" border="0">
  <tr>
    <td width="22%" align="left">&nbsp;</td>
    <td align="right"><script language="JavaScript">

<!--
function stopError() {
return true;
}

window.onerror = stopError;

// --></script><script>
/*Real time DHTML Clock By Paul Swonger AKA "PSYCO" written exclusively for use on the "HTMLGOODIES" website. Feel free to distribute freely (as long as credit is given).*/
function tick() {
var hours, minutes, seconds, ap;
var intHours, intMinutes, intSeconds;
var today;

today = new Date();




intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();

if (intHours == 0) {
hours = "12:";
ap = "Meia Noite";
} else if (intHours < 12) { 
hours = intHours+":";
ap = "A.M.";
} else if (intHours == 12) {
hours = "12:";
ap = "";
} else {
intHours = intHours - 12
hours = intHours + ":";
ap = "P.M.";
}

if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}

if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
} 

timeString = hours+minutes+seconds+ap;

Clock.innerHTML = timeString;

window.setTimeout("tick();", 100);
}

window.onload = tick;

      </script>
</td>
    <td><div id="Clock" align="right" style="font-family: Arial; font-size: 25; color=black"> </div></td>
  </tr>
  <tr>
    <td width="22%" rowspan="2" align="left"><div class="applemenu">
      <div class="silverheader"><a href="#">Games</a></div>
      <div class="submenu"> <a href="../Games/Jogo da Velha.php">Jogo da Velha</a></div>
      <div class="silverheader"><a href="#" >Teste 1</a></div>
      <div class="submenu"> Links podem ser colocados aki<br />
      </div>
      <div class="silverheader"><a href="#">Teste 2</a></div>
      <div class="submenu"> Links podem ser colocados aki<br />
      </div>
      <div class="silverheader"><a href="">Teste 3</a></div>
      <div class="submenu"> Links podem ser colocados aki<br />
      </div>
      <div class="silverheader"><a href="#">Teste 4</a></div>
      <div class="submenu"> Links podem ser colocados aki<br />
      </div>
    </div></td>
    <td rowspan="2" align="center">
------------------------------------------------------------------------------------------------CAMPO ALTERAÇÂO---------------------------------------------------------------------------------------
<?php 
    
$id = isset($_GET['usu_id']);

$select = mysql_query("SELECT * FROM usuarios WHERE usu_id = '$id'");
    while($res_select = mysql_fetch_array($select)){
    
    $senha = $res_select['usu_senha'];
        
        
?>

<?php if(iseet($_POST['atualizar'])){
    
    $nova_senha = $_POST['usu_senha'];
    
    $update = mysql_query("UPDATE in usuarios SET usu_senha = '$nova_senha' WHERE usu_id = '$id'");
    
    if($update == ''){
    
        echo "Ocorreu um erro ao atualizar os dados!";
    }else{
        echo "Dados atualizados com sucesso!"; 
        
    }
    
}?>
    <table width="49%" border="0">  
<tr>
<td width="37%">Login</td>
<td width="63%"><form id="form1" name="form1" method="POST" >
<label>
<input name="login" type="text" id="login" />
</label>
</form></td>
</tr>
<tr>
<td>Senha Alterior</td>
<td><form id="form2" name="form2" method="post" action="">
<label>
<input name="senha_alterior" type="password" id="senha_alterior" />
</label>
</form></td>
</tr>
<tr>
<td>Nova Senha</td>
<td><form id="form3" name="form3" method="post" action="">
<label>
<input name="nova_senha" type="password" id="senha" value="<?php echo $senha; ?>"/>
</label>
</form></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><form id="form4" name="form4" method="post" action="">
<input type="submit" name="atualizar" id="atualizar" value="atualizar" />
</form></td>
</tr>
</table><?php } ?></td>
--------------------------------------------------------------------------------------------FIM CAMPO ALTERAÇÂO--------------------------------------------------------------------------------------
    <td><table width="100" align="right"  cellpadding="0"  cellspacing="1" style="border:solid darkred 1px">
      <tr>
        <td height="18" bgcolor="#C8C8C8" style="color:#FFFFFF"><center>
          <b>Notícias</b>
        </center></td>
      </tr>
      <tr>
        <td><marquee id="scroller" scrollamount="3" direction="up" onmouseover="scroller.scrollAmount='1';scroller.style.cursor='default'" onmouseout="scroller.scrollAmount='3'" style="width:125px; height:200px">
          <center>
            <!-- Begin.noticia1 //-->
            <table border="0" cellpadding="0"  cellspacing="1" width="125">
              <tr>
                <td height="18" class="title"> :. Date <br />
                  <hr align="left" size="1" color="#FFFFFF" width="98%" />
                  Title </td>
              </tr>
              <tr>
                <td class="content" valign="top"> Text </td>
              </tr>
            </table>
            <!-- End.noticia1 //-->
            <table border="0" cellpadding="0"  cellspacing="1" width="125">
              <tr>
                <td height="18" class="title"> :. 7/2/2005 <br />
                  <hr size="1" color="#FFFFFF" width="98%" align="left" />
                  Simple System </td>
              </tr>
              <tr>
                <td class="content" valign="top"> Total adaptable system to the ASP/PHP </td>
              </tr>
            </table>
            <table border="0" cellpadding="0"  cellspacing="1" width="125">
              <tr>
                <td height="18" class="title">:. Copyright</td>
              </tr>
              <tr>
                <td class="content" valign="top"> Created by SidaoBatera <br /></td>
              </tr>
            </table>
          </center>
        </marquee></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="22%" align="left">&nbsp;</td>
    <td width="65%" height="8" align="center">&nbsp;</td>
    <td width="13%" rowspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td width="22%" align="left">&nbsp;</td>
    <td height="242" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td width="22%" align="left">&nbsp;</td>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>
<p>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  
  <script type="text/javascript" src="ddaccordion.js">

/***********************************************
* Accordion Content script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit [url=http://www.dynamicDrive.com]http://www.dynamicDrive.com[/url] for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

  </script><script type="text/javascript">


ddaccordion.init({
    headerclass: "silverheader", //Shared CSS class name of headers group
    contentclass: "submenu", //Shared CSS class name of contents group
    revealtype: "mouseover", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
    mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
    collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
    defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc] [] denotes no content
    onemustopen: true, //Specify whether at least one header should be open always (so never all headers closed)
    animatedefault: false, //Should contents open by default be animated into view?
    persiststate: true, //persist state of opened contents within browser session?
    toggleclass: ["", "selected"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
    togglehtml: ["", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
    animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
    oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
        //do nothing
    },
    onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
        //do nothing
    }
})


  </script>
  <style type="text/css">
      td
      {
      font-family:verdana;
      font-size:8pt;
      }

      td.title
      {
      padding:2px;
      padding-left:4px;
      background-color:#DDDDDD;
      font-weight:bold;
      }

      td.content
      {
      padding:2px;
      border-bottom:solid #DDDDDD 2px;
      padding-bottom:12px;
      }
    </style>
</p>

<p>
  <style type="text/css">

.applemenu{
margin: 5px 0;
padding: 0;
width: 170px; /*width of menu*/
border: 1px solid #9A9A9A;
}

.applemenu div.silverheader a{
background: black url(silvergradient.gif) repeat-x center left;
font: normal 12px Tahoma, "Lucida Grande", "Trebuchet MS", Helvetica, sans-serif;
color: white;
display: block;
position: relative; /*To help in the anchoring of the ".statusicon" icon image*/
width: auto;
padding: 5px 0;
padding-left: 8px;
text-decoration: none;
}


.applemenu div.silverheader a:visited, .applemenu div.silverheader a:active{
color: white;
}


.applemenu div.selected a, .applemenu div.silverheader a:hover{
background-image: url(silvergradientover.gif);
color: white;
}

.applemenu div.submenu{ /*DIV that contains each sub menu*/
background: white;
padding: 5px;
height: 300px; /*Height that applies to all sub menu DIVs. A good idea when headers are toggled via "mouseover" instead of "click"*/
}

  </style>
</p>
  </div>
</div>
</div>
</body>
</html>
<?php

mysql_free_result($busca);
?>

Editado por Mateus Conti
Link para o comentário
Compartilhar em outros sites

  • 0

no lugar coloca um controle para interromper caso não venha nada preenchido

if(isset($_GET['usu_id']))

{

$id = $_GET['usu_id'];

echo "Usuario não informado";

exit;

}

ai vai saber se passou algum parametro ou não , se não passou o script para e mostra a mensagem na tela

tem que ver o que chama este programa para ver se ele esta enviando o ?usu_id=$X

Link para o comentário
Compartilhar em outros sites

  • 0
no lugar coloca um controle para interromper caso não venha nada preenchido

if(isset($_GET['usu_id']))

{

$id = $_GET['usu_id'];

echo "Usuario não informado";

exit;

}

ai vai saber se passou algum parametro ou não , se não passou o script para e mostra a mensagem na tela

tem que ver o que chama este programa para ver se ele esta enviando o ?usu_id=$X

Agora ta dando que não tem o id

" Notice: Undefined variable: id in C:\xampp\htdocs\weylife\Perfil\Alterar_dados.php on line 244 "

Ah já arrumei era só pegar essa } e colocar no final assim

<?php 
    
if(isset($_GET['usu_id']))
{
$id = $_GET['usu_id'];
echo "Usuario não informado";
exit;


$select = mysql_query("SELECT * FROM usuarios WHERE usu_id = '$id'");
    while($res_select = mysql_fetch_array($select)){
    
    $senha = $res_select['usu_senha'];
        
}        
?>
Porem agora não ta aparecendo nada, nem a tabela... talves senha aquela parte que eu coloquei
<?php } ?>

jissa ve se tem essa parte ta colocada no lugar certo eu coloquei ela no fim da minha tabela

Link para o comentário
Compartilhar em outros sites

  • 0

não ta aparecendo nada porque o comando 'exit' entrou em ação.. ou seja, ele pára de carregar todo o resto da página

provavelmente isso está dando porque o $_GET esta errado...

quando você passa pra pagina de alteração, o que vem depois do endereço, é 'usu_id' mesmo?

ou é outro nome?? os nomes precisam ser iguais, senao vai dar erro mesmo

Link para o comentário
Compartilhar em outros sites

  • 0
não ta aparecendo nada porque o comando 'exit' entrou em ação.. ou seja, ele pára de carregar todo o resto da página

provavelmente isso está dando porque o $_GET esta errado...

quando você passa pra pagina de alteração, o que vem depois do endereço, é 'usu_id' mesmo?

ou é outro nome?? os nomes precisam ser iguais, senao vai dar erro mesmo

Sim é usu_id mesmo

tanto que só esta dando erro no $_GET...

Nos outros campos que preenchi " usu_id " não esta dando erro só ali meso... Estranho :S

Link para o comentário
Compartilhar em outros sites

  • 0

coloca na primeira linha do seu código...

if(!isset($_GET['usu_id']))
die("ERRO");
else
die("OK");

se aparecer ERRO significa que nem ta vindo esse "usu_id" então o problema ta antes e não nesta página...

ou seja, a página que chama essa ai passando essa variavel...

Link para o comentário
Compartilhar em outros sites

  • 0

vendo melhor o script ele esta confuso

no seu formulario tem quato forms que enviam para o mesmo lugar que altera, só que neste só recebe e altera a senha mas tb não vi esta variavel tem a "senha"

(ou seja qualquer coisa que passar dos 4 vai tentar alterar somente a senha os outros campos não vão fazer nada)

não existe nenhum ?usu_id=XX ou campo hiden que tenha recebido o conteudo de usu_id, então isto deve estar vindo de outro lugar de onde??

o que chama este(s) formulario(s) de alteração??

no final do form que tem a senha esta assim:

form 3 não tem o submit e no form4 que tem o submit não envia nada

<td>Nova Senha</td>

<td><form id="form3" name="form3" method="post" action="">

<label>

<input name="nova_senha" type="password" id="senha" value="<?php echo $senha; ?>"/>

</label>

</form></td>

</tr>

<tr>

<td>&nbsp;</td>

<td><form id="form4" name="form4" method="post" action="">

<input type="submit" name="atualizar" id="atualizar" value="atualizar" />

</form>

</td>

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...