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?

Recommended Answers

All 3 Replies

There is an actual PHP forum on this site where this might get answered better...

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.