Hello All
I have created a statement that works fine, taking the value from a form and inserting into a MS SQL table.
I now want to expand the code, to only insert when the value doesnt already exist...
My Current Code is as follows:
$tsql = "INSERT INTO email_supp
(email,date,source)
VALUES
(?,?,?)";
$today = date("d/m/y");
$source= 'Email Form';
$email = array($_POST['emailopt'], $today,$source);
/* Prepare and execute the query. */
$stmt = sqlsrv_query( $conn, $tsql, $email);
if( $stmt )
{
echo "Row successfully inserted.\n";
}
else
{
echo "Row insertion failed.\n";
die( print_r( sqlsrv_errors(), true));
}
/* Free statement and connection resources. */
/*sqlsrv_free_stmt( $stmt);*/
sqlsrv_close( $conn);
?>
My main problem here is I dont really know how the value is taken from the form, I know its within this part (array($_POST['emailopt']) but If i wanted to just specify the value to a variable my PHP seems to then fall over.
ANY help would be appreciated..
Thanks in advance
Bicky