0

Hi,
i'm doing a page where user can register and give up of a course:

<td width="5%">
                </td>
                <td>
                PROGRAMAÇÃO:
                <br/>
                <?PHP
                        $cc=$_GET['cod'];
                        $sql_prog = "SELECT prog_curso FROM cursos WHERE cod_curso=".$cc;
               
                        $query_prog = mysql_query($sql_prog, $connect);
               
                        while ($row = mysql_fetch_array($query_prog))
                        {
                                echo $row['prog_curso'];
                        }
                ?>
                <br/>
                </td>
                <?PHP
                if(is_logged())
                {
                ?>
                <form action="inscreve.php?cod=<?php echo $cc ?>" method="post" class="registration_form">
                        <input type="submit" name='inscreve' value="Inscrever" />
                </form>
                <form action="desiste.php?cod=<?php echo $cc ?>" method="post" class="registration_form">
                        <input type="submit" name='desiste' value="Desistir">
                </form>
                <?PHP
                ;}
                ?>
        </tr>

desiste.php:

<?php

include 'topo.php';
include ('db_connect.php');

$cc = $_GET['cod'];
$aluno=$_SESSION['cod_aluno'];

$query_delete_user = "DELETE FROM al_curso WHERE cod_curso=". $cc ." AND cod_aluno=". $aluno;
$result_delete_user = mysql_query($query_delete_user, $connect);

if (!$result_delete_user){
        echo '<div class="warning"> Não estava inscrito neste curso. </div>';
}
else
{
        header("location: desiste_suc.php?cod=$cc");
}

include 'rodape.php';
?>

desiste_suc.php:

<?PHP
        include 'topo.php';
        echo '<div class="success"> O aluno desitiu. </div>';
        include 'rodape.php';
?>

So, the register part it's working perfectly, but the give up part, i have a student register in Guitar and if i give up it Delets ('til here we're ok) now if i give up again it should say "The student is not register in the course", instead of that it says "Give up successfuly".

Can someone help me?

Edited by PF2G: n/a

4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by pritaeas
0

It might be me, but I don't completely understand what your question is. Or, better said, I understand your question, but the context is kind of unclear to me.

Edited by minitauros: n/a

0

mysql_query returns true even if there are no records deleted. Have a look at mysql_affected_rows. Use that to determine if there are either zero, or one or more rows deleted.

Edited by pritaeas: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.