Form Query
Posted: Sun Oct 11, 2009 3:09 am
Good Morning
I have got the following code:
The section of updating the database is working fine however on the form there are 3 controls (Textarea class, Textbox, Submit button). When i click submit i want just the content of the textarea class to be saved to the database where are currently the contents of all three controls are being saved one after the other so in the end "submit" ends up on there field because it loops through all the items saving one after another.
What am I doing wrong and how can i stop this happening and just saving the textarea class contents?
Thank you in advance
Frosty
I have got the following code:
Code: Select all
if ( isset( $_POST ) )
$postArray = &$_POST; // 4.1.0 or later, use $_POST
else
$postArray = &$HTTP_POST_VARS; // prior to 4.1.0, use HTTP_POST_VARS
foreach ( $postArray as $sForm => $value )
{
if ( get_magic_quotes_gpc() )
$postedValue = htmlspecialchars( stripslashes( $value ) ) ;
else
$postedValue = htmlspecialchars( $value ) ;
$user='user';
$host='localhost';
$password='password';
$database='database';
$con=mysqli_connect($host, $user, $password, $database)
or die ("Error 201: The SQL Server could not be contacted at this time. please try agian or if the problem persists contact Luke Frost");
$query = "UPDATE oc_message SET Content = '" . $postedValue . "', OC_Name = '" . $_POST['OC_Name'] . "' WHERE URN = 1";
$result=mysqli_query($con, $query)
or die ("Error 202: The 332 Sqn SQL Server could not be contacted at this time. please try agian or if the problem persists contact Luke Frost");
echo "Home Page has been updated successfully to the following information:<br><br>";
echo "<strong>OC's Message</strong><br>";
echo $postedValue;
echo "<br><br><strong>OC's Name</strong><br>";
echo $_POST['OC_Name'];
echo "<br><Br>Page will redirect automatically after 5 seconds.<br>";
echo "If the page does not refresh click <a href='../WebsiteAdmin_Webpages.php'>here</a>";
}What am I doing wrong and how can i stop this happening and just saving the textarea class contents?
Thank you in advance
Frosty