Jump to content
xisto Community
sonesay

Question About Multiple Voting Post Or Get Methods Multiple voting post or get methods on 1 page

Recommended Posts

Hi all. I'm working on a page that outputs a list of submited applications where exisitng members can view the list and submit their vote on each application.

 


echo("<span class='base_header'>Accept</span><input type='radio' name='status' value='accept' />");

echo("<span class='base_header'>Reject</span><input type='radio' name='status' value='reject' />");

echo("<input type='submit' value='Vote' />");

echo("</form>");

echo("</p>"); linenums:0'>// output voting option for each application. echo("<p>"); echo("<form method='post'>"); echo("<span class='base_header'>Accept</span><input type='radio' name='status' value='accept' />"); echo("<span class='base_header'>Reject</span><input type='radio' name='status' value='reject' />"); echo("<input type='submit' value='Vote' />"); echo("</form>"); echo("</p>");


I want to be able to submit to the same page but cant figure out how I am going to do it with the post method and retain the application Id which will be used later to process the vote.

 

I have got around this problem before with using links and using get method but it does give an ugly url extention and I dont want to resort to this.

<a href=\"example.php?remove=" . $id . "\"> Remove</a>

One advantage that get methods have is you can add additional id info on it like ?remove from above code example. I need someting like that for post method voting section. My question is it is possible to use the post method to submit votes and somehow retain a key for application id that is needed to process the vote. I have not added any names or id to the form because Im not sure which one I could use.

 

heres an screen shot to give you a better idea of what im after.

Posted Image

 

I know I could get around this with only displaying 1 form for each application on its own page then there would be only 1 form to submit but displaying multiple forms is more desirable.

Share this post


Link to post
Share on other sites

You could always make a hidden textbox and fill it with the value of the ID you want, then send it along with the other data to the processor page?Im a little confused at what you want but i think thats right?

Share this post


Link to post
Share on other sites

Google "Larry Ullman sticky form redux php" to see the process in action.
The form's action needs to be the same page as what sends the form.
At the top of the form, check for a value which is 'hidden' and process the data, or if there is no value hidden, then display the form.

http://forums.xisto.com/no_longer_exists/

Sample of the Redux method here:

include ('./includes/header.html');

// Check if the form has been submitted.
if (isset($_POST['submitted'])) {

// Minimal form validation.
if ( is_numeric($_POST['quantity']) && is_numeric($_POST['price']) && is_numeric($_POST['tax']) ) {

// Calculate the results.
$taxrate = $_POST['tax'] / 100; // Turn 5% into .05.
$total = ($_POST['quantity'] * $_POST['price']) * ($taxrate + 1);

// Print the results.
echo '<h1 id="mainhead">Total Cost</h1>
<p>The total cost of purchasing ' . $_POST['quantity'] . ' widget(s) at $' . number_format ($_POST['price'], 2) . ' each, including a tax rate of ' . $_POST['tax'] . '%, is $' . number_format ($total, 2) . '.</p><p><br /></p>';

} else { // Invalid submitted values.
echo '<h1 id="mainhead">Error!</h1>
<p class="error">Please enter a valid quantity, price, and tax.</p><p><br /></p>';
}

} // End of main isset() IF.

// Leave the PHP section and create the HTML form.
?>
<h2>Widget Cost Calculator</h2>
<form action="calculator.php" method="post">
<p>Quantity linenums:0'><?php # Script 3.5 - calculator.php$page_title = 'Widget Cost Calculator';include ('./includes/header.html');// Check if the form has been submitted.if (isset($_POST['submitted'])) { // Minimal form validation. if ( is_numeric($_POST['quantity']) && is_numeric($_POST['price']) && is_numeric($_POST['tax']) ) { // Calculate the results. $taxrate = $_POST['tax'] / 100; // Turn 5% into .05. $total = ($_POST['quantity'] * $_POST['price']) * ($taxrate + 1); // Print the results. echo '<h1 id="mainhead">Total Cost</h1> <p>The total cost of purchasing ' . $_POST['quantity'] . ' widget(s) at $' . number_format ($_POST['price'], 2) . ' each, including a tax rate of ' . $_POST['tax'] . '%, is $' . number_format ($total, 2) . '.</p><p><br /></p>'; } else { // Invalid submitted values. echo '<h1 id="mainhead">Error!</h1> <p class="error">Please enter a valid quantity, price, and tax.</p><p><br /></p>'; } } // End of main isset() IF.// Leave the PHP section and create the HTML form.?><h2>Widget Cost Calculator</h2><form action="calculator.php" method="post"> <p>Quantity: <input type="text" name="quantity" size="5" maxlength="10" /></p> <p>Price: <input type="text" name="price" size="5" maxlength="10" /></p> <p>Tax (%): <input type="text" name="tax" size="5" maxlength="10" /></p> <p><input type="submit" name="submit" value="Calculate!" /></p> <input type="hidden" name="submitted" value="TRUE" /></form><?phpinclude ('./includes/footer.html');?>
Now you only need to make them "sticky".

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.