Who can help me with the following.
a part of my code doesn't work and i do not know wy.
<?php
//from here it is working
$con = mysql_connect("localhost", "bla", "bla");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("wordpress", $con);
$sql1 ="CREATE TABLE IF NOT EXISTS stamboom_landen (
id int(11) NOT NULL auto_increment,
land VARCHAR(150),
PRIMARY KEY (id) )";
mysql_query($sql1) or die(mysql_error());
if(isset($_POST['land_toevoegen']))
{
$ingevuldland = $_POST['land_text'];
// Als Post is leeg
if($_POST['land_text'] == '')
{
$con = mysql_connect("localhost","bla","bla");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("wordpress", $con);
$result = mysql_query("SELECT * FROM stamboom_landen");
echo"De volgenede landen bestaan al:<br>";
while($row = mysql_fetch_array($result))
{
echo $row['land'];
echo "<br>";
}
echo "<br><br>test 2 U heeft niks ingevuld<br><br>";
?>
<form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>
<input type='text' name='land_text' >
<input type='submit' name='land_toevoegen' value='Land Toevoegen'>
</form>
<?php
die();
}
// einde als post is leeg
// Als post is niet leeg
if($_POST['land_toevoegen'] != '')
{
$ingevuldland = $_POST['land_text'];
$connectdatum = mysql_connect("localhost","bla","bla") or die ("Kontrolier bitte ihren server connection.");
mysql_select_db("wordpress");
$query = "SELECT land FROM stamboom_landen WHERE land='$ingevuldland'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
$land = $row['land'];
// als land al in table staat
if($land == $ingevuldland)
{
$result = mysql_query("SELECT * FROM stamboom_landen");
echo"test 3 De volgenede landen bestaan al:<br>";
while($row = mysql_fetch_array($result))
{
// echo hier de landen die bestaan
echo $row['land'];
echo "<br />";
}
// echo hier het land dat is ingevuld en geef weer vanuit datatabel
echo "<br /><br />test1 $land bestaat al";
?>
<form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>
<input type='text' name='land_text' >
<input type='submit' name='land_toevoegen' value='Land Toevoegen'>
</form>
<?php
die();
}
// from here to down it is NOT working
else
{
$connectdatum = mysql_connect("localhost","bla","bla") or die ("Kontrolier bitte ihren server connection.");
mysql_select_db("wordpress");
$sql="INSERT INTO stamboom_landen (land)
VALUES ('$ingevuldland')";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
$result = mysql_query("SELECT * FROM stamboom_landen");
echo"De volgenede landen bestaan al:<br>";
while($row = mysql_fetch_array($result))
{
// echo hier de landen die bestaan
echo $row['land'];
echo "<br />";
}
echo "$ingevuldland";
?>
<form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>
<input type='text' name='land_text' >
<input type='submit' name='land_toevoegen' value='Land Toevoegen'>
</form>
<?php
}
die();
}
}
?>
//TILL here it is NOT working
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $lang['PAGE_TITLE']; ?></title>
</head>
<body>
<?php
$link = mysql_connect("localhost", "bla", "bla");
mysql_select_db("wordpress", $link);
$result = mysql_query("SELECT * FROM stamboom_landen", $link);
$num_rows = mysql_num_rows($result);
if ($num_rows == 0){
echo "er zijn nog geen landen in uw landen tabel";
?>
<form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>
<input type='text' name='land_text' >
<input type='submit' name='land_toevoegen' value='Land Toevoegen'>
</form>
<?php
die();
}
else{
$con = mysql_connect("localhost","bla","bla");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("wordpress", $con);
$result = mysql_query("SELECT * FROM stamboom_landen");
echo"test1 De volgenede landen bestaan al:<br>";
while($row = mysql_fetch_array($result))
{
echo $row['land'];
echo "<br />";
}
?>
<form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>
<input type='text' name='land_text' >
<input type='submit' name='land_toevoegen' value='Land Toevoegen'>
</form>
<?php
}
?>
</body>
</html>
Who can help me wy a part is not working
Thanks in advice John