Results 1 to 13 of 13

Thread: PHP URL call

  1. #1
    Join Date
    Oct 2012

    PHP URL call

    Hi. I am a PHP starter and need your help. I have a form that searches a database for a report based on subject's ID number or title. The report resides on a link that has the following form:


    How to call that URL in php, so that I get the report for any ID number or title I search? Either the ID number or the title will be empty in the URL based on what the user searches. The user ID and password is the same for all users.

    I am not sure if I explained myself well, but I hope I could get some help from here.

    Thanks in advance
    Last edited by Atrisa Milani; 01-09-2013 at 03:28 AM.

  2. #2
    Join Date
    May 2006
    the netherlands
    plenty of possibilities:

    I find it very insecure though that passwords can be simply put in the url

  3. #3
    Join Date
    Oct 2007
    I agree with the warning about the password in th URL. If you contol that domain, consider changing that approach.

    You can use file_get_contents for a very simple data grab, or you can read up on cURL for a more complex interaction with the requested page.

    Is this an API of some kind, or are you scraping from an HTML page?

  4. #4
    Join Date
    Oct 2012
    Thank you both for your answers. I hid the username and password data from the URL.
    The report comes from an API and not from HTML page. In my case I guess the file_get_contents function will work fine, though I am still not there

  5. #5
    Join Date
    Oct 2012
    When searching with a specific ID number, The URI for the report with that ID gets printed in the window and not the report. This line is responsible for getting the report:

    echo getReport(getURI(($rID)));

    and then getReport function:

    function getReport ($uri) {

    $rep = file_get_contents($uri);

    return $rep;


    &uri is the URI in the form I mentioned in the first post and where the report resides. With these I get the report URI in to the frame, but not the report for that specific URI.

  6. #6
    Join Date
    Oct 2012
    I though the problem was because of the iFrames I was using, but that is not it.
    Last edited by Atrisa Milani; 01-10-2013 at 10:00 AM.

  7. #7
    Join Date
    Oct 2012
    Found the reason. Problem was not in the code, rather in our environment.

  8. #8
    Join Date
    Sep 2008
    Maybe I'm mis-interpreting the original question, but in case anyone else is reading this thread and interprets it the way I did...

    If you have a url like the one given:

    You can access those variables in PHP quite easily using $_GET.

    So, for example, if that url is used on a page to run the search, we could use code such as the following...

    mysql_query("SELECT * FROM mytable WHERE id=$id OR myvar='$myvar'");


  9. #9
    Join Date
    Oct 2012
    Thanks speghettiCode. I now get the report out.

    One question yet: the report is using Scandivian characters such as and . The report looks fine on the URL in the browser, but when I get the same report with my PHP code, those special characters are not recognized and the report looks funny. Is there a way I could define the character set in my code so that the report shows correctly?

    Also the styles and pictures in the report are missing.

    Last edited by Atrisa Milani; 01-18-2013 at 08:55 AM.

  10. #10
    Join Date
    Sep 2008
    Those characters are part of a UTF-8 character set. To set the default character set via PHP, include the following line at the top of your page:

    PHP Code:
    Also, it may be redundant, but I also include the following HTML at the top of my pages:

    HTML Code:
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
    If your database query is not pulling the information you would expect, there are several factors:
    1. table structure
    2. how the variables are encoded in the table
    3. how the variables are encoded in the query

    If you are using the code I suggested, then will be changed to &Aring; when stored in the variable (or, perhaps displayed in the report depending on how you have it set up). To reduce the risk of SQL injection it's important to use htmlentities() or something similar when using the variables in a query. However, if you need these characters displayed on the screen, you could use:

    PHP Code:
    echo html_entity_decode($myvar,ENT_QUOTES,'utf-8'); 
    Does that help?
    Last edited by speghettiCode; 01-18-2013 at 11:01 AM. Reason: added HTML meta tag

  11. #11
    Join Date
    Oct 2012
    Thanks for the reply. I have that meta tag in the first page; also tried ini_set('default_charset','UTF-8'); but still the same problem. My code looks like this:
    function getData ($url) {
        $data = file_get_contents($url);
        $data = utf8_decode($data);
        return $data;
    But this didn't help either.

  12. #12
    Join Date
    Oct 2012
    This did the trick: $data = utf8_encode($data); Looked like the data was in ISO-8859-1 and had to convert it to UTF-8. Thanks for your help so far.

  13. #13
    PHP is server side scripting language. It is use for designing web page. PHP may be deployed on most internet servers and additionally as a standalone shell on nearly each operating system.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.13971 seconds
  • Memory Usage 2,976KB
  • Queries Executed 15 (?)
More Information
Template Usage (35):
  • (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
  • (2)bbcode_code
  • (1)bbcode_html
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (13)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (13)postbit
  • (13)postbit_onlinestatus
  • (13)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 (73):
  • 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_postinfo_query
  • fetch_postinfo
  • 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
  • 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