954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Register in course

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?

PF2G
Junior Poster
127 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

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

hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 167
 

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.

minitauros
Junior Poster
109 posts since Apr 2011
Reputation Points: 36
Solved Threads: 17
 

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.

pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: