[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

03/02/2008 at 12:20AM PST, ID: 23207219
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

Resetting the page by refreshing it

Asked by Simon336697 in PHP Scripting Language

Hi guys.
Im having a problem getting my head around why my form keeps posting if i refresh my page.

The first time i go to my page (onefile.php), it is fine.
But as soon as I enter a value in a textbox and submit it (which adds one record to a  database), and then refresh the page, I get....

In Internet Explorer....
"Internet Explorer needs to resend the information............"

and in Firefox....
"The page you are trying to view contains POSTDATA. If you resend the data, any action the form carried out will be repeated)...

Can someone please examine my script, and see:

1) If my code is missing anything
2) What should I do to my code to factor in users refreshing the page?
Is it normal to factor in this user action, and if so, what normally is good practice?

Any help greatly appreciated.

---------------------------------------------------------------------------------------------------- onefile.php
<html>

<!-- Code Start:
---------------- -->
<!-- INSERT A NEW AREA:
----------------------- -->
<form action="onefile.php" method="POST">
Insert a new area: <input type="text" name="newarea">
<input type="submit" name="submit" value="Go">
</form>

<!-- DISPLAY ALL RECORDS:
----------------------- -->
<form action="onefile.php" method="POST">
Display all records: <input type="submit" name="displayall" value="All">
</form>

</html>


<?php

      // Include our connection information to connect to mysql database
      //----------------------------------------------------------------
      include("connectioninfo.php");


      //Insert a new area into the table called areas_are
      //-------------------------------------------------
/*
      mysql_query("INSERT INTO areas_are (name_are) VALUES('$_POST[newarea]') ")  or die(mysql_error());
      echo "Data Inserted!";
      print "<br>";
*/

/*
      if(!empty($_POST[newarea])) {

              $sql="INSERT INTO areas_are (name_are) VALUES ('$_POST[newarea]')";
              echo "1 record added";
              print "<br>";
        } else {
      print "Please submit a value. A blank value is not allowed \n";
      }
*/

// First, check to see which button the user clicked on


if($_POST['displayall']) {
          echo "User clicked on the All button <br />";
      $sQuery  = "SELECT name_are FROM areas_are";
      $refResult = mysql_query($sQuery);
            while($aRow = mysql_fetch_array($refResult, MYSQL_ASSOC))
            {
                echo "Name: $aRow[name_are]<br />";
            }
      }
elseif ($_POST['submit']) {
    echo "User clicked on the Go button <br />";
   
          if(!empty($_POST[newarea])) {

              $sql="INSERT INTO areas_are (name_are) VALUES ('$_POST[newarea]')";
              mysql_query($sql) or die(mysql_error());
              echo "1 record added";
              print "<br>";
        } else {
      print "Please submit a value. A blank value is not allowed \n";
      }
   
   
}
?>
---------------------------------------------------------------------------------
[+][-]03/02/08 03:36 AM, ID: 21025645

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Sign Up Now!
Solution Provided By: Tchuki
Participating Experts: 1
Solution Grade: A
 
 
[+][-]03/02/08 06:02 PM, ID: 21028640

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 06:05 PM, ID: 21037658

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 / EE_QW_2_20070628