Jump to content

eaglehopes

Members
  • Posts

    108
  • Joined

Everything posted by eaglehopes

  1. I used your code in my webpage and worked like a charm. Thanks, I did not know .htmlentities function of PHP.
  2. I have a home.html page in where I put some example XML code ( I got this code from https://www.sitemaps.org/protocol.html) : <pre><code> <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> ..... </url> <url> ..... </url> <url> ..... </url> <url> ..... </url> . . . </urlset> </code></pre> I am using PHP to include my home.html page into the main page(i.e. index.php) : ... <div><?php include "./p/home.html" ?> </div> ... In final, XML code gives error because it contains "<?" and "?>". How I used "<pre><code>....</code></pre>" and put above XML code inside it, but no success. How can I correctly show my code part in my home.html page? Thanks
  3. Thanks ginerjm. You offered gentle help. After your answer, I looked for new solution. First of all I noticed that I am completely wrong in my code since I mixed $_SESSION variables with $_COOKIE variables ... any way as you sad, my previous code is wrong and I forgot it, but write from the start. I wanted to get and embed "ready php or html pages" into main page's related tags(i.e divs etc) after clicking hyperlinks. Like using a javascript and "onclick" event of button, but with php script. Finally, I did it by using $_SESSION variables. So, my result code was in index.php file : <!DOCTYPE html> <?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); $_SESSION['page'] = ''; $_SESSION['subblog'] = ''; $_SESSION['finalPage'] = ''; $_SESSION['time'] = time(); ?> <html> <head> <link rel="stylesheet" type="text/css" href="./css/styles.css"/> <table title="" class="headPart" > <tbody > <tr > <td class="headImage" > <b class="headupperpart">MY WEB SITE</b> </td> </tr> </tbody> </table> </head> <body class="background" > <table class="bodyLayout"> <tbody> <tr > <!-- MENU ROW --> <td class="MenuTag" > <a class="button" href="./index.php?page=home" target="_self">Home</a> <a class="button" href="./index.php?page=about" target="_self">About</a> <a class="button" href="./index.php?page=blog" target="_self">Blog</a> </td> </tr> <!-- end of the MENU row --> <?php if(isset($_GET["page"]) ) { $_SESSION["page"]=$_GET["page"]; } if (isset($_GET["subblog"]) ) { $_SESSION["subblog"]=$_GET["subblog"] ; } if( isset($_GET["fin"] ) ) { $_SESSION["finalPage"]=$_GET["fin"]; } // if user request blogs- then show blog menu here if ( strcmp($_SESSION["page"],"blog")==0 ) { // create new menu //if ( strcmp($_COOKIE['page'],"blog")==0 ) { // create new menu if( isset($_SESSION["subblog"]) ) { // if subblog is selected // create subblog menu and put it in new row // while the blog menu bar remains open, get the selected subblogId (short id) & read "sub blog's sub menu file:subcats file" // create new final menu - three depth menu system echo '<tr><td class="MenuTag">'; loadSecondLevelMenu() ; echo "</td></tr>"; echo '<tr><td class="MenuTag">'; // loadThirdLevelMenu($subblog) ; loadThirdLevelMenu($_SESSION["subblog"]) ; echo "</td></tr>"; } else { // subblog is empty echo '<tr><td class="MenuTag">'; loadSecondLevelMenu(); echo "</td></tr>"; } } function loadThirdLevelMenu($id) { if( (include './pages/blog/subCat.php') == TRUE ) { // do nothing since it loads page inside above "if statement" automatically } else { echo "subCat page Load error..."; } } function loadSecondLevelMenu() { if( (include './pages/blog/categories.php') == TRUE ) { // do nothing since it loads page inside above "if statement" automatically } else { echo "categories page Load error..."; } } ?> </tbody> </table> </body> </html> and in subCat.php (abbreviation of subCategory) <?php $subCat=$_SESSION['subblog']; // do something with sended variable changed into local variable of $subCat ?> And I have managed to work with this combination. Thanks again for your kindness. If you do not mind, I do not waste nobody's time about my problem since I have managed to solve it. In the future, I want to reserve "help token" you offered me, and spend it for other questions I will ask. if you accept of course !
  4. Thanks ginerjm it helped much. After using setcookie I need to refresh page, I understood that. So, after your answer, I could not any method of PHP to refresh page after setting cookie for instance other than header("Refresh:<time>"). Howevere it is not the solution I am looking for I think, it is continously refresh the main page ... I think I should return to the use GET method to do what I try to do : change a page ..
  5. I used below code in my website : <!DOCTYPE html> <?php //$page="home"; error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); $_SESSION['page'] = 'home'; $_SESSION['subblog'] = 'CP'; $_SESSION['finalPage'] = ''; $_SESSION['time'] = time(); ?> <html> <head> <link rel="stylesheet" type="text/css" href="./css/styles.css"/> <table title="" class="headPart" > <tbody > <tr > <td class="headImage" > <b class="headupperpart">MY WEB SITE</b> </td> </tr> </tbody> </table> </head> <body class="background" > <table class="bodyLayout"> <tbody> <tr > <!-- MENU ROW --> <td class="MenuTag" > <a class="button" href="./index.php?page=home" target="_self">Home</a> <a class="button" href="./index.php?page=about" target="_self">About</a> <a class="button" href="./index.php?page=blog" target="_self">Blog</a> </td> </tr> <!-- end of the MENU row --> <?php if(isset($_GET["page"]) ) { setcookie("page",$_GET["page"]); } if (isset($_GET["subblog"]) ) { setcookie("subblog",$_GET["subblog"] ); } if( isset($_GET["fin"] ) ) { setcookie("finalPage",$_GET["fin"]); } if ( strcmp($_COOKIE['page'],"blog")==0 ) { // create new menu if( isset($_COOKIE['subblog']) ) { // if subblog is selected // create subblog menu and put it in new row echo '<tr><td class="MenuTag">'; loadSecondLevelMenu() ; echo "</td></tr>"; echo '<tr><td class="MenuTag">'; loadThirdLevelMenu($_COOKIE['subblog']) ; echo "</td></tr>"; } else { // subblog is empty echo '<tr><td class="MenuTag">'; loadSecondLevelMenu(); echo "</td></tr>"; } } function loadThirdLevelMenu($id) { if( (include './pages/blog/subCat.php') == TRUE ) { // do nothing since it loads page inside above "if statement" automatically } else { echo "categories page Load error..."; } } function loadSecondLevelMenu() { if( (include './pages/blog/categories.php') == TRUE ) { // do nothing since it loads page inside above "if statement" automatically } else { echo "categories page Load error..."; } } ?> </tbody> </table> </body> </html> I tried to use $_COOKIE[] array to pass the menu link data between all pages in the server. I changed cookies with hyperlinks so I sent new variables to page with GET method. It works but not as I expected ! I need to click twice for buttons to set the cookies(i.e that are setted in $_GET[<cookiename>]). Why ? How can I convert it to : "once I clicked the button it changes getted variable and set it to coookie variable" ? Any help or guide is appreciated... Edited : I deleted unused javascript from code...
  6. Thanks requinix ! It happens exactly as you said : my resource is a book and it says that "PHP initialize $page variable automatically". It also says that use $HTTP_GET_VARS["varname"] to get the sended variable ! So I had to research extra documents to find that all of them depreceated. Time to change resource as you said :)
  7. Ok ! I found the answer in answer . It says that, I forgot to get the variable passed by using $_GET["page"] . So below code solved my problem $page=$_GET["page"];
  8. Hi to all ! I have a web page whose main page is index.php I try to use passing data inside embedded URLs : my code is below : <!DOCTYPE html> <html> <body class="background" > <div> <a class="button" href="./index.php?page=home" target="_self">Home</a> <a class="button" href="./index.php?page=about" target="_self">About</a> <a class="button" href="./index.php?page=blog" target="_self">Blog</a> </div> <div> <?php include 'db.inc'; echo "page selected is ". $page ."\n"; // if user request blogs- then show blog menu here if ( strcmp($page,"blog")==0) { // get new menu from file echo "YEKEKE ". $page ."is blog"; if( include ('./pages/blog/categories/categories.php') == TRUE ) { // do nothing } else { echo "Page Load error..."; } } else { echo "try out"; } console.log($page."is blog"); ?> </div> </body> </html> However, it does not work since I could not get $page variable correctly, I get $page as blank variable. Why, where is my mistake? Any help is appreciated. Edit : I try to do that : 1. user click link in index.php page 2. get the new page inside index.php with sended value of the $page variable...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.