I'm working a very simple script for an email (messaging) between users. I have a form with two buttons that gives you the option to save message as a draft or just send it to the user.
Here are the two buttons on form:
<input type="submit" name="save" id="save" value="Save as Draft" />
<input type="submit" name="send" id="send" value="Send" />
Here is how I'm trying to differentiate between form actions.
if(isset($_POST['save']) && trim($_POST["save"])!==''){
mysql_query("UPDATE mailbox SET
member_id='$_SESSION[user_id]',
message='$message',
draft='DRAFT',
subject='$subject',
date='$dsub'
WHERE id='$draftid'");
header('Location: mailbox.php');
}elseif(isset($_POST['send']) && trim($_POST["send"])!==''){
$send="INSERT INTO mailbox SET
member_id='$memid',
user_name='$$_SESSION[user_name]',
user_id='$_SESSION[user_id]',
message='$message',
inbox='NEW',
subject='$subject',
date='$dsub' " ;
$save_result=mysql_query($save);
header('Location: mailbox.php');
// update draft to sent
mysql_query("UPDATE mailbox SET
draft='',
sent='SENT'
WHERE id='draftid'");}
header('Location: mailbox.php');
Save works just fine, but in the event I try to send it disregards the Save as I would expect it to, but it also disregards the rest of the script and just executes the header. Not quite sure what I'm doing wrong here. Any ideas would be greatly appreciated.