Jump to content
  • Announcements

    • boen_robot

      Guidelines and Netiquette   03/28/2017

      Posting Problems:   Having problems posting your topic? Read through this: To join, you agree to our terms and conditions and fill out and submit a registration form. An activation email will be sent to your email adress, so you'll need to verify your account. After that the account has to be validated by one of the moderators. This will mean that it can take up to a day to be activated. A couple of things to remember to ensure approval: Don't use an email address in one of those $2 four character .com domains eg. xyds.com. These will be deleted and the domain added to the banned list. Don't use an email address that is within a domain with a bad reputation for spam. A Google search is run on every email address and email domain. Don't sign up with an email address that doesn't exist, doesn't work or requires the sender to answer a quiz before their email can get to you. Put your country and or state and city in the signup form. Blank forms will go to the botton of the "to do" list. And make sure that your email address and your country match, saying you're from Alabama and using a .ru email address is not going to get you activated. After a membership is activated the first few posts will be monitored. Posting spam or unapproved topics described in the agreement results in an immediate ban. The email provider and the IP addresses associated with the account will be banned and all posts will be deleted. These strict measures have been deemed necessary to hinder spam. Sorry for any inconvenience this causes, but it's not liable to change. If, after reading this, you still can't post and don't understand why, contact one of the Moderators listed here.   Topic Guidelines   Including the following information can expedite an accurate response from board members: Must be a Specific Problem or Question related to web design and development Include Code in Question (wrap with   for small blocks of code and for longer blocks   ) Include Code Author Include Extra Notes/Modifications/Attempts Include web link to page/file when possible Content Guidelines   You may not post, upload, link to, or email any Content that contains, promotes, gives instruction about, or provides prohibited Content. Prohibited Content includes any Content that breaks any local, state, county, national or international law. Prohibited Content also includes: No direct or indirect advertising or websites, forums, products, services No hijacking of posts (do not post your question in someone elses) Content that infringes upon any rights [ex. MP3s and ROMs] (including, but not limited to, copyrights and trademarks) Abusive, threatening, defamatory, racist, or obscene Viruses or any other harmful computer software False Information or libel Spam, chain letters, or Pyramid schemes Gambling or Illicit drugs Terrorism Hacking or cheating for internet/online games Warez, Roms, CD-Keys, Cracks, Passwords, or Serial Numbers Pornography, nudity, or sexual material of any kind Excessive profanity Invasive of privacy or impersonation of any person/entity Hacking materials or information Posting Tips   There are more BBcodes than there are buttons for on the reply menu. To get the full list, click "BB Code Help" underneath the clickable smilie face menu. Use   for small snippets of code Use   for lengthy snippets of code Use   if your snippet is HTML (optional) Use   if your snippet is SQL (optional) Rules of Conduct   Be nice. There's no need for calling someone stupid if they ask an 'easy' question. Keep your avatars and signatures absolutely child friendly. We have a younger audience on this forum. Keep your language appropriate for the same reason above. Do not PM moderators for help on the forum. Post on the topic, or create a new one.   Spam:   Recently, as you have all without doubt noticed, we have had lots of spam and advertisement on the forum. Therefore, we'd like to alert you as to what to do when you have found any of the aforementioned annoying messages: it. Immediately. Give a clear reason, please, if the advertising is not evident. DO NOT POST! Report, let the post stay as is, and we will get to it, meanwhile if you continue to post as normal in the other threads, it won't be on the top so long. Refrain from PMing the member. This won't help at all, as they are most likely spambots anyway. Thank you.       Images in signatures:   After thinking of users on dial-up, we have decided to enforce the following rules regarding signatures. Please pay heed to them. Respecting these rules is respecting the members on this forum with dial-up. Signature rules: No animated images AT ALL. No matter the amount of animation. Maximum image widthxheight: 300x150 Maximum image (file) size: 15kb Use calm colors. Do not use highly contrasting images in your signature, as this can get really annoying when seeing several posts from one member in the same thread. The same prohibited content goes for images as for posts. Lastly, use common sense. No lengthy signatures please. Save us some scrolling. Thank you.       Links in signatures:   Please understand that w3schools.com only exists because of voluntary work and is barely supported by the advertising littered throughout the tutorials and the forum. So, please, stop advertising other sites. DO not post links that drive traffic away from the w3schools domain - especially to a site that offers similar if not identical information. Please help support the site by keeping individuals on it. Thank you. Here are some guidelines as to what you can put in your signature: w3schools links --> allowed w3.org links --> allowed browser links --> allowed html editor links --> allowed personal sites --> allowed tutorial sites competing with w3schools --> NOT allowed sites completely irrelevant to webprogramming and this forum --> NOT allowed   Thanks for understanding, and for taking the time to read this. ~W3Schools Modstaff~
iwato

Load Page with Filler Update

Recommended Posts

iwato    6

THE TASK:  

  1. Receive an HTTP query from an external source.
  2. Use the information from the query to obtain information from a data base
  3. Insert the information from the database into a filler page.
  4. Load the filler into the host page in such away that both appear simultaneously.

DILEMMA:

I can perform all of these tasks individually, but I am at a loss as to how to move from Step 3 to Step 4.

DISCUSSION:  I am accustomed to loading a filler into a page that is already opened.  And, I am accustomed to loading a page with information queried from a database.  Although I am pretty sure that I can call a page and load it with a filler whose content is determined by the HTTP query (Steps 1 and 4).  What I have not done and feel awkward about is filling the filler page with information from the database query before displaying both the page and the filler together.

QUESTION:  Any suggestions?

Roddy

Share this post


Link to post
Share on other sites
justsomeguy    939

I'm not really clear what you're asking.  If you're handling the request with PHP, then you can get the input data, do whatever you need with the database, load a template or something and populate it, and then I guess load another template for the rest of the page and insert the other template before sending the response to the browser.  Are you already using some kind of template engine?

Share this post


Link to post
Share on other sites
iwato    6

Thank you for responding.  I have decided to play with my idea a little before coming back. For, in this way, I will be able to ask a better question dealing specifically with code. In so doing, I may even be able to answer my own question.  

Share this post


Link to post
Share on other sites
iwato    6

JSG: 

Quote

If you're handling the request with PHP, then you can get the input data, do whatever you need with the database, load a template or something and populate it.

I have created a form page (sender.php) with a single input field.  The value of this input field is sent via a $_GET superglobal to another page (receiver.php) that:  one, retrieves all of the records from a data base; two, compares the value received from the form page (sender.php) with the values of a field of all of the retrieved records, and three, displays the receiver.php page with the value of another field of the same matched record.  Everything up to this point has now been accomplished.

JSG: 

Quote

... and then I guess load another template for the rest of the page and insert the other template before sending the response to the browser.

Indeed, this is the part that I have yet to overcome.

The displayed result (see above) is the information that should serve as a filler for another page that hosts all such form queries.

QUESTION:  How do I get the information from this filler (receiver.php) to appear in the host page with the host page when the result of the form query is sent to the filler template?

Roddy

Share this post


Link to post
Share on other sites
justsomeguy    939

This is a bit abstract, can you show your code and what you're trying to do?  What do you mean by the host page?

Share this post


Link to post
Share on other sites
iwato    6

So as to be simpler.

QUESTION ONE:  Is it possible to call a page into which the calling page is itself loaded?

QUESTION TWO: If this is possible, there is likely more than one technique available to achieve the task.  What are they?

Edited by iwato

Share this post


Link to post
Share on other sites
justsomeguy    939

Is it possible to call a page into which the calling page is itself loaded?

I'm just not sure what you mean by that.  "Call a page", do you mean get the HTML contents of a page and do something with it?  Are you saying you want to send an ajax request or something, get the response, and add it to the current page?  That's possible.

Share this post


Link to post
Share on other sites
iwato    6

Let me try one more time.

Usually, information from an external source is loaded into an HTML page that is already opened.

In my case, the HTML page in which the information is to appear is not yet opened.  What is more, the unopened page in which the processed information is to appear is used for several other purposes and cannot be easily produced from the processing PHP page that produces the information that is to appear in the HTML page.

Roddy

Edited by iwato

Share this post


Link to post
Share on other sites
justsomeguy    939

Usually, information from an external source is loaded into an HTML page that is already opened.

What are you, specifically, referring to here.  Are you talking about using Javascript to load content via ajax?  Are you talking about PHP getting data from a database, or sending a request to a remote server or something, and then using that data when it builds the response for the browser?  I'm not sure why it's significant that the source is external, I assume by external you mean a remote server separate from the web server handling the request.

In my case, the HTML page in which the information is to appear is not yet opened.

If you're saying the page isn't loaded by the browser yet, then nothing can happen until the browser sends a request for the page and gets a response from the server.

What is more, the unopened page in which the processed information is to appear is used for several other purposes

What other purposes?  What's the main purpose of this page?  

and cannot be simply produced from the processing PHP page that produces the information that is to appear in the HTML page.

Why not?

I think we're beyond the discussion of abstract concepts and it's time to get specific.

Share this post


Link to post
Share on other sites
iwato    6

OK.  We appear to have touched base here:

If you're saying the page isn't loaded by the browser yet, then nothing can happen until the browser sends a request for the page and gets a response from the server.

So, I have to

1) Get the PHP page to send a request to the user's browser to open the host HTML page.

2) Force a request from the newly opened HTML page to the PHP page.

3) Receive the response and display it in the HTML page.

This looks like AJAX.  Something that I have never used before, but appears entirely within my reach as I have some knowledge of both Javascript and JSON.

This appears to be something that I can do except for the fact that I do not know who the user is.  Once again,

The TASK

The user clicks on a link on a third party website.

An HTTP request is sent from the third party website to a PHP document hosted on my own webpage that uses the requested information to query a database and make a determination.

But, how does the PHP document know where to send the HTTP request necessary to open the host HTML page in the user's browser?

Roddy

 

Share this post


Link to post
Share on other sites
justsomeguy    939

1) Get the PHP page to send a request to the user's browser to open the host HTML page.

No, browsers send requests to the server, and the server sends a response back to the browser.  The browser initiates the connection, not the server.  The server just handles connections that get sent to it.

You use ajax when you have a page that is already open and loaded, and you want to change some content on the page from the server without refreshing the entire page.  You can see it on the forum when you submit a new post and it just adds it to the thread but doesn't refresh the entire page, it sends an ajax request to the server with the post content, the server responds with some sort of response that the Javascript is looking for (maybe HTML markup, maybe a JSON object, etc), and then the ajax callback function updates the page based on the server response.

The user clicks on a link on a third party website.

If it's on a separate domain that's going to be an issue, browsers block ajax requests to domains other than the originating domain for security reasons.  The way to bypass that is to send the ajax request to a local PHP page, which will act as a proxy to send the request to the remote server, get the response, and send it back to the originating page.  It's important to note in that case that the request to the remote server comes from the PHP server, not the user's browser.

I'm still not clear on exactly what you're trying to do.  It sounds like you just want a user to click a link on some other website, to your server.  Like, a regular link like any other link on the internet, that goes to your server, and the user's browser loads the URL on your servers and sees whatever you want them to see.  Just like any other link on any other website.  Is it any different than that?

Share this post


Link to post
Share on other sites
iwato    6
Quote

I'm still not clear on exactly what you're trying to do.  It sounds like you just want a user to click a link on some other website, to your server.

The user will click on the third-party website only if he wants.  That is his choice.  i only care about what happens after he clicks.

Quote

Like, a regular link like any other link on the internet, that goes to your server, and the user's browser loads the URL on your servers and sees whatever you want them to see.

Yes and no.

Yes, when the user clicks on the third party website, he is taken to my website, but his action does not open an HTML page, rather an invisible PHP page.  What I need to know is how get this latter page with the .php extention to open an .html page in the user's browser after it has processed the information sent to it from the third-party website.

In addition, I would like that the information processed on the PHP page be transferred to the newly opened HTML page.

Is it clear now?

Roddy 

Share this post


Link to post
Share on other sites
iwato    6

I have just discovered that I can use the PHP header( ) function with an URL as the value of the function's location parameter to open the HTML page from the PHP age.

header("Location: $url");

Ostensibly, i could append a query string to the end of the URL and then process this string on the HTML when the page opens.  Would this not require, however, that I change the extension of the HTML page from .html to .php?  Likely not a big deal as the HTML page is still in a stage of development.

Roddy

Share this post


Link to post
Share on other sites
dsonesuk    701

Unless you set html to be treated as php, then yes! you would have to change the file to php, but also instead of querystring you could use session to store data.

Share this post


Link to post
Share on other sites
iwato    6

It will be my first time to use a session, but I could see the time coming long before I started the current task.  So, now is just as good as time as any, and it looks like using a session will provide me with all of the communication that I need between the PHP and HTML pages.

Once again, Dsonesuk, you have struck home.

Many thanks!

Roddy

Share this post


Link to post
Share on other sites
Ingolme    794

HTML has no access to the PHP session data. Sessions are used to transfer data between PHP pages.

Share this post


Link to post
Share on other sites
iwato    6

Understood.  But, pages with .php extensions can display HTML.  One of my pages displays no HTML, the other does.  This is what I meant.

Thank you.

Roddy

Share this post


Link to post
Share on other sites
justsomeguy    939

It sounds like the regular use case for PHP.  You can have PHP send to the browser any content you want, PHP can output any text content like HTML, CSS, Javascript, etc, you can have it output an image, a PDF document, whatever you want.  So it sounds to me like you're describing the general use case where PHP gets some sort of post or get data as input and produces HTML as output.  You can have your HTML right in the PHP code so that it just prints whatever you tell it to, or you can have it load partial HTML templates in other files, fill in whatever data you want, and assemble the various parts into the final markup.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×