Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //starta a sess�o
- $id_prod = $_POST['editId'];
- session_start();
- ob_start();
- //resgata os valores das session em variaveis
- $id_users = isset($_SESSION['id_users']) ? $_SESSION['id_users']: "";
- $nome_user = isset($_SESSION['nome']) ? $_SESSION['nome']: "";
- $email_users = isset($_SESSION['email']) ? $_SESSION['email']: "";
- $pass_users = isset($_SESSION['pass']) ? $_SESSION['pass']: "";
- $logado = isset($_SESSION['logado']) ? $_SESSION['logado']: "N";
- //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
- //que no caso satisfar� nossa condi��o no if e a pessoa sera redirecionada para a tela de login novamente
- if ($logado == "N" && $id_users == ""){
- echo "<script type='text/javascript'>
- location.href='index.php'
- </script>";
- exit();
- }
- ?>
- <?php
- include ("conexaobd.php");
- $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
- );
- //Fazendo o looping para exibição de todos registros que contiverem em nomedatabela
- while ($dados2 = mysqli_fetch_array($consulta2)) {
- $nomep = $dados2[0];
- $descp = $dados2[1];
- $precop = $dados2[2];
- $catp = $dados2[3];
- $statusp = $dados2[4];
- }
- ?>
- <!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>Cadastro Produtos</title>
- </head>
- <body>
- <form name="form1" method="post" action="altera-cadastro.php">
- <table width="400" border="1">
- <tr>
- <td colspan="2" bgcolor="#999999"><blockquote>
- <p>ATUALIZAR CADASTRO DO PRODUTO </p>
- </blockquote></td>
- </tr>
- <tr>
- <td width="64">Nome:</td>
- <td width="400"><input name="nome" type="text" size="50" value = <?php echo($nomep)?> /> </td>
- </tr>
- <tr>
- <td height="167">Descrição:</td>
- <td> <textarea id="descricao" rows="10" name="descricao" cols="255" ><?php echo($descp)?></textarea> </td>
- </tr>
- <tr>
- <td>Categoria:</td>
- <td><select id="categoria" name="categoria">
- <?php
- include ("conexaobd.php");
- $consulta = mysqli_query($con,"SELECT idcat, nome FROM categoria_produto where idestab = $id_prod ");
- //Fazendo o looping para exibição de todos registros que contiverem em nomedatabela
- while ($dados = mysqli_fetch_array($consulta)) {
- if($dados['nome'] == $catp) echo("<option selected = 'true' value='".$dados['idcat']."'>".$dados['nome']."</option>");
- else echo("<option value='".$dados['idcat']."'>".$dados['nome']."</option>");
- }
- ?></select></td>
- </tr>
- <tr>
- <td>Preço:</td>
- <td><input type=text name= "preco" size="10" value = <?php echo($precop)?> onkeyup="foo(this)" />
- <script>
- function foo(obj){
- if(obj.value != obj.value.replace(/[^0-9,.]/g,"")){
- // the if is removeable if you don't want a message.
- obj.value = obj.value.replace(/[^0-9,.]/g,"");
- // strip all text and such.
- obj.focus();
- // ensure it keeps focus.
- alert("Por favor lembrar-se e apenas numeros.");
- // your message.
- };
- // remove this }; if your not having the if.
- };
- </script></td>
- </tr>
- <tr>
- <td>Status:</td>
- <td><select id="status" name="status">
- <?php
- {
- echo("<option value=0>Inativo</option>
- <option value=1>Ativo</option>");
- }
- ?></select></td>
- </tr>
- <tr>
- <td> </td>
- <td> <input type="submit" name="button" id="button" value="Alterar" />
- </td>
- </tr>
- </table>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement