Results 1 to 10 of 10

Thread: How do I stop loading php page?

  1. #1
    Join Date
    May 2014

    How do I stop loading php page?

    I have an HTML page (mypage.com/index.html) which calls a php page (mypage.com/task.php)..

    When index executes the php page the browser ends up on my page.com/task.php which I don't want.

    I have a form on the main page with graphics, menus, etc. I don't want the visited to leave that main page after the hit the submit button on the form. How do I stop the browser leaving the calling page when it calls a php page? I want this to happen in the background.


  2. #2
    Join Date
    Jul 2013
    Voorheesville NY USA
    I'm confused about your page names. Are the pages REALLY 'named' : mypage.com/index.html. Normally a web page is named something like "index.html" or "task.php".

  3. #3
    Join Date
    May 2014
    No, Im just using that as an example. Here is the sequence...

    I go to the main /index.html page (home page) which has a simple form for input.
    I enter a string and hit the submit button.
    The index page sends that info to my /task.php page on the server which posts the input to
    mysql also on the server.
    The php page sends an echo (only because I programmed an echo in there which may be the
    problem) which prints on a new browser page, taking me off the original main page.

    I want to make sure that when someone hits the submit button on the main page that they dont leave the main page.

    Now here are my thoughts. I suppose if I program php to return some html info it will have to put it on a new page. However, if the php page sends no html info maybe it will have no reason to leave the original calling page.

    I will have to remove that echo statement and test that theory. What are your thoughts. Am I thinking right?


  4. #4
    Join Date
    Jul 2013
    Voorheesville NY USA
    Thinking purely about design here......

    The index page (by default) is usually the main page of a 'site'. You have picked up on that by naming your first page 'index.html'. Question is - is there any php in this page? If not you have made it a tad more complicated to get some dynamic content to show up there. Moving on tho - having a main page like 'index.html' gives you a landing place on the web for your entire site, no? So - how much individual functioning do you want this page to do for you? As you add to your site, you're going to be wanting to have other pages appear to your users, not just the index. In your question above, perhaps (perhaps!) you might want to move that input form from your main page (index.html) to a page created to handle that input and let task.php send the form, wait for it, receive and process it (and any errors) and have a 'return' button on the task.php screen to send you back to the index.html screen. And repeat that scenario when you come up with task #2.

    Just my $.02

  5. #5
    Join Date
    May 2014
    That IS good advise and I thank you for the idea. My issue is this...why does the entire process take me away from the main index.html page (or it could be any secondary page for that matter). What is it about the execution of that php code that sends me to a second page (the one that prints the echo I put in there). The more I think about it the more I suspect it's the echo statement itself. It sends that back to the browser and the browser must print it and it creates a new page.

    Therefore Im thinking that if I remove the echo statement or any other html sent back to the browser from the php code then the browser wont have to display a new page and the visitor never leaves the page they were on...unless I want them to.

    Im just thinking out loud now, now that I suspect the echo statement. That why I am wondering what someone thinks of my rationale. I havent been able to get to the computer to test this yet so I wont know till tonight if Im right.

    thanks for any input

  6. #6
    Join Date
    Jul 2013
    Voorheesville NY USA
    If you look at your html in the first page you have an action= attribute of your form tag that SENDS you to a new page. You are the one introducing the second page and you are doing nothing to send it back to the first page. If you really MUST send yourself back to the first page, either move your php into the first page (and rename it to a php file or modify your configuration to parse html files (not a good idea)) and process it all in the first page, or use the Header command (look it up) in the second page to redirect control back to the first page.

  7. #7
    Join Date
    May 2014
    Yeah, I didnt realize I was actually sending the browser to the php page. I thought the php page operated in the background of the server and only if I coded the php page to send back html that the html would show.

    I didnt realize that when I call the php page that I actually force the browser to leave the calling page. I thought that it was like calling a function located in a different file. I thought I call the php page which executes it's code in server side background and thats all. My mistake.

    Ok, then IS there a way to call server side functions (scripts, etc) that do not force me to leave the page calling the server scripts. ASP maybe?


  8. #8
    Join Date
    May 2014
    By the way...how would I send it back to the main page...just include an href to the url maybe?


  9. #9
    Join Date
    Jul 2013
    Voorheesville NY USA
    When you call anything, be it from the address bar of your browser, or from a form tag of your html, or an anchor tag, or a header command, you are sending data and control to a script or html page. If it's an html page, you are basically just asking for that page to be displayed. If it is a script (ending in .php) then the webserver (?) opens that file on your server who then sees it is a .php file and parses the php code in there and produces whatever that script is designed to do. What a php script usually does is do some input processing (using the input from the screen just seen) and then send some results back to the client, all under the guise of that script's name. There is no 'conversation' between the page you see on your screen at the time you click and anything on the server. There is simply a packet sent to the server to be handled and then another packet sent back to the client afterwards. (Generally!)

    If you want to keep the scenario you have now, you will have to do what I suggested in my last post. It might involve some research on your part (as I said) but it will be good for you to read some of this stuff.

  10. #10
    Join Date
    May 2014
    You could do your request by AJAX, which is the cleanest but more complex method.

    or you could do an auto redirect from task.php once all the processing is complete, which would be simpler for a newbie.

    If there is any echo, error, any output what-so-ever the following code will not work and will give an error similar to "ERROR: headers already sent".

    PHP Code:
    header('Location: /index.html');

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11005 seconds
  • Memory Usage 2,934KB
  • Queries Executed 13 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (10)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates