user3225445
user3225445

Reputation: 23

HTML, MySQL and PHP -> no text boxes

Hello and a good evening to you all,

I´ve been a long time lurker of this site, but for the first time I could not find an answer to my question.

I have to create a small administration interface for my IT classes. I have everything up and running, and I created a database. I am trying to work out how I can create different queries when a checkbox is checked. When I remove all the PHP code, the webpage shows me all the text boxes but when adding the PHP code, all the boxes seem to disappear. I can´t work out how this is possible.

Here is my code (the names of the items are in Dutch but I don´t think that will be of any problem since the idea is the same...)

<html>
<body>
<h1>Mutatie toevoegen</h1>

<?php
include 'config.php';

if(isset($_POST['verzenden']))
{
$bedrag=$_POST['bedrag'];
$voornaam=$_POST['voornaam'];
$achternaam=$_POST['achternaam'];
$contant=$_POST['contant'];
$datum=$_POST['datum'];
$omschrijving=$_POST['omschrijving'];
$uitgave=$_POST['uitgave'];
$bonnetje=$_POST['bonnetje'];

if($uitgave == 'uitgave')
{
   //Het is een uitgave
  if($contant == 'contant')
  {
      //het is contant, er moet voor een bonnetje bij
      $bonnetje=$_GET['uitgave_id']+1;
      $query="insert into uitgaven(bedrag, voornaam, achternaam, contant, datum, omschrijving, bonnetje)
      values('$bedrag', '$voornaam', '$achternaam', '$contant', '$datum', '$omschrijving', '$bonnetje')";
  }
  else
  {
      //het is niet contant, er hoeft niets bij
      $query="insert into uitgaven(bedrag, voornaam, achternaam, contant, datum, omschrijving)
      values('$bedrag', '$voornaam', '$achternaam', '$contant', '$datum', '$omschrijving')";
  }
}
else
{
  //Het is een inkomst
  if($contant == 'contant')
  {
      //het is contant, er moet voor een bonnetje bij
      $bonnetje=$_GET['inkomsten_id']+1;
      $query="insert into inkomsten(bedrag, voornaam, achternaam, contant, datum, omschrijving, bonnetje)
      values('$bedrag', '$voornaam', '$achternaam', '$contant', '$datum', '$omschrijving', '$bonnetje')";
  }
  else
  {
      //het is niet contant, er hoeft niets bij
      $query="insert into inkomsten(bedrag, voornaam, achternaam, contant, datum, omschrijving)
      values('$bedrag', '$voornaam', '$achternaam', '$contant', '$datum', '$omschrijving')"//     }
}




if(mysql_query($query))
{
        echo '<p>De nieuwe gegevens zijn toegevoegd.<br>';
        echo 'Controleer dit op <a href=studenten.php>studenten.php</a></p>';
        }
        else
        {
            echo '<p>Er is iets fout gegaan!</p>';
            echo mysql_error();
        }

    }
?>


<form action="" method="post">
<label>Bedrag(in euro):</label>
<input type="number" name="bedrag"><br/>
<label>Voornaam:</label>
<input type="text" name="voornaam"><br/>
<label>Achternaam:</label>
<input type="text" name="achternaam"><br/>
<label>Datum:</label>
<input type="date" name="datum"><br/>
<label>Omschrijving:</label>
<input type="text" name="omschrijving"><br/>
<label>Contant?</label>
<input type="checkbox" name="contant" value="contant"><br/>
<label>Uitgave?</label>
<input type="checkbox" name="uitgave" value="uitgave"><br/>
<input type="submit" name="verzenden" value="Verstuur">
<input type="reset" name="reset" value="Reset">
</form>
<p>Alle velden zijn verplicht.</p>


</body>

</html>

Running this on my apache webserver with PHP5 and MySQL installed, gives back a blank page. I was wondering if you guys could help me.

With great thanks in advance,

Upvotes: 2

Views: 91

Answers (1)

Anonymous
Anonymous

Reputation: 12017

You did not close your if statement here:

if(isset($_POST['verzenden']))
{

If you add a } where this loop should end (which I am pretty sure is right before ?>), it should fix that problem. In addition, you missed a semicolon on this line:

$query="insert into inkomsten(bedrag, voornaam, achternaam, contant, datum, omschrijving)
  values('$bedrag', '$voornaam', '$achternaam', '$contant', '$datum', '$omschrijving')"//     }

So, just change that line to this:

$query="insert into inkomsten(bedrag, voornaam, achternaam, contant, datum, omschrijving)
  values('$bedrag', '$voornaam', '$achternaam', '$contant', '$datum', '$omschrijving')";//     }

Upvotes: 5

Related Questions