Professional Web Applications Themes

Reloading a page - PHP Development

You're asking a javascript question in a PHP newsgroup? Try this instead of your script. <html> <body onLoad="javascript :window.location('http://www.abc.com/abc.php');"> </body></html> I usually use window.location instead of .reload. Steve Robbins <srobbinsno.spam.charter.net> wrote in news:slrnbgmc28.ttq.srobbinslocalhost.localdomain : > > I am putting a page together that has two text boxes, a button, and a > table that shows the content of a table. When the button is clicked, > the content of the text boxes is written to the database and the page > should be redrawn with the new content of the table. Simple enough. > > My problem is that when ...

  1. #1

    Default Re: Reloading a page

    You're asking a javascript question in a PHP newsgroup?

    Try this instead of your script.
    <html>
    <body onLoad="javascript:window.location('http://www.abc.com/abc.php');">
    </body></html>


    I usually use window.location instead of .reload.



    Steve Robbins <srobbinsno.spam.charter.net> wrote in
    news:slrnbgmc28.ttq.srobbinslocalhost.localdomain :
    >
    > I am putting a page together that has two text boxes, a button, and a
    > table that shows the content of a table. When the button is clicked,
    > the content of the text boxes is written to the database and the page
    > should be redrawn with the new content of the table. Simple enough.
    >
    > My problem is that when the button is clicked, I get the text boxes
    > cleared and the old data in the table. If I reload the page manually,
    > I see the new data.
    >
    > Here is my last attempt in which I tried going to a javascript routine
    > to reload the page. This replaces trying the PHP "Header" function to
    > get the page to reload. Any suggestions on how to handle this are
    > appreciated.
    >
    > if($btnInsert)
    > {
    > $txtPage = $_POST['txtPage'];
    > $txtCommonName = $_POST['txtCommonName'];
    >
    > # the below is one line in my code but broken into two lines
    > # for the newsgroup
    > $sql = "insert into page_translate set page = \"$txtPage\",
    > commonname = \"$txtCommonName\"";
    >
    > $result = mysql_query($sql);
    > ?>
    > <script language="JavaScript" type="text/JavaScript">
    > window.reload()
    > </script>
    > <?
    > }
    >
    >
    >
    Brian Guest

  2. #2

    Default Re: Reloading a page

    On Tue, 08 Jul 2003 20:55:47 -0000, Steve Robbins
    <srobbinsno.spam.charter.net> wrote:
    >My problem is that when the button is clicked, I get the text boxes
    >cleared and the old data in the table. If I reload the page manually,
    >I see the new data.
    >
    >if($btnInsert)
    >{
    > $txtPage = $_POST['txtPage'];
    > $txtCommonName = $_POST['txtCommonName'];
    >
    > # the below is one line in my code but broken into two lines
    > # for the newsgroup
    > $sql = "insert into page_translate set page = \"$txtPage\",
    > commonname = \"$txtCommonName\"";
    >
    > $result = mysql_query($sql);
    > ?>
    > <script language="JavaScript" type="text/JavaScript">
    > window.reload()
    > </script>
    > <?
    >}
    Re-loading the page by Javascript or other means shouldn't be
    neccessary.

    Where is your query for your table in relation to the above code?




    David Mackenzie Guest

  3. #3

    Default Re: Reloading a page

    On Wed, 09 Jul 2003 13:23:02 -0000, Steve Robbins
    <srobbinsno.spam.charter.net> wrote:
    >On Wed, 09 Jul 2003 13:17:24 +0100, David Mackenzie
    ><dcmtarbrax.freeserve.co.uk> wrote:
    >> On Tue, 08 Jul 2003 20:55:47 -0000, Steve Robbins
    >><srobbinsno.spam.charter.net> wrote:
    >>
    >>>My problem is that when the button is clicked, I get the text boxes
    >>>cleared and the old data in the table. If I reload the page
    >>>manually, I see the new data.
    >>>
    >>>if($btnInsert) { $txtPage = $_POST['txtPage']; $txtCommonName =
    >>>$_POST['txtCommonName'];
    >>>
    >>> # the below is one line in my code but broken into two lines # for
    >>> the newsgroup $sql = "insert into page_translate set page =
    >>> \"$txtPage\", commonname = \"$txtCommonName\"";
    >>>
    >>> $result = mysql_query($sql); ?> <script language="JavaScript"
    >>> type="text/JavaScript"> window.reload() </script> <?
    >>>}
    >>
    >> Re-loading the page by Javascript or other means shouldn't be
    >> neccessary.
    >>
    >> Where is your query for your table in relation to the above code?
    >
    >The query is in a function that takes the results and fills a table.
    >Here it is(again the first line is word wrapped for the newsreaders):
    <snip function>

    This may seem like an obvious question, but are you querying the
    database after your insert statement above?

    --
    David (please modify address to david before replying!)
    David Mackenzie Guest

  4. #4

    Default Re: Reloading a page

    On Wed, 09 Jul 2003 15:34:59 +0100, David Mackenzie
    <dcmtarbrax.freeserve.co.uk> wrote:
    > This may seem like an obvious question, but are you querying the
    > database after your insert statement above?
    Yes. The basic layout of the page is:

    Create form.
    Draw table with db contents.

    When there is information in the text boxes and submit is clicked:
    Query to insert data
    Redraw page(Here is where I seem to be losing it as the table has all
    the old data but not the new record. If I manually reload the page, it
    is then correct).
    Steve Robbins Guest

  5. #5

    Default Re: Reloading a page

    On Wed, 09 Jul 2003 16:52:57 +0100, David Mackenzie
    <dcmtarbrax.freeserve.co.uk> wrote:
    >
    > You are querying and displaying your table before inserting the new
    > record. Move your if($btnInsert){} block to before your draw table
    > block.
    >
    > Remember that PHP is executed entirely server-side, so you don't have
    > to wait until you've outputted your form before checking the $_POST[]
    > array.
    >
    > If you check the POST vars before creating the form, you can output
    > messages to the user if the data fails any validation.
    That did it. Now to make sure I am following the logic, I believe the
    piece I didn't know was that when you click on a form button, the page
    is reloaded and processed and that is how the "if" statement related to
    the button is run.

    This was/is my first run into forms and I was wondering how the if
    statement was referenced and that would make sense.

    Thanks! If I understood that right, then I think a lot more will make
    sense now.
    Steve Robbins Guest

  6. #6

    Default Re: Reloading a page

    On Wed, 09 Jul 2003 17:23:26 -0000, Steve Robbins
    <srobbinsno.spam.charter.net> wrote:
    >On Wed, 09 Jul 2003 16:52:57 +0100, David Mackenzie
    ><dcmtarbrax.freeserve.co.uk> wrote:
    >>
    >> You are querying and displaying your table before inserting the new
    >> record. Move your if($btnInsert){} block to before your draw table
    >> block.
    >>
    >> Remember that PHP is executed entirely server-side, so you don't have
    >> to wait until you've outputted your form before checking the $_POST[]
    >> array.
    >>
    >> If you check the POST vars before creating the form, you can output
    >> messages to the user if the data fails any validation.
    >
    >That did it. Now to make sure I am following the logic, I believe the
    >piece I didn't know was that when you click on a form button, the page
    >is reloaded and processed and that is how the "if" statement related to
    >the button is run.
    >
    >This was/is my first run into forms and I was wondering how the if
    >statement was referenced and that would make sense.
    >
    >Thanks! If I understood that right, then I think a lot more will make
    >sense now.
    Once you get your head round the client-server programming model it
    becomes easier.

    I'm primarily a VB programmer and I found the event-driven model
    confusing at first but now I'm used to it.

    Good Luck!

    --
    David (please modify address to david before replying!)
    David Mackenzie Guest

Similar Threads

  1. CF MX 6.1 Adminstrator Page keeps Reloading
    By ELTON_KWEK in forum Coldfusion Server Administration
    Replies: 0
    Last Post: March 17th, 02:14 AM
  2. Explorer crashes when reloading a page
    By Peter Krempl in forum Macromedia Director 3D
    Replies: 4
    Last Post: May 24th, 01:01 PM
  3. go to anchors in HTML without reloading the page.
    By Davinci brussels in forum Macromedia Flash Actionscript
    Replies: 4
    Last Post: February 8th, 09:10 PM
  4. Without reloading the page
    By Mike Levin in forum ASP.NET Web Services
    Replies: 2
    Last Post: August 7th, 01:07 PM
  5. how to load an IMAGE without reloading the whole page?
    By murdex webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 9
    Last Post: July 28th, 11:48 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139