Antwort
<?php
echo "<body style=\"background-color: #FF8000\">";
?>
<form name="textsuche" method="post"
action="<?php echo $_SERVER['PHP_SELF']; ?>">
<pre>
id: <INPUT TYPE="text" MAXLENGTH="30" SIZE="15" NAME="id">
Bauteil: <INPUT TYPE="text" MAXLENGTH="30" SIZE="15" NAME="bauteil">
Etage: <INPUT TYPE="text" MAXLENGTH="30" SIZE="15" NAME="etage">
Raumnummer1: <INPUT TYPE="text" MAXLENGTH="30" SIZE="15" NAME="raum1">
Raumnummer2: <INPUT TYPE="text" MAXLENGTH="30" SIZE="15" NAME="raum2">
Bezeichnung: <INPUT TYPE="text" MAXLENGTH="30" SIZE="15" NAME="bez">
Fläche: <INPUT TYPE="text" MAXLENGTH="30" SIZE="15" NAME="flaeche">
Gesamthöhe: <INPUT TYPE="text" MAXLENGTH="30" SIZE="15" NAME="hoehe">
Material Wand: <INPUT TYPE="text" MAXLENGTH="30" SIZE="15" NAME="material">
Flächentyp: <INPUT TYPE="text" MAXLENGTH="30" SIZE="15" NAME="typ">
Nutzer: <INPUT TYPE="text" MAXLENGTH="30" SIZE="15" NAME="nutzer">
lh: <INPUT TYPE="text" MAXLENGTH="30" SIZE="15" NAME="lh">
<INPUT TYPE="submit" VALUE="Suchen" name="submit"> <INPUT TYPE="Reset" VALUE="Zurücksetzen" name="submit">
</pre>
</form
<!DOCTYPE html>
<html>
<body>
<header>
<h1>
Suchergebnis</h1>
</header>
</html>
<?php
if (isset($_POST['submit'])) {
print_r($_POST);
$sql = "SELECT * FROM institut2;";
if(isset($_POST['id'])) {
$sql="SELECT * FROM institut2 WHERE id LIKE ".
"'%". mysql_real_escape_string($_POST['id']) . "%'".
" ";
}
if(isset($_POST['bauteil'])) {
$sql="SELECT * FROM institut2 WHERE Bauteil LIKE ".
"'%". mysql_real_escape_string($_POST['bauteil']) . "%'".
" ";
}
if(isset($_POST['etage'])) {
$sql="SELECT * FROM institut2 WHERE Etage LIKE ".
"'%". mysql_real_escape_string($_POST['etage']) . "%'".
" ";
}
if(isset($_POST['raum1'])) {
$sql="SELECT * FROM institut2 WHERE Raumnummer1 LIKE ".
"'%". mysql_real_escape_string($_POST['raum1']) . "%'".
" ";
}
if(isset($_POST['raum2'])) {
$sql="SELECT * FROM institut2 WHERE Raumnummer2 LIKE ".
"'%". mysql_real_escape_string($_POST['raum2']) . "%'".
" ";
}
if(isset($_POST['bez'])) {
$sql="SELECT * FROM institut2 WHERE Bezeichnung LIKE ".
"'%". mysql_real_escape_string($_POST['bez']) . "%'".
" ";
}
if(isset($_POST['flaeche'])) {
$sql="SELECT * FROM institut2 WHERE Fläche LIKE ".
"'%". mysql_real_escape_string($_POST['flaeche']) . "%'".
" ";
}
if(isset($_POST['hoehe'])) {
$sql="SELECT * FROM institut2 WHERE Gesamthöhe LIKE ".
"'%". mysql_real_escape_string($_POST['hoehe']) . "%'".
" ";
}
if(isset($_POST['material'])) {
$sql="SELECT * FROM institut2 WHERE Material_Wand LIKE ".
"'%". mysql_real_escape_string($_POST['material']) . "%'".
" ";
}
if(isset($_POST['typ'])) {
$sql="SELECT * FROM institut2 WHERE Flächentyp LIKE ".
"'%". mysql_real_escape_string($_POST['typ']) . "%'".
" ";
}
if(isset($_POST['nutzer'])) {
$sql="SELECT * FROM institut2 WHERE Nutzer LIKE ".
"'%". mysql_real_escape_string($_POST['nutzer']) . "%'".
"";
}
if(isset($_POST['lh'])) {
$sql="SELECT * FROM institut2 WHERE lh LIKE ".
"'%". mysql_real_escape_string($_POST['lh']) . "%'".
" ";
}
$c = mysql_connect('localhost', 'Julian', '123') or die("Keine Verbindung möglich. Benutzername oder Passwort sind falsch");
mysql_select_db('Institutgoe') or die("Die Datenbank existiert nicht.");
if(1==0) {
$sql =
"SELECT * FROM institut2 WHERE id = '%"
. mysql_real_escape_string($_POST['id']) . "%'
";
"SELECT * FROM institut2 WHERE Bauteil = '%"
. mysql_real_escape_string($_POST['bauteil']) . "%'
";
"SELECT * FROM institut2 WHERE Etage = '%"
. mysql_real_escape_string($_POST['etage']) . "%'
";
"SELECT * FROM institut2 WHERE Raumnummer1 = '%"
. mysql_real_escape_string($_POST['raum1']) . "%'
";
"SELECT * FROM institut2 WHERE Raumnummer2 = '%"
. mysql_real_escape_string($_POST['raum2']) . "%'
";
"SELECT * FROM institut2 WHERE Bezeichnung = '%"
. mysql_real_escape_string($_POST['bez']) . "%'
";
"SELECT * FROM institut2 WHERE Fläche = '%"
. mysql_real_escape_string($_POST['flaeche']) . "%'
";
"SELECT * FROM institut2 WHERE Gesamthöhe = '%"
. mysql_real_escape_string($_POST['hoehe']) . "%'
";
"SELECT * FROM institut2 WHERE Material_Wand = '%"
. mysql_real_escape_string($_POST['material']) . "%'
";
"SELECT * FROM institut2 WHERE Flächentyp = '%"
. mysql_real_escape_string($_POST['typ']) . "%'
";
"SELECT * FROM institut2 WHERE lh = '%"
. mysql_real_escape_string($_POST['nutzer']) . "%'
";
}
echo "<!-- SQL = $sql -->";
$result = mysql_query($sql) or die(mysql_error());
if(($treffer = mysql_num_rows($result)) > 1) {
}
Der letzte Teil ist richtig.