Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Senior Member
    Join Date
    Oct 2007
    Posts
    241
    Member #
    15910
    Hello,

    I have a poll form as below, called display_poll.php, that I will display at a small section of my whole page. The form sends all the data to another page called update_answers.php, which updtaes the database with the response and displays vote results. it works out fine, but update_answers page is displayed as a separate page... what i want is, when the user hits submit, I want this to be displayed in the same location of the poll, at the same location where i displayed my poll questions, and not as a separate page as right now. How to do that? I am assuming that instead of saying action=update answer" i ned to say something else, but i dont know what..


    echo "<form method=\"post\" action=\"update_answers.php\">";

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    You can have the form submit to the page itself, and then use some logic to check to see if the form is submitted.

    If not, display the form. Else: Display thanks message/whatever.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
    
    	<title>PHP POll example</title>
    
    	<meta http-equiv="content-type" content="text/html;charset=utf-8" />
    
    </head>
    
    <body>
    
    	<h1>Web page title</h1>
    
    	<p id="description">This is a poll... Lorem ipsum</p>
    
    	<div id="poll">
    
    	<?php
    
    	if(isset($_POST['submit']) == false)
    	{ ?>
    		<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    			<p>How good is beer?</p>
    			<input type="radio" name="beer" value="good" /> Good
    			<input type="radio" name="beer" value="average" /> Average
    			<input type="radio" name="beer" value="poor" /> Poor
    
    			<input type="submit" name="submit" value="Vote" />
    		</form>
    
    	<?php
    	}
    	else
    	{ ?>
    		<p>You subbmited the form.</p>
    	<?php
    	}
    	?>
    	</div>
    
    </body>
    </html>


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:59 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com