Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Tatiane.Design

Painel Administrativo com PHP 5

Recommended Posts

Oiiii meninos estou desenvolvendo um pequeno site com a linguagem php

que estou adorando aprender mais é muito complicado, rsrsrs

 

na minha pagina quemsomos.php (da pasta adm) criei o formulario para enviar o texto

para atualizar minha pagina do site da seguinte forma abaixo

 

Essa é minha pagina quemsomos.php na minha pasta adm

 

<?php
include "verifica.php";
?>



<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
include "config.php";
?>

<style type="text/css">
<!--
#geral_clean { width:950px; height:600px; margin-left: auto;
margin-right: auto; border:0px solid #900}
#texto_topo { font:Verdana, Geneva, sans-serif; font-size:22px; color:#666;
width:910px; height:60px; border:0px solid #00F; margin-left: auto;
margin-right: auto; background-position:top}

-->
<style type="text/css">
<!--
#geral_somos { width:950px; height:600px; margin-left: auto;
margin-right: auto; border:0px solid #900}
#texto_topo { font:Verdana, Geneva, sans-serif; font-size:20px; color:#666;
width:910px; height:60px; border:0px solid #00F; margin-left: auto;
margin-right: auto; background-position:top}

-->
</style>
<body>
<div id="geral_somos">

<div id="texto_topo"><font face="Trebuchet MS, Arial, Helvetica, sans-serif">Quem Somos</font></div><!--texto_topo-->

<?php
$sql = mysql_query("SELECT * FROM quemsomos where id = '1'");
while($linha = mysql_fetch_array($sql)){
$texto = $linha['texto'];
}

?>

<form id="form1" name="form1" method="post" action="funcao_quemsomos.php">
 <table width="200" border="0" cellpadding="3" cellspacing="3">
   <tr>
     <td width="59"><strong> Texto:</strong></td>
     <td width="120"><label>

      <textarea name="texto" id="texto" cols="50" rows="10"><?php echo $texto ?></textarea>
   </label></td>
   </tr>
   <tr>
     <td> </td>
     <td><input type="submit" name="button" id="button" value="enviar" /></td>
   </tr>
   <tr>
     <td> </td>

   </tr>
   <tr>
     <td> </td>
    <td><input type="submit" name="button" id="button" value="Enviar" /></td>
   </tr>
 </table>
</form>
</div><!--geral_somos-->
</body>
</html>

 

e essa é minha pagina funcao_quemsomos.php na pasta adm

 

<?php
include "config.php";

$texto = $_POST['texto'];

$sql = mysql_query("UPDATE quemsomos SET texto='texto' where id = '1'");
header("Location: index.php?pg=quemsomos");


?>

 

So que não deu certo quando eu tento atualizar pelo formulario da

minha pagina quemsomos.php (da pasta adm) não atualiza nada

nem no banco de dados atualiza e ainda aparece um monte de codigo

no formulario esses abaixo:

 

<br />
<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined variable: texto in C:\wamp\www\studio3d\adm\quemsomos.php on line <i>55</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0021</td><td bgcolor='#eeeeec' align='right'>365224</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='C:\wamp\www\studio3d\adm\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0048</td><td bgcolor='#eeeeec' align='right'>387840</td><td bgcolor='#eeeeec'>include( <font color='#00bb00'>'C:\wamp\www\studio3d\adm\paginas.php'</font> )</td><td title='C:\wamp\www\studio3d\adm\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>5</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>3</td><td bgcolor='#eeeeec' align='center'>0.0060</td><td bgcolor='#eeeeec' align='right'>394552</td><td bgcolor='#eeeeec'>include( <font color='#00bb00'>'C:\wamp\www\studio3d\adm\quemsomos.php'</font> )</td><td title='C:\wamp\www\studio3d\adm\paginas.php' bgcolor='#eeeeec'>..\paginas.php<b>:</b>71</td></tr>
</table></font>

 

Alguem pode me orientar :( :(

Compartilhar este post


Link para o post
Compartilhar em outros sites

O erro informa que a variável $texto não está definida.

 

$sql = mysql_query("SELECT * FROM quemsomos where id = '1'");
while ($linha = mysql_fetch_array($sql)) {
$texto = $linha['texto'];
}

 

Você já verificou no banco de dados se existe este registro com ID 1 na tabela quemsomos?

 

Como você irá retornar apenas um único registro não há a necessidade de loop. Troque o código acima pelo abaixo:

 

$sql = 'SELECT texto FROM quemsomos WHERE id = 1';
$query = mysql_query($sql) or die(mysql_error());
$texto = mysql_result($query, 0);

Compartilhar este post


Link para o post
Compartilhar em outros sites

Não deu certo Léo

 

Conseguir da mas um passo agora pelo menos aparece o texto do banco de dados no formulario, mas agora quando eu escreve algum texto e tento enviar o texto some e ainda apaga do banco de dados

 

Alguem tem alguma sugestão

 

vou postar o codigo com ele esta agora

 

pagina funcao_quemsomos.php

 

<?php
include "config.php";

$texto = $_POST['texto'];

$sql = mysql_query("UPDATE quemsomos SET texto='texto' where id = '1'");
header("Location: index.php?pg=quemsomos");


?>

 

a pagina quemsomos.php

 

<?php
include "verifica.php";
?>



<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
include "config.php";
?>

<style type="text/css">
<!--
#geral_clean { width:950px; height:600px; margin-left: auto;
margin-right: auto; border:0px solid #900}
#texto_topo { font:Verdana, Geneva, sans-serif; font-size:22px; color:#666;
width:910px; height:60px; border:0px solid #00F; margin-left: auto;
margin-right: auto; background-position:top}

-->
<style type="text/css">
<!--
#geral_somos { width:950px; height:600px; margin-left: auto;
margin-right: auto; border:0px solid #900}
#texto_topo { font:Verdana, Geneva, sans-serif; font-size:20px; color:#666;
width:910px; height:60px; border:0px solid #00F; margin-left: auto;
margin-right: auto; background-position:top}

-->
</style>
<body>
<div id="geral_somos">

<div id="texto_topo"><font face="Trebuchet MS, Arial, Helvetica, sans-serif">Quem Somos</font></div><!--texto_topo-->
<?php
$sql = mysql_query("SELECT * FROM quemsomos where id = '1'");
while ($linha = mysql_fetch_array($sql)) {
       $texto = $linha['texto'];
}
?>
<form id="form1" name="form1" method="post" action="funcao_quemsomos.php">
 <table width="200" border="0" cellspacing="3" cellpadding="0">
   <tr>
     <td width="46">Texto:</td>
     <td width="145"><label for="texto"></label>
       <textarea name="texto" id="texto" cols="45" rows="5"><?php echo $texto ?></textarea></td>
   </tr>
   <tr>
     <td> </td>
     <td><input type="submit" name="button" id="button" value="Enviar" /></td>
   </tr>
 </table>
</form>
</div><!--geral_somos-->
</body>
</html>

 

Alguem pode me dar uma dica de como resolver

Compartilhar este post


Link para o post
Compartilhar em outros sites

<?php
include "config.php";

$texto = $_POST['texto'];

$sql = mysql_query("UPDATE quemsomos SET texto='texto' where id = '1'");
header("Location: index.php?pg=quemsomos");


?>

 

tente fazer assim

<?php
include "config.php";

$texto = $_POST['texto'];

mysql_query("UPDATE quemsomos SET texto='$texto' where id = '1'");
header("Location: index.php?pg=quemsomos");


?>

 

note que eu mandei ele executar o mysql_query e não mandei o conteudo para dentro da $sql e tambem passai a variavel $texto para o sql.

 

teste e veja se dá certo.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ricardo deu certo, pagina quem somos da adm esta enviando o texto

tanto para o banco de dados e para pagina principal.

so que embaixo na pagina quem somos do site, proximo do rodape esta repetindo

o texto em fonte menor igual do rodape, e na pagina da adm aparece esse erro:

 

Notice: A session had already been started - ignoring session_start() in C:\wamp\www\studio3d\adm\verifica.php on line 2

Call Stack

# Time Memory Function Location

1 0.0028 365224 {main}( ) ..\index.php:0

2 0.0283 378232 include( 'C:\wamp\www\studio3d\adm\rodape.php' ) ..\index.php:6

3 0.0328 387416 include( 'C:\wamp\www\studio3d\adm\verifica.php' ) ..\rodape.php:2

4 0.0328 387448 session_start ( ) ..\verifica.php:2

 

alguem pode me dar uma dica.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Você ta importando duas sessions iguais pra mesma pagina =) procure uma repetição de session_start na mesma pagina ou um include com session, incluindo numa pagina que ja tem essa mesma session.

 

Olhe se o config.php tem alguma session

Compartilhar este post


Link para o post
Compartilhar em outros sites

pagina adm quemsomos.php

 

<?php
include "verifica.php";
?>



<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
#geral_somos #form1 table tr td {
font-weight: bold;
font-size: 16px;
font-family: Arial, Helvetica, sans-serif;
color: #666;
}
</style>
</head>
<?php
include "config.php";
?>

<style type="text/css">
<!--
#geral_clean { width:950px; height:600px; margin-left: auto;
margin-right: auto; border:0px solid #900}
#texto_topo { font:Verdana, Geneva, sans-serif; font-size:22px; color:#666;
width:910px; height:60px; border:0px solid #00F; margin-left: auto;
margin-right: auto; background-position:top}

-->
<style type="text/css">
<!--
#geral_somos { width:950px; height:600px; margin-left: auto;
margin-right: auto; border:0px solid #900}
#texto_topo { font:Verdana, Geneva, sans-serif; font-size:20px; color:#666;
width:910px; height:60px; border:0px solid #00F; margin-left: auto;
margin-right: auto; background-position:top}

-->
</style>
<body>
<div id="geral_somos">

<div id="texto_topo"><font face="Trebuchet MS, Arial, Helvetica, sans-serif">Quem Somos</font></div><!--texto_topo-->
<?php
$sql = mysql_query("SELECT * FROM quemsomos where id = '1'");
while ($linha = mysql_fetch_array($sql)) {
       $texto = $linha['texto'];
}
?>
<form id="form1" name="form1" method="post" action="funcao_quemsomos.php">
 <table width="200" border="0" cellspacing="3" cellpadding="0">
   <tr>
     <td width="46">Texto:</td>
     <td width="145"><label for="texto"></label>
       <textarea name="texto" id="texto" cols="90" rows="12"><?php echo $texto ?></textarea></td>
   </tr>
   <tr>
     <td> </td>
     <td><input type="submit" name="button" id="button" value="Enviar" /></td>
   </tr>
 </table>
</form>
</div><!--geral_somos-->
</body>
</html>

 

 

pagina quemsomos.php

 

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #333;
}
</style>
</head>

<?php
include "config.php";
?>

<style type="text/css">
<!--
#geral_clean { width:950px; height:600px; margin-left: auto;
margin-right: auto; border:0px solid #900}
#texto_topo { font:Verdana, Geneva, sans-serif; font-size:22px; color:#666;
width:910px; height:60px; border:0px solid #00F; margin-left: auto;
margin-right: auto; background-position:top}
#divquem_somos { font:Verdana, Geneva, sans-serif; font-size:20px; color:#666;
width:910px; height:500px; border:0px solid #00F; margin-left: auto;
margin-right: auto; background-position:top}

-->
<style type="text/css">
<!--
#geral_somos { width:950px; height:600px; margin-left: auto;
margin-right: auto; border:0px solid #900}
#texto_topo { font:Verdana, Geneva, sans-serif; font-size:20px; color:#666;
width:910px; height:60px; border:0px solid #00F; margin-left: auto;
margin-right: auto; background-position:top}
#divquem_somos { font:Verdana, Geneva, sans-serif; font-size:14px; color:#666;
width:910px; height:500px; border:0px solid #00F; margin-left: auto;
margin-right: auto; background-position:top}
-->
</style>
<body>
<div id="geral_somos">

<div id="texto_topo"><font face="Trebuchet MS, Arial, Helvetica, sans-serif">Quem Somos</font></div><!--texto_topo-->
<div id="divquem_somos">
<?php $sql = 'SELECT texto FROM quemsomos WHERE id = 1';
$query = mysql_query($sql) or die(mysql_error());
$texto = mysql_result($query, 0);
?>
<?php echo $texto ?>
</div>


</div><!--geral_somos-->
</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ta vou postar a pagina

 

Não ta mas repitindo o texto ta tudo certinho agora

a pagina quemsomos.php da adm ta enviando o texto para o banco de dados

e para site

 

so que na pagina quemsomos.php da adm ainda fica aparecendo essa

mensagem de erro: (coisa chata como tiro ela)

 

Notice: A session had already been started - ignoring session_start() in C:\wamp\www\studio3d\adm\verifica.php on line 2

Call Stack

# Time Memory Function Location

1 0.0028 365224 {main}( ) ..\index.php:0

2 0.0283 378232 include( 'C:\wamp\www\studio3d\adm\rodape.php' ) ..\index.php:6

3 0.0328 387416 include( 'C:\wamp\www\studio3d\adm\verifica.php' ) ..\rodape.php:2

4 0.0328 387448 session_start ( ) ..\verifica.php:2

 

 

tentei tirar session_start(); da linha so que depois não entro no adm fica pedindo senha e usuario

 

A pagina verifica.php

 

<?php
session_start();

include "config.php";

if(isset($_SESSION["login_usuario"]) AND isset ($_SESSION['senha_usuario'])) {


$login_usuario = $_SESSION["login_usuario"];
$senha_usuario = $_SESSION["senha_usuario"];

$sql = mysql_query("SELECT * FROM adm WHERE login = '$login_usuario'");
$cont = mysql_num_rows($sql);
while($linha = mysql_fetch_array($sql)) {
$senha_db = $linha['senha'];
}

if($cont == 0) {

unset($_SESSION["login_usuario"]);
unset($_SESSION["senha_usuario"]);

echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=login.php'>
<script type=\"text/javascript\">
alert(\"O Nome de usuario nao corresponde.\");
</script>
";
}
if($senha_db != $senha_usuario) {

	unset($_SESSION["login_usuario"]);
    unset($_SESSION["senha_usuario"]);

		echo "
		<META HTTP-EQUIV=REFRESH CONTENT= '0; URL=login.php'>
		<script type=\"text/javascript\">
		alert(\"A senha nao corresponde.\");
		</script>";

}
}else{

echo "
		<META HTTP-EQUIV=REFRESH CONTENT= '0; URL=login.php'>
		<script type=\"text/javascript\">
		alert(\"O usuario e a senha nao correspondem.\");
		</script>";
} 

		?>

 

 

Pagina config.php

 

<?php

$db = mysql_connect("localhost","root","");
$dados = mysql_select_db("studio3d",$db);

?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Acho que ja sei o problema o verifica.php ja esta fazendo a include da config.php retire o include da config.php que tem no admquemsomos.php

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.