i have set up a php script, that asks the database jokes to show all of its data… i want to be able to add a joke. so everytime you click on the link to add a joke, you are supposed to see a form where to put your joke into! here is the script (but it doesnt work):
<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=windows-1250″>
<meta name=”generator” content=”PSPad editor, [url]www.pspad.com
<title></title>
</head>
<body>
<?php
if(isset($addjoke)):
?>
<form action=”<?=$PHP_SELF?>” method=”post”>
<p>Geben Sie hier ihren Witz ein: <br />
<textarea name=”joketext” rows=”5″ cols=”30″ wrap>
</textarea><br />
<input type=”submit” name=”submitjoke” value=”Speichern” />
</p>
</form>
<?php
else:
$dbcnx=mysql_connect(“localhost”, “root”);
if(!$dbcnx){
echo(“<p>cant connect</p>”);
exit();
}
if(!mysql_select_db(“jokes”)){
echo(“<p>auswahl der witzebank zur zeit nicht möglich</p>”);
exit();
}
if($submitjoke == “Speichern”){
$sql = “INSERT INTO Jokes SET
JokeText=’$JokeText’,
JokeDate=CURDATE()”;
if(mysql_query($sql)){
echo(“<p>witz wurde hinzugefügt</p>”);
}else{
echo(“<p>FEHLErhaft das ganze</p>”);
}
}
echo(“<p>hier sind alle witze:</p>”);
$result = mysql_query(“SELECT JokeText FROM Jokes”);
if(!$result){
echo(“<p>alles scheisse man</p>”);
exit();
}
while($row=mysql_fetch_array($result)){
echo(“<p>”.$row[“JokeText”].”</p>”);
}
echo(“<p><a href=’$PHP_SELF?addjoke=1′>”.”einen witz hinzufuegen!</a></p>”);
endif;
?>
</body>
</html>
thanks,
daniel