www.webdeveloper.com
Results 1 to 10 of 10

Thread: Auto return and refresh pages

  1. #1
    Join Date
    Jul 2004
    Posts
    62

    Auto return and refresh pages

    I have seen a site developed in PHP where the user can view their member details, and if they wish to update any info, click on a 'update details' link which opens a form in a pop-up window. When the user updates the info and clicks submit in the new window, the info is updated, the pop-up window closes and the original window then re-loads to display the updated member info.

    I'd like to apply a similar process to a site I am working on, but have no idea how something like that is done. I thought it might be a javascript process running it, but there isn't any javascript on the page from what I can tell. If anyone knows how this is done, i'd love to know!

    cheers
    Cowboy Killer

  2. #2
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    379
    This is not very hard to do. Do you have experience with PHP and SQL? If you have a solid understanding of both, we can guide you through the rest.
    The beauty of code is in its simplicity.

  3. #3
    Join Date
    Jul 2004
    Posts
    62
    JayM, yeah, i have a pretty good understanding of both PHP and MySQL. I am keen to hear how it can be done!

  4. #4
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    379
    When the user clicks 'Update Info', what you do is query the SQL database with a SELECT clause, selecting the fields that you want to allow the user to edit, and assign the value of each field to a variable.

    You then display your form, with each field value displayed in the text boxes (assuming you will have them displayed in text boxes).

    Ex: <input type="text" value="<?php echo $variable_name ?>">

    The user can then change the values displayed in the form.

    Once the form is submitted, you have to query the database with the UPDATE caluse.

    Ex: UPDATE table_name SET age = 12 WHERE member_id = 02

    Hopefully this should get you started. If you need any more clarification let me know.

    Cheers
    The beauty of code is in its simplicity.

  5. #5
    Join Date
    Jul 2004
    Posts
    62
    Thanks but I really don't have a problem with updating the information. What you wrote is all pretty straight forward for me. The problem im having is knowing how to automatically refresh a page when the user returns to it. I'll clarify the process so you know what i'm trying to do.

    It starts when a user is viewing details for a certain project in their browser window. One of the parameters relating to the project is whether or not it is dependent upon a pre-existing project. If the user wants to nominate another project here, they click on a link entitled 'add' which uses javascript to open up a pop-up window displaying a list of all the existing projects. Once they have located the project they want to nominate, they click on the radio button for that project and click 'submit'. The form will action itself, and do an 'update' query, adding the nominated project id into the record for the original project.

    Now, here's the bit I am uncertain about. Once the record has been updated, the pop-up window automatically closes, returning the user to the main browser window, which then automatically refreshes displaying the updated information. I guess the real question is how does the pop-up window automatically close, and how does the original browser window know that the user has returned to it and subsequently refresh in order to display the up-to-date info?

    I was buying concert tickets online the other day from http://www.princebandroom.com.au and their site worked just like this when I updated my contact details and I thought it would be nice to replicate that for my site.

    I hope i've been clear describing this. I'm not even sure if it is PHP that is able to control this but I'd appreciate any ideas you have.
    Last edited by Cowboy Killer; 12-17-2006 at 06:45 PM.

  6. #6
    Join Date
    Jun 2006
    Posts
    472
    you can use the meta refresh tag..to refresh the page every 600 seconds
    <meta http-equiv="refresh" content="600">

  7. #7
    Join Date
    Jul 2004
    Posts
    62
    Thanks aussie girl. I know about this option, however, i don't want to refresh after a specified amount of time, only when the pop-up window closes because thats the only time any information has been changed.

  8. #8
    Join Date
    Nov 2006
    Location
    philipines
    Posts
    12
    good day friend...,
    I think you need a conditional loop, after the submit button you have to close your pop up window and loop to start.
    @lsar

  9. #9
    Join Date
    Jul 2004
    Posts
    62
    I have discovered what is needed here... I have created a conditional loop and provided it all checks out, i need to run the following:
    HTML Code:
    <script language="JavaScript" type="text/javascript">
      <!--
        opener.location.reload(true);
        self.close();
      // -->
    </script>
    This closes the pop-up window and refreshes the parent window automatically!
    Hey, thanks for all your help!

  10. #10
    Join Date
    Nov 2006
    Location
    philipines
    Posts
    12
    you are welcome friend...
    @lsar

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles