<html><body>

<?php
$server   = 'mysql:dbname=shop;host=localhost';
$user     = 'root';
$password = '';
$options  = array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');

try {
	$db    = new PDO($server, $user, $password, $options);
	}
catch(Exception $e){
	echo "keine Datenbankverbindung";
    }
	
echo "<form action='anzeige.php' method='post'>";
echo "<strong> Artikel:</strong><br><input name='artikel' size='55'><br><br>";
echo "<input type='submit' name='login2' value='Anzeigen'>";
echo "</form>";

if(isset($_POST['login']))
{
$abfrage ="Select * from kunden where Name='$_POST[user_name]' and Passwort='$_POST[user_password]'";
$statement = $db-> query($abfrage);

$daten = $statement-> fetch();

if($statement->rowCount()>0)
{
echo "Hallo $daten[Name]<br><br>";
echo "Neue Artikel eingeben:<br><br>";
echo "<form action='eintrag.php' method='post'>";
echo "<strong> Bezeichnung:</strong><br><input name='bez'><br>";
echo "<strong> Einkaufspreis:</strong><br><input name='einkauf'><br>";
echo "<strong> Verkaufspreis:</strong><br><input name='verkauf'><br><br>";
echo "<input type='submit' name='login' value='Eintragen'>";
echo "</form>";
}
else
{die("Zugriff verweigert");}
}
else
{
echo "<br><br><form action='login.php' method='post'>";
echo "<strong> Username:</strong><br><input name='user_name'><br>";
echo "<strong> Passwort:</strong><br><input name='user_password'><br><br>";
echo "<input type='submit' name='login' value='Login'><br>";
echo "</form>";
}

?>
</body></html>