| | |
One form, two actions
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
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:
Here is how I'm trying to differentiate between form actions.
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.
Here are the two buttons on form:
html Syntax (Toggle Plain Text)
<input type="submit" name="save" id="save" value="Save as Draft" /> <input type="submit" name="send" id="send" value="Send" />
php Syntax (Toggle Plain Text)
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');
html Syntax (Toggle Plain Text)
$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); // update draft to sent mysql_query("UPDATE mailbox SET draft='', sent='SENT' WHERE id='draftid'"); header('Location: mailbox.php');
How bout that....
u do insert and update then after that u give the header.......
is it works?
php Syntax (Toggle Plain Text)
$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);
What is $save? I think you are trying to run the query $send?
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. ![]() |
Similar Threads
- one FORM two actions ???? (PHP)
- Trying to get pagename in URL for PHP (PHP)
- Automated form submission (Python)
- Multiple Submit Buttons in Form (PHP)
- CGI, without going anywhere? (Perl)
- form-to-email in Dreamweaver (Community Introductions)
Other Threads in the PHP Forum
- Previous Thread: How to Display Motherboard Serial With PHP
- Next Thread: how to add time duration in php
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner binary broken buttons cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source sp space speed sql subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web websphere white xml youtube





