Re: Difficulty posting array data
Posted: Fri Jun 24, 2011 12:18 pm
Ok, this works. (Ya-hoo!)
However, I'm wondering if i need to add the escape sequence at the bottom after the last else statement as well?
However, I'm wondering if i need to add the escape sequence at the bottom after the last else statement as well?
Code: Select all
//inserting records
$Insert=sprintf("INSERT INTO formdata(FirstName, LastName, Email, Status, Date, Source)
VALUES
('FirstName','LastName','Email','Status','Date','Source')",
mysql_real_escape_string($_POST['FirstName']),
mysql_real_escape_string($_POST['LastName']),
mysql_real_escape_string($_POST['Email']),
mysql_real_escape_string($_POST['Status']),
mysql_real_escape_string($_POST['Date']),
mysql_real_escape_string($_POST['Source'])
);
$error = 0;
if(isset($_POST['Status'])){
if($_POST['Status'] == 'Other'){
if(isset($_POST['Other']) && trim($_POST['Other']) != ''){
$status = $_POST['Other'];
} else {
$error++;
echo "Please fill out the 'Other' box.<br />";
}
} else {
$status = $_POST['Status'];
}
} else {
$error++;
echo "Please select a 'Status'.<br />";
}
if($error){
echo "<br />There were $error error".($error>1?'s':'').".";
} else {
$Insert="INSERT INTO formdata(FirstName, LastName, Email, Status, Date, Source)
VALUES
('".$_POST['FirstName']."','".$_POST['LastName']."','".$_POST['Email']."','".$status."',Now(),'".$_POST['Source']."')";
}
if(!mysql_query($Insert,$dbc)){
die('Error: '.mysql_error ());
}