Hi,
I hate it to be a newbie, but you have to start somewhere... :bemused:
I simply tryed to create an addressbook for myself, which i can edit and keep up to date.
I know the form really looks like the form for a newbie, but when it's working, this will be furhter updated. For now, please help me out; the data i entered in the form is not inserted in my database and it should be so very simple!
This is the phpcode to insert the data into my database:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Insert_data</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
include("connect.php");
if(!empty($POST)) {
$POST['vnm'] = addslashes($vnm);
$POST['anm'] = addslashes($anm);
$POST['eml'] = addslashes($eml);
$string = "INSERT INTO Customer (Voornaam, Achternaam, Email) VALUES('$vnm', '$anm', '$eml')";
$Query = mysql_query($string) or die(mysql_error());
$_POST['$string'];
echo "DB bijgewerkt";
} else {
?>
<h1>Toevoegen Adres</h1>
<form name="klant" method="post" action="<?php echo $PHP_SELF;?>">
Voornaam: <input type="text" name="vnm"><br>
Achternaam: <input type="text" name="anm"><br>
E-mail: <input type="text" name="eml"><br>
<input type="submit" name="submit" value="submit">
</form>
<?php } ?>
</body>
</html>
this is the code to check if there is anything in my database after adding the php form:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>zoekop3_php</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
include ("connect.php");
$host = "localhost";
$dbusername = "****";
$password = "**";
$db = "****";
mysql_connect($host, $dbusername, $password) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
$query = mysql_query("SELECT * FROM Customer");
while($row = mysql_fetch_array($query)) {
echo "ID: " . $row["ID"] . "<br>";
echo "Naam: " . $row["Naam"] . "<br>";
echo "Achternaam: " . $row["Achternaam"] . "<br>";
echo "Email: " . $row["email"] . "<br>";
}
?>
</body>
</html>
I get no errors, when entering data to the database, but nothing is entered! When i try to look up the data entered in the database (at least should...), this is what the screen comes up with:
ID:1
Naam:
Adres:
Email:
ID:2
Naam:
Adres:
Email:
and so on
So, however the system tells me there is data added to my database Customer(4 columns; ID-int-11-NOT NULL-auto_increment, Voornaam-varchar-50-NOT NULL, Achternaam-varchar-50- NOT NULL, Email-varchar-100-NOT NULL), only the id's are getting 1 nuber bigger all the time, but there is nothing in it.
Is there please someboby who can help me out? Thanks in advance - dutch newbie.