Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

Sign in to follow this  
skullcrusher

Ajuda a remover linha (sql)

Recommended Posts

skullcrusher

Olá gente.

Estou a tentar fazer um script para remover a linha cujo campo "email" seja igual ao que for recebido no formulário, mas sem sucesso :D

		
<?php if (!$_POST){  ?>

<form method="post" action="/apagar.php" enctype="multipart/form-data">

<label>Email:</label> <input name="email" type="text" id="email" /></p>
<p><input class="enviar" type="submit"  /></p>

</form>

<?php

} else {

      include("config.php");

        $email_recebido = $_POST["email"];
$result = mysql_query("select email from boleia where email like '$email_recebido'"); 

   while($r=mysql_fetch_array($result)) 
   { 
	  $apagar=$r['email'];
	}

	$sql = "DELETE FROM boleia WHERE email=$apagar LIMIT 1";
	}
        ?>

Já dei altas voltas ao código, às tantas agora está alta trapalhada  :confused: Obrigado.

Share this post


Link to post
Share on other sites
scorch

Tenta assim:

               
<?php if (!$_POST){  ?>

<form method="post" action="/apagar.php" enctype="multipart/form-data">

        <label>Email:</label> <input name="email" type="text" id="email" /></p>
        <p><input class="enviar" type="submit"  /></p>

</form>

<?php

} else {
       
      include("config.php");
      
      $sql = mysql_query("DELETE FROM boleia WHERE email=\"".$_POST["email"]."\" LIMIT 1");
?>


scorch_pp.png

PS: Não respondo a perguntas por mensagem que podem ser respondidas no fórum.

Share this post


Link to post
Share on other sites
skullcrusher

$result = mysql_query("select email from boleia where email='".$email_recebido."'"); 

Não resultou, mas como código do scorch já está a bombear!

Obrigado aos 2 :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.