making a insert fields....
Posted: Tue Mar 01, 2005 2:41 am
alright i just got up the poem part that i wanted well im making a place where the users can go to submit there poems and well i just used my signup script and edited it alil bit it works expect for adding stuff to the database can someone find what im doing wrong??
code
code
Code: Select all
<?php
// dbConfig.php is a file that contains your
// database connection information. This
// tutorial assumes a connection is made from
// this existing file.
include ("dbConfig.php");
// ==== Input validation and PHP dBase code ===============================
//
// ========================================================================
if ( $_GETї"op"] == "poe" )
{
$bInputFlag = false;
foreach ( $_POST as $field )
{
if ($field == "")
{
$bInputFlag = false;
}
else
{
$bInputFlag = true;
}
}
// If we had problems with the input, exit with error
if ($bInputFlag == false)
{
die( "Problem with your registration info. "
."Please go back and try again.");
}
// Fields are clear, add user to database
// Setup query
$q = "INSERT INTO `dbpoems` (`username`,`poem`) "
."VALUES ('".$_POSTї"username"]."', "
."poem('".$_POSTї"poem"]."'), ";
// Run query
$r = mysql_query($q);
// Make sure query inserted user successfully
if ( !mysql_insert_id() )
{
die("Error: You stink to much so you didnt get put in there =P.");
}
else
{
// Redirect to thank you page.
Header("Location: poems.php");
}
} // end if
// ==== Thank you page ====================================================
//
// ========================================================================
elseif ( $_GETї"op"] == "thanks" )
{
echo "<h2>Thanks for submitting your poems at Haunted Graveyard!</h2>";
}
// ==== Main Form =========================================================
//
// ========================================================================
else
{
echo "<form action="?op=poe" method="POST">\n";
echo "Username: <input name="username" MAXLENGTH="25"><br />\n";
echo "Poem: <input type="poem" name="poem" MAXLENGTH="25"><br />\n";
echo "<input type="submit">\n";
echo "</form>\n";
}
// EOF
?>