Just started using php within the last few days. It seemed fairly simple so I just jumped right in. Now, I am just trying to get this simple thing to work. It does not return any errors. I know I am able to connect to the db. My problem is with the hyperlink, it will not give me the form to fill out. It just continues to repost the hyperlink. I am hoping that I am just over looking something, but from what I can tell everything looks good. Any suggestions.
Thanks,
Jason
<BODY bgcolor="#FFFFFF">
<?php // if user wants to add joke
if (isset($addjoke)): ?>
<form action="<?php echo($PHP_SELF); ?>" method=POST>
<P>Type your joke here:<BR>
<textarea name="joketext" rows=10 cols=40 wrap>
</textarea><BR>
<input type=submit name"submitjoke" value="submit">
</form>
<?php else:
// connect to the database server
$dbcnx=@mysql_connect ("localhost","user","passwd");
if (!$dbcnx) {
echo ("<P>Unable to connect to database at this time.</P>");
exit();
}
// get the Jokes database
if (! @mysql_select_db("Jokes")) {
echo ("<P> Unable to locate the Joke database at this time</P>");
exit();
}
// if joke has been submitted add to database
if ("submit"==$submitjoke) {
$sql="INSERT INTO Jokes SET ".
"JokeText='$joketext',".
"JokeDate=CURDATE()";
if (mysql_query($sql)) {
echo ("<P> Your joke has been added.</P>");
} else {
echo ("Error adding Joke to Database: ".mysql_error()."</P>");
}
}
// Request the text of all the Jokes
$result=mysql_query(
"SELECT JokeText FROM Jokes");
if (!$result) {
echo ("Error performing query: ".mysql_error()."</P>");
exit();
}
// Display the text of each joke in a paragraph
while ($row = mysql_fetch_array($result)){
echo("<P>".$row["JokeText"]."<P>");
}
// When clicked, this link will load the page
// with the joke submission form displayed
echo ("<P> <A HREF='$PHP_SELF?addjoke=1'>". "Add a joke!</A></P>");
endif;
?>
</body>