Jump to content

How does one avoid resubmitting search results?


drayarms

Recommended Posts

You must all be familiar with those annoying messages that pop up on your screen sometimes when you try to navigate a website backwards on you browser, like this one I get on Safari:

 

Are you sure you want to resend the form again? To reopen this page, Safari must resend a form. this might result in duplicate purchases, comments or other actions.

 

On google chrome, I get this:

 

Confirm Form Resubmission

This web page requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed. Press Reload to resend that data and display this page.

I pro

So basically, I have a form which takes some inputs. Then on a second page, I process those inputs with a select query, and on the same page, display the results of the select query . Then on that display page, I have a few links which take the user to 3rd pages. When I try to hit the previous page button on one of the third pages to get back to the display page, I get those above messages and I'm required to refresh the page before my results are redisplayed. How can I avoid this. My suspicion is that this happens because i'm using the same php script to do both the processing and the displaying of the results. Any insights are appreciated.

 

If it helps, I'll include a simplified version of the page that processes the form and displays the results below.



<?php

//address error handling

ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);


//authenticate user
require('auth.php');






echo'                   <div id="content" class=""> ';





                                                if (isset($_POST['submitted'])) {

                                                        // Connect to the database.

                                                        require_once ('config.php');

                                                        //Query the database.

                                                        $sql = "SELECT * FROM members INNER JOIN images ON members.member_id = images.member_id WHERE members.ethnicity = '{$_POST['ethnicity']}' AND images.image_cartegory = 'main'  ";



                                                        $query = mysql_query($sql);



                                                        //Check for success here.

                                                        if(!$query)

                                                        {

                                                                die('<p>Could not retrieve the data because: <b>' . mysql_error(). '</p>');

                                                                // Handle as desired

                                                        }else{  //If query is valid.

                                                                if(mysql_num_rows($query) > 0){

                                                                        
                                                                        
                                                                        //Retrieve each record.

                                                                        while ($row = mysql_fetch_assoc($query)){ 

                                                                        //Define variables to be passed via url.

                                                                        $friend= $row['member_id'];

                                                                                

                                                                        //Print the records.


                                                                        echo"

                                                                        


                                                                        

                                                                
                                                                        //Make sure an uploaded photo is present.  if ($row['image'] !== NULL) {

                                                                        echo"<a href='friend.php?friend=$friend' >";



                                                                        // Note that we are building our src string using the filename from the database.

                                                                        echo "<img src=\"images/" . $row['image'] . "\" width=\"140\" maxheight=\"154\" />";    

                   

                                                                        echo "</a>";   


                                                                        echo"<h2 style= 'position:relative;bottom:25px;'>" .$row['username']. "</h2>";


                                                        
                                                                        //End of if there is an uploaded pic.} 
                                                                        

                                                                        
                                                                        }//End of while loop.



                         

                                                                }else {//No rows returned. End of if number of rows is greater than 0 loop.

        
                                                                        echo 'No results match this search query.' ;

                                                                        }

                                                        }//End of else if query is valid.

                                                }//End of if form is submitted statement.




echo'                                           

                                

                        

                        </div> <!--closes content-->      ';








?>



Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.