Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. <?php
  2. //starta a sess�o
  3. $id_prod = $_POST['editId'];
  4. session_start();
  5. ob_start();
  6. //resgata os valores das session em variaveis
  7. $id_users = isset($_SESSION['id_users']) ? $_SESSION['id_users']: "";
  8. $nome_user = isset($_SESSION['nome']) ? $_SESSION['nome']: "";
  9. $email_users = isset($_SESSION['email']) ? $_SESSION['email']: "";
  10. $pass_users = isset($_SESSION['pass']) ? $_SESSION['pass']: "";
  11. $logado = isset($_SESSION['logado']) ? $_SESSION['logado']: "N";
  12. //varificamos e a var logado cont�m o valos (S) OU (N), se conter N quer dizer que a pessoa n�o fez o login corretamente
  13. //que no caso satisfar� nossa condi��o no if e a pessoa sera redirecionada para a tela de login novamente
  14. if ($logado == "N" && $id_users == ""){
  15. echo "<script type='text/javascript'>
  16. location.href='index.php'
  17. </script>";
  18. exit();
  19. }
  20. ?>
  21. <?php
  22. include ("conexaobd.php");
  23.  
  24. $consulta2 = mysqli_query($con,"SELECT p.nome,p.descricao,p.preco,c.nome,p.status FROM produto p, categoria_produto c WHERE p.idcategoria = c.idcat AND p.id =" . $id_prod
  25. );
  26.  
  27. //Fazendo o looping para exibição de todos registros que contiverem em nomedatabela
  28. while ($dados2 = mysqli_fetch_array($consulta2)) {
  29. $nomep = $dados2[0];
  30. $descp = $dados2[1];
  31. $precop = $dados2[2];
  32. $catp = $dados2[3];
  33. $statusp = $dados2[4];
  34. }
  35. ?>
  36. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  37. <html xmlns="http://www.w3.org/1999/xhtml">
  38. <head>
  39. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  40. <title>Cadastro Produtos</title>
  41. </head>
  42.  
  43. <body>
  44.  
  45. <form name="form1" method="post" action="altera-cadastro.php">
  46. <table width="400" border="1">
  47. <tr>
  48. <td colspan="2" bgcolor="#999999"><blockquote>
  49. <p>ATUALIZAR CADASTRO DO PRODUTO </p>
  50. </blockquote></td>
  51. </tr>
  52. <tr>
  53. <td width="64">Nome:</td>
  54. <td width="400"><input name="nome" type="text" size="50" value = <?php echo($nomep)?> /> </td>
  55. </tr>
  56. <tr>
  57. <td height="167">Descrição:</td>
  58. <td> <textarea id="descricao" rows="10" name="descricao" cols="255" ><?php echo($descp)?></textarea> </td>
  59. </tr>
  60. <tr>
  61. <td>Categoria:</td>
  62. <td><select id="categoria" name="categoria">
  63. <?php
  64. include ("conexaobd.php");
  65.  
  66. $consulta = mysqli_query($con,"SELECT idcat, nome FROM categoria_produto where idestab = $id_prod ");
  67.  
  68. //Fazendo o looping para exibição de todos registros que contiverem em nomedatabela
  69. while ($dados = mysqli_fetch_array($consulta)) {
  70.  
  71. if($dados['nome'] == $catp) echo("<option selected = 'true' value='".$dados['idcat']."'>".$dados['nome']."</option>");
  72. else echo("<option value='".$dados['idcat']."'>".$dados['nome']."</option>");
  73.  
  74. }
  75.  
  76. ?></select></td>
  77.  
  78.  
  79. </tr>
  80. <tr>
  81. <td>Preço:</td>
  82. <td><input type=text name= "preco" size="10" value = <?php echo($precop)?> onkeyup="foo(this)" />
  83. <script>
  84.  
  85. function foo(obj){
  86.  
  87. if(obj.value != obj.value.replace(/[^0-9,.]/g,"")){
  88. // the if is removeable if you don't want a message.
  89.  
  90. obj.value = obj.value.replace(/[^0-9,.]/g,"");
  91. // strip all text and such.
  92. obj.focus();
  93. // ensure it keeps focus.
  94. alert("Por favor lembrar-se e apenas numeros.");
  95. // your message.
  96. };
  97. // remove this }; if your not having the if.
  98. };
  99. </script></td>
  100. </tr>
  101. <tr>
  102. <td>Status:</td>
  103. <td><select id="status" name="status">
  104. <?php
  105. {
  106. echo("<option value=0>Inativo</option>
  107. <option value=1>Ativo</option>");
  108. }
  109. ?></select></td>
  110. </tr>
  111. <tr>
  112. <td>&nbsp;</td>
  113. <td> <input type="submit" name="button" id="button" value="Alterar" />
  114. </td>
  115. </tr>
  116. </table>
  117. </form>
  118. </body>
  119. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement