Jul 26, 2008

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

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > HTML, XML etc..

free web hosting

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

sonesay
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.

CODE
// 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.
CODE
<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.


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.

 

 

 


Reply

shadowx
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?

Reply

jlhaslip
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://www.peachpit.com/articles/article.a...qNum=2&rl=1

Sample of the Redux method here:
CODE

<?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>
<?php
include ('./includes/footer.html');
?>


Now you only need to make them "sticky".

 

 

 


Reply

sonesay
Thanks for help guys I think hidden field will do the trick I will use 1 hidden field to hold the application ID which should work out fine.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:


Searching Video's for multiple, voting, post, methods, multiple, voting, post, methods, 1, page
advertisement



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



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE