Hi,
ja bin momentan am lernen und mach eine kleine Auswahl
zum Hintergrundfarbe ändern.
Folgendes Script:
PHP
<?php
$color = htmlspecialchars($_POST['color']);
if (isset($color))
{
switch($color)
{
case '1':
$farbe = '#FFE500';
break;
case '2':
$farbe = '#00FF00';
break;
default:
$farbe = '#FFFFFF';
break;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<title>First</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<meta name="description" content="" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="generator" content="Webocton - Scriptly (www.scriptly.de)" />
<link href="styles/style.css" type="text/css" rel="stylesheet" />
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon" />
</head>
<body bgcolor="<?php echo $farbe; ?>">
<div id="website">
<div id="header"> <h1>Website</h1></div>
<div id="main">
<div id="left">
<form action="index.php" method="post" >
Hintergrundfarbe:
<select name="color">
<option value="1">Gelb</option>
<option value="2">Grün</option>
<option value="" selected="selected">Keine Auswahl</option> </select>
<input type="submit" value="Farbe wechseln" />
</form>
</div>
<div id="right"></div>
<div id="footer">
© - by Lalox3, All rights reserved.</div>
</div>
</div>
</body>
</html>
Alles anzeigen
Dann kommt:
ZitatNotice: Undefined index: color in C:\xampp\htdocs\new\index.php on line 2
Sollte natürlich nicht sein, aber es nerft.... richtig!
Wie bekommt man diese Undefinierten Variablen hin das es keine fehlermeldungen Spuckt.???
Line 2:
Greez and ty