Using POST and GET together?

Hello!

Little bit of a problem here…
I’ve build a function for a script that allows you to select multiple messages in an inbox via a check box. The id of the message get put into an array, and sent through POST to the script. However, I need to send GET info, to tell the script which action is being submitted, ie delete, mark open, mark new, move to, etc.

Currently I’m using javascript in an onclick in an anchor, so the href is the scripts address with GET info, and the onclick submits the form.

However, the GET info gets to the script fine, but the form info doesn’t make it. Here’s the relevant code:

The HTML with the links to submit the form, and GET info with the action info:

<form name="cbox" method="post" action="jmail.php"> <p align="center"><input type="checkbox" name="checkall" onclick="checkUncheckAll(this);"/> Select all / Un-select all <br> <a href="jmail.php?user=$aid&action=delsel" onclick="document['cbox'].submit();">Delete</a> | <a href="jmail.php?user=$aid&action=marksel" onclick="document['cbox'].submit();">Mark Read</a></form?

Here’s what receives the info, just incase:

[code]// Nested mark read and delete
if(isset($_GET[action])) {

// Mark as read
if($_GET[action] == "marksel") {
	//do some stuff here

}

//Delete
if($_GET[action] == "delsel") {
	//do some stuff here
}

[/code]

Thanks for any and all help in advance!

<a href="#" onclick="document['cbox'].action='jmail.php?user=$aid&action=delsel';document['cbox'].submit();">Delete</a>

but its better to use no JavaScript at all:

<form name="cbox" method="post" action="jmail.php"> <p align="center"><input type="checkbox" name="checkall" onclick="checkUncheckAll(this);"/> Select all / Un-select all <br> <input type="hidden" name="user" value="$aid" /> <input type="submit" name="action" value="Delete" /> <input type="submit" name="action" value="Mark Read" />

[code]
if(isset($_POST[‘user’]))$_GET[‘user’]=$_POST[‘user’];

// Nested mark read and delete
if(isset($_POST[‘action’])) {

// Mark as read
if($_POST[‘action’] == “Mark Read”) {
//do some stuff here

}

//Delete
if($_POST[‘action’] == “Delete”) {
//do some stuff here
} [/code]

Sponsor our Newsletter | Privacy Policy | Terms of Service