Estou fazendo site em PHP que acessa banco de dados. Ele acessa por uma página (programacao_edit.php) onde mostra as informações da tabela e permite alterar algum campo ao clikar num link; ele vai para uma otra pagina (programacao_alt.php) que carrega as informações em textfields para o usuario pooder editar.
Mas o que está acontecendo é estranho. Ao clikar no Link, ele abri a pagina programacao_alt.php toda em branco e sem codigo fonte nenhum :blink:
Estou empacado nesta parte do site. Abaixo segue os codigos das paginas:
Pergunta
Lukaumfera
Eae galera do SB!!
Estou fazendo site em PHP que acessa banco de dados. Ele acessa por uma página (programacao_edit.php) onde mostra as informações da tabela e permite alterar algum campo ao clikar num link; ele vai para uma otra pagina (programacao_alt.php) que carrega as informações em textfields para o usuario pooder editar.
Mas o que está acontecendo é estranho. Ao clikar no Link, ele abri a pagina programacao_alt.php toda em branco e sem codigo fonte nenhum :blink:
Estou empacado nesta parte do site. Abaixo segue os codigos das paginas:
programacao_edit.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>Editar Programação</title> <style> body { font-family:Arial, Helvetica, sans-serif; font-size:12px; } </style> </head> <script language="javascript"> <!-- function aparecer(id) { var mostrar = document.getElementById(id); if (mostrar.style.display == ""){ mostrar.style.display = "none"; }else{ mostrar.style.display = ""; } } --> </script> <!--INSERÇÃO--> <? include "config.php"; if ($_GET['btn'] == "gravar"){ $data = $_POST["data"]; $local = $_POST["local"]; $gravar_dados = mysql_query ("INSERT INTO programacao (data, local) VALUES ('$data','$local')",$db); if ($gravar_dados == 1) { print" <META HTTP-EQUIV=REFRESH CONTENT='0 URL=programacao_edit.php'> <script type=\"text/javascript\"> alert(\"Programação atualizada com sucesso.\"); </script> "; } } ?> <body> <a href="#" onclick="aparecer('form'); return false;">INSERIR PROGRAMAÇÃO</a></p> <div id="form" style="display:none"> <form name="form1" id="form1" method="post" action="?btn=gravar"> <table width="211" border="0" cellspacing="2" cellpadding="2"> <tr> <td width="44">Data</td> <td width="153"><label> <input type="text" name="data" id="data" maxlength="10" /> </label></td> </tr> <tr> <td>Local</td> <td><label> <input name="local" type="text" id="local" maxlength="100" width="300"/> </label></td> </tr> </table> <p> <label> <input type="submit" name="button" id="button" value="Gravar" width="10" height="10"/> </label> </p> </form> </div> <table width="500" border="0" cellspacing="3" cellpadding="0"> <tr align="center" bgcolor="#CCCCCC"> <td width="20%">Data</td> <td width="50%">Local</td> <td width="10%">Alterar</td> <td width="10%">Remover</td> </tr> <? include "config.php"; $mostrar_prog = mysql_query ("SELECT id, data, local FROM programacao ORDER BY data ASC"); while ($linha = mysql_fetch_array ($mostrar_prog)) { ?> <tr align="center"> <td><?=$linha['data'];?></td> <td><?=$linha['local'];?></td> <td><a href="programacao_alt.php?id=<?=$linha['id'];?>"><img src="alterar.jpg" border="0" width="16" height="16"/></a></td> <td><img src="excluir.gif" border="0" width="16" height="16"/></td> </tr> <? } ?> </table><br /> <br /> </body> </html>programacao_alt.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>Alterar Programação</title> <style> body { font-family:Arial, Helvetica, sans-serif; font-size:12px; } </style> </head> <body> aaaaaaa <? include "config.php"; $id = $_GET['id']; $carregar = mysql_query ("SELECT * FROM programacao WHERE id = '$id'",$db;); while ($linha = mysql_fetch_array ($carregar)) { $data = $linha["data"]; $local = $linha["local"]; } ?> ALTERAR PROGRAMAÇÃO<br /> <form name="form1" id="form1" method="post" action="?btn=alterar&id=<? echo "$id"; ?>"> <table width="211" border="0" cellspacing="2" cellpadding="2"> <tr> <td width="44">Data</td> <td width="153"><label> <input type="text" name="data" id="data" value="<? echo "$data"; ?>" maxlength="10" /> </label></td> </tr> <tr> <td>Local</td> <td><label> <input name="local" type="text" id="local" value="<? echo "$local"; ?>" maxlength="100" width="300"/> </label></td> </tr> </table> <p> <label> <input type="submit" name="button" id="button" value="Alterar" /> </label> </p> </form> <? if ($_GET['btn'] == "alterar"){ $id = $_GET["id"]; $data = $_POST["data"]; $local = $_POST["local"]; $atualizar_prog = mysql_query ("UPDATE programacao SET data='$data', local='$local' WHERE id='$id'"); if ($atualizar_prog == 1) { print" <META HTTP-EQUIV=REFRESH CONTENT='0 URL=programacao_edit.php'> <script type=\"text/javascript\"> alert(\"Programação alterada com sucesso.\"); </script> "; } } ?> </body> </html>Onde foi que eu errei! :wacko:
Editado por LukaumferaLink para o comentário
Compartilhar em outros sites
4 respostass a esta questão
Posts Recomendados
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.