Need PHP Help

thedigit2s

Well-known member
  • Oct 3, 2009
    2,726
    3,105
    113
    37
    @ katubedda
    PHP Hedder (Location:index.php) කමාන්ඩ් එක use කරල up Directory එකේ තියෙන file එකක් load කරන්නේ කොහොමද?

    තව දුරටත් ප්‍රශ්නේ තේරෙන විදිහට අහනවා නම් මගේ public_html එකේ index.php file එකේ ඉදලා connection කියන folder එකේ check.php file එක load කරනවා නම් , check.php ෆයිල් එක ඇතුලේ ඉඳගෙන ආපහු index.php එකට යන්නේ කොහොමද?
     
    • Like
    Reactions: NipunaDDDD

    aaa1111

    Member
    Sep 19, 2012
    43
    4
    0
    Udinma include karnna puluwan neda check.php eka index.php athule..
    Poddak "include php" kiyala google karapan,ona syntax ewi ..
     
    • Like
    Reactions: thedigit2s

    Lakshan-Seram

    Well-known member
  • May 31, 2011
    24,718
    12,629
    113
    127.0.0.1:8080/Kandy
    load කරනවා නම්
    PHP:
    include();
    include_once();
    require();
    require_once();
    header location eka redirect ekak (302) eken karanna ba

    index eken page loader ekak nam one

    HTML:
    index.php?page=check.php
    PHP:
    <?php
    if( isset($_GET['page'])&& $_GET['page'] != '' ) {
      $page = $_GET['page'];
      header('Location: '.$page);
    }
    
    // Index.php contents here. Load without ?page=check.php
    ?>
     
    Last edited:
    • Like
    Reactions: thedigit2s

    thedigit2s

    Well-known member
  • Oct 3, 2009
    2,726
    3,105
    113
    37
    @ katubedda
    Udinma include karnna puluwan neda check.php eka index.php athule..
    Poddak "include php" kiyala google karapan,ona syntax ewi ..

    අනේ මචෝ load කරනවා කිවුවේ මට එ directry එක ඇතුලේ තියෙන file එක browser එකට load කරලා ආයෙමත් එක ඇතුලේ ඉඳලා ආපස්සට යන එක මචෝ:(:(:( include seen එකෙන් මට ඔනි විදිහට වැඩේ කරගන්න බැ:(:(:(
     

    NipunaDDDD

    Well-known member
  • Jan 16, 2009
    1,556
    120
    63
    Ubata one parent directory eke file ekak load karaganda neda?

    Ehenam mehema karanam hari. :)

    PHP:
    include("../index.php");
     
    Last edited:
    • Like
    Reactions: thedigit2s

    thedigit2s

    Well-known member
  • Oct 3, 2009
    2,726
    3,105
    113
    37
    @ katubedda
    PHP:
    include();
    include_once();
    require();
    require_once();
    header location eka redirect ekak (302) eken karanna ba

    index eken page loader ekak nam one

    HTML:
    index.php?page=check.php
    PHP:
    <?php
    if( isset($_GET['page'])&& $_GET['page'] != '' ) {
      $page = $_GET['page'];
      header('Location: '.$page);
    }
    
    // Index.php contents here. Load without ?page=check.php
    ?>

    අනේ මචෝ උඔ කියන දේ මට තේරෙන්නේ නැ..:sorry::sorry::sorry::sorry::sorry:
     

    Lakshan-Seram

    Well-known member
  • May 31, 2011
    24,718
    12,629
    113
    127.0.0.1:8080/Kandy

    Lakshan-Seram

    Well-known member
  • May 31, 2011
    24,718
    12,629
    113
    127.0.0.1:8080/Kandy


    Ekanam danne ne ban. Aruta one kiyapu vidiyata mata teruna vidiyata kiwwe :)

    Uta one kiwwe aye parent directory eke tiyena file ekata yandane itin mama e code eka dunna :)

    pora index eke inda anith page ekata kalin yanawa ne.. so, me code eken aye back wenna try karoth aye index eken redirect wenawa kalin page ekata.. so, end wenne neti loop ekak awith crash wenawa.
     

    thedigit2s

    Well-known member
  • Oct 3, 2009
    2,726
    3,105
    113
    37
    @ katubedda
    ara php code eka index.php ekata danna..

    itapasse index.php eka normal wisit karanna puluwan.. http://domain.com/index.php

    mekedi load wenne index.php eka.. wena file ekak load karanna redirect karanna one nam

    http://domain.com/index.php?page=whatever/page.php eken puluwan.

    හරි මචෝ පොඩ්ඩක් තේරුනා :):)

    දැන් එතකොට whatever/page.php එක ඇතුලේ මෙහෙම code එක ලියලා index.php වලට යන්න එක හරිද?
    PHP:
     if($page==1)header("location:index.php");
     

    thedigit2s

    Well-known member
  • Oct 3, 2009
    2,726
    3,105
    113
    37
    @ katubedda
    meken redirect loop ekak enne..


    ඔවු දාපු ගමන් rederect වෙන්න පටන් ගත්තා. එක පාරක් එ page එකට ගිහින් ආවට පස්සේ අයෙමත් එකට යන්නේ නැතිවෙන් session variable එකක් හදලා වැඩේ ගොඩ දාගත්තා.

    page වල එහෙට මෙහෙට යන්න වෙනම theory තියෙනවද මචෝ.:confused::confused::confused:
    මම පිලිවෙලකට මෙවා ඉගෙන ගත්ත මිනිහෙක් නෙවෙයි. google දෙයියන්ගෙන් තමයි ඉතින් ගොඩක් වෙලාවට ගොඩයන්නේ. එ වුනාට සමහර තැන්වලදි line 50 ක් විතර දිග code එකක් line 3 කින් විතර කරගන්න පුළුවන් කියලා පස්සේ තමයි තේරෙන්නේ.
     

    joshmiller

    Well-known member
  • Feb 23, 2014
    3,305
    220
    63
    pitarata
    require() - will suppress errors when file not found
    include() - will not display any error when file is not found


    you can also use require_once(),include_once()
     
    • Like
    Reactions: thedigit2s

    joshmiller

    Well-known member
  • Feb 23, 2014
    3,305
    220
    63
    pitarata
    ඔවු දාපු ගමන් rederect වෙන්න පටන් ගත්තා. එක පාරක් එ page එකට ගිහින් ආවට පස්සේ අයෙමත් එකට යන්නේ නැතිවෙන් session variable එකක් හදලා වැඩේ ගොඩ දාගත්තා.

    page වල එහෙට මෙහෙට යන්න වෙනම theory තියෙනවද මචෝ.:confused::confused::confused:
    මම පිලිවෙලකට මෙවා ඉගෙන ගත්ත මිනිහෙක් නෙවෙයි. google දෙයියන්ගෙන් තමයි ඉතින් ගොඩක් වෙලාවට ගොඩයන්නේ. එ වුනාට සමහර තැන්වලදි line 50 ක් විතර දිග code එකක් line 3 කින් විතර කරගන්න පුළුවන් කියලා පස්සේ තමයි තේරෙන්නේ.


    redirecting user to another page ?
    header("LOCATION:page.php");

    or

    can use javascript as well

    echo "<script>window.location = 'http://www.google.com';</script>";