
October 14th, 2004, 01:20 PM
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 6
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
insert statement has me stumped.
I have this insert statment:
PHP Code:
<?php
$content_title = 'Home Page Administration';
$page_title = 'Index Page Options';
include( '../includes/subheader.php' );
include_once( '../includes/dbconnect.php' );
if( isset( $_POST['action'] ) == 'Submit Info' )
{ //Handle the form
// Create a function for escaping the data.
function escape_data ($data) {
// Need the connection.
global $dbc;
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string($data);
} // End of function.
//Create a blank variable
$message = NULL;
//Check for content title
if( empty( $_POST['title'] ))
{
$t = FALSE;
$message .= "<p><font color=\"red\">You need to title your post</font></p>";
} else {
$t = escape_data( $_POST['title'] );
}
//Check for content to be submitted.
if( empty( $_POST['content'] )) {
$c = FALSE;
$message .="<p><font color=\"red\">You can\'t display a blank home page!!</font></p>";
} else {
$c = escape_date( $_POST['content'] );
}
//Check for an image to be posted.
if( empty( $_POST['img'] )) {
$i = FALSE;
$message .="<p><font color=\"red\">You can\'t have a missing image</font></p>";
} else {
$i = $_POST['img'];
}
//Check for img description
if( empty( $_POST['imgdesc'] )) {
$imgdesc = FALSE;
$message .="<p><font color=\"red\">We need a description for this image!!</font></p>";
} else {
$imgdesc = escape_data( $_POST['imgdesc'] );
}
//Check for date to display
if( empty( $_POST['datetodisplay'] )) {
$dm = FALSE;
$message .= "<p><font color=\"red\">When do you want this to display?</font></p>";
} else {
$dm = $_POST['datetodisplay'];
}
if( $t && $c && $i && $imgdesc && $dm )
{
$sql = "INSERT INTO indexpage
( id, title, content, datemod, img, imgdesc, datetodisplay )
VALUES
( '', '$t', '$c', now(), '$i', '$imgdesc', '$dm' )";
//$result = mysql_query( $sql );
$result = mysql_query($sql) or die ("INSERT INTO DATABASE FAILED: ".mysql_error());
}
//Print the messge if there is one
if( isset( $message )) {
echo '<font color=\"red\">' . $message . '</font>';
}
}
?>
I am not able to send the post variables to the database, its not giving my red messages for missing fields, nothing.
Any ideas??
|