Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Button not working

html

  • Please log in to reply
3 replies to this topic

#1 Dorgon

Dorgon

    CC Regular

  • Member
  • PipPipPip
  • 37 posts

Posted 07 November 2012 - 07:21 AM

Good afternoon,

I am creating an simple interface for my project to check if everything works but i have a problem.
I think the answer is quite simple but i just can't find te problem.

the button Delete doen't work.
The user in the database doen't get deleted. and I don't see the echo.

Tanks in advance.

here is my code:
<?php
// ALLE classes includen
$Folder = '../Classes/';
if ($Handle = opendir($Folder)) {
    while (false !== ($Entry = readdir($Handle))) {
	    if ($Entry != "." && $Entry != "..") {
		    require_once($Folder.$Entry);
	    }
    }
    closedir($Handle);
}
require_once('../Datalayer/Utilities/DAOFactory.php');
require_once('../Datalayer/Utilities/DBObject.php');
require_once('../Datalayer/MYSQL/MYSQLDAOFactory.php');
require_once('../Datalayer/MYSQL/MYSQLStudentDAO.php');
// eind
include('../TemplateHTML/bovenkant.tpl.html');
?>
<form name="form1" method="post" action="">
    <center>
    Voer het E-mail adres in van de student:<br />
    <input name="email" type="text" maxlength="50" /> <br />
    <input type="submit" name="submit" value="Haal op">
    </center>
</form>

<?php
if (isset($_POST['submit']) && !empty($_POST['email'])){
    $Email = $_POST['email'];
    $Voornaam = '';
    $Achternaam = '';
    $TussenVoegsel = '';
    $Wachtwoord = '';
    $Geslacht = '';
    $OVnummer = '';
    
    DAOFactory::setCurrentFactory(new MYSQLDAOFactory());
    $CurrentStudent = new Student($Voornaam, $Achternaam, $TussenVoegsel, $Wachtwoord, $Email, $Geslacht, $OVnummer);
    $CurrentStudent->loadStudent($CurrentStudent);
    
    
    ?>
    <form method="post" action="">
        <center>
        <b>Voornaam:</b><br />
        <?php echo $CurrentStudent->getVoornaam();?><br />
        <b>Achternaam</b>:<br />
        <?php echo $CurrentStudent->getAchternaam();?><br />
        <b>Tussenvoegsel:</b><br />
        <?php echo $CurrentStudent->getTussenVoegsel();?><br />
        <b>Email:</b><br />
        <?php echo $CurrentStudent->getEmail();?><br />
        <b>Geslacht:</b><br />
        <?php
        //
        $Geslacht = $CurrentStudent->getGeslacht();
        if($Geslacht = 1){
            echo 'man';
        }
        else{
            echo 'vrouw';
        }
        // OMZETTEN VAN BOOLEAN NAAR MAN/VROUW.
        ?><br />
        <b>Ovnummer:</b><br />
        <?php echo $CurrentStudent->getOVnummer();?><br />
        <input type="submit" name="delete" value="Delete">
        </center>
    </form>
    <?php
    if( isset($_POST['delete'])) {
        $CurrentStudent->deleteStudent($CurrentStudent);
        echo 'regegre';
    }
}





include('../TemplateHTML/onderkant.tpl.html');


  • 0

#2 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 07 November 2012 - 07:26 AM

if (isset($_POST['submit']) ...){
    [...html & php...]
    if( isset($_POST['delete'])) {
        $CurrentStudent->deleteStudent($CurrentStudent);
        echo 'regegre';
    }
}

See the problem? :)

Also, I don't think you check for equals there, but you SET it to 1
if($Geslacht = 1){

  • 0

#3 Dorgon

Dorgon

    CC Regular

  • Member
  • PipPipPip
  • 37 posts

Posted 07 November 2012 - 08:20 AM

Thanks for the reply.

When I put the delete button isset outside the submit isset it says that $CurrentStudent is not declared :/

thanks for the other fault!
  • 0

#4 Dorgon

Dorgon

    CC Regular

  • Member
  • PipPipPip
  • 37 posts

Posted 07 November 2012 - 10:37 AM

Ok I got it Working now but now i have an other problem, $CurrentStudent still is an Student object but it has no more values in the parameters?!?!

new code:
<?php
// ALLE classes includen
$Folder = '../Classes/';
if ($Handle = opendir($Folder)) {
    while (false !== ($Entry = readdir($Handle))) {
	    if ($Entry != "." && $Entry != "..") {
		    require_once($Folder.$Entry);
	    }
    }
    closedir($Handle);
}
require_once('../Datalayer/Utilities/DAOFactory.php');
require_once('../Datalayer/Utilities/DBObject.php');
require_once('../Datalayer/MYSQL/MYSQLDAOFactory.php');
require_once('../Datalayer/MYSQL/MYSQLStudentDAO.php');
// eind
include('../TemplateHTML/bovenkant.tpl.html');
?>
<form name="form1" method="post" action="">
    <center>
    Voer het E-mail adres in van de student:<br />
    <input name="email" type="text" maxlength="50" /> <br />
    <input type="submit" name="submit" value="Haal op">
    </center>
</form>

<?php
DAOFactory::setCurrentFactory(new MYSQLDAOFactory());
$Email = '';
    $Voornaam = '';
    $Achternaam = '';
    $TussenVoegsel = '';
    $Wachtwoord = '';
    $Geslacht = '';
    $OVnummer = '';
$CurrentStudent = new Student($Voornaam, $Achternaam, $TussenVoegsel, $Wachtwoord, $Email, $Geslacht, $OVnummer);
if (isset($_POST['submit']) && !empty($_POST['email'])){
    $Email = $_POST['email'];
    $CurrentStudent->setEmail($Email);
    $CurrentStudent->loadStudent($CurrentStudent);
    
    
    ?>
    <form method="post" action="">
        <center>
        <b>Voornaam:</b><br />
        <?php echo $CurrentStudent->getVoornaam();?><br />
        <b>Achternaam</b>:<br />
        <?php echo $CurrentStudent->getAchternaam();?><br />
        <b>Tussenvoegsel:</b><br />
        <?php echo $CurrentStudent->getTussenVoegsel();?><br />
        <b>Email:</b><br />
        <?php echo $CurrentStudent->getEmail();?><br />
        <b>Geslacht:</b><br />
        <?php
        //
        $Geslacht = $CurrentStudent->getGeslacht();
        if($Geslacht == 1){
            echo 'man';
        }
        else{
            echo 'vrouw';
        }
        // OMZETTEN VAN BOOLEAN NAAR MAN/VROUW.
        ?><br />
        <b>Ovnummer:</b><br />
        <?php echo $CurrentStudent->getOVnummer();?><br />
        <input type="submit" name="delete" value="Delete">
        </center>
    </form>
    <?php

}

if( isset($_POST['delete'])) {
    $CurrentStudent->deleteStudent($CurrentStudent);
}







include('../TemplateHTML/onderkant.tpl.html');

  • 0





Also tagged with one or more of these keywords: html

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download