Hello,
I tried to execute the following form:
<html>
<head>
<title></title>
</head>
<body>
<FORM method="POST" action="jokehandle.php">
<INPUT TYPE="submit" name="addjoke" value="Insert"><BR/>
<INPUT TYPE="submit" name="deletejoke" value="Delete">
</FORM>
</body>
</html>
and the following script PHP:
<HTML>
<HEAD><TITLE>Operazioni su joke</TITLE></HEAD>
<BODY>
<?php
// If the user wants to add a joke
if (isset($_POST['addjoke'])==true):
?>



<FORM ACTION="jokehandle.php" 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_pconnect("localhost",
"root", "");
if (!$dbcnx) {
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
exit();
}


// Select the jokes database
if (! @mysql_select_db("jokes") ) {
echo( "<P>Unable to locate the joke " .
"database at this time.</P>" );
exit();
}


// If a joke has been submitted,
// add it to the database.
if ("SUBMIT" == $_POST['submitjoke']) {
$joketext=$_POST['joketext'];
$sql = "INSERT INTO Jokes SET " .
"JokeText='$joketext', " .
"JokeDate=CURDATE()";
if (mysql_query($sql)) {
echo("<P>Your joke has been added.</P>");
} else {
echo("<P>Error adding submitted joke: " .
mysql_error() . "</P>");
}
}
if (isset($_POST['deletejoke'])==true) {$sql = "DELETE FROM Jokes " .
"WHERE ID=$deletejoke";
if (mysql_query($sql)) {
echo "<P>The joke has been deleted.</P>";
}

} else {
echo("<P>Error deleting joke: " .
mysql_error() . "</P>");
}





echo("<P> Here are all the jokes " .
"in our database: </P>");

// Request the text of all the jokes
$result = mysql_query(
"SELECT ID,JokeText FROM Jokes");
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit();
}

// Display the text of each joke in a paragraph
while ( $row = mysql_fetch_array($result) ) {
$jokeid=$row["ID"];
$joketext=$row["JokeText"];
$PHP_SELF="jokehandle.php";
echo "<P>$joketext " .
"<A HREF='$PHP_SELF?deletejoke=$jokeid'>" .
"Delete this Joke</A></P>";
}



// When clicked, this link will load this page
// with the joke submission form displayed.
echo("<P><A HREF='$PHP_SELF?addjoke=1'>" .
"Add a Joke!</A></P>");

endif;

?>



</BODY>
</HTML>
I have this problem:
If I try to execute the delete no information is deleted from the database and I call jokehandle passing addjoke no joke is inserted in the database.
The browser show this message:
Notice: Undefined index: submitjoke in C:\FoxServ\www\db\jokehandle.php on line 43
Error deleting joke:
Here are all the jokes in our database:
Why did the chicken cross the road? To get to the other side! Delete this Joke
Prova Delete this Joke
Crisi Fiat forse risolta Delete this Joke
Sport. Vittoria della Juventus a Reggio Calabria per 2-0. Delete this Joke
La crisi Fiat c terminata male. Delete this Joke
Francesco Delete this Joke
Francesco Delete this Joke
Add a Joke!
Only the insert from a form does run. I don' t understand the problem.
I also ask if the FoxServer Version has bounded perfromance because the form in a script PHP that call itself run only if the action of the form is the name of the script or the S_SERVER['PHP_SELF'];. If the action is the langage variable SPHP_SELF the scipt doesn't run. If I use S_POST or S_GET with index 'PHP_SELF the script give the notice S_POST[''] undefined.
Bye from Francesco.


---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to