How to get the HTML page loaded and ready before i get the code for the current page through php?How do I use PHP to get the current year?How do I get the current date and time in PHP?How do I get PHP errors to display?How to get the client IP address in PHPHow do you parse and process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How do I reformat HTML code using Sublime Text 2?Pure JavaScript equivalent of jQuery's $.ready() - how to call a function when the page/DOM is ready for itpost form data through two php pagesCannot display HTML string

Partition error (Fdisk/Parted)

Bank loan to use as proof of funds for uk visa application

Add elements inside Array conditionally in JavaScript

Flooding vs Unknown Unicast Flooding

99 coins into the sacks

Where do 5 or more U.S. counties meet in a single point?

Using mean length and mean weight to calculate mean BMI?

Why is the episode called "The Last of the Starks"?

Is the tensor product (of vector spaces) commutative?

What is the oldest instrument ever?

GLM: Modelling proportional data - account for variation in total sample size

Employee is self-centered and affects the team negatively

What's an appropriate age to involve kids in life changing decisions?

Does this website provide consistent translation into Wookiee?

My Sixteen Friendly Students

Existence of a weight of a representation in the fundamental Weyl chamber

Is your maximum jump distance halved by grappling?

How could a civilization detect tachyons?

What happens when the drag force exceeds the weight of an object falling into earth?

Learning how to read schematics, questions about fractional voltage in schematic

Is it safe to keep the GPU on 100% utilization for a very long time?

Light Switch Neutrals: Bundle all together?

How to start your Starctaft II games vs AI immediatly?

How do I give a darkroom course without negatives from the attendees?



How to get the HTML page loaded and ready before i get the code for the current page through php?


How do I use PHP to get the current year?How do I get the current date and time in PHP?How do I get PHP errors to display?How to get the client IP address in PHPHow do you parse and process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How do I reformat HTML code using Sublime Text 2?Pure JavaScript equivalent of jQuery's $.ready() - how to call a function when the page/DOM is ready for itpost form data through two php pagesCannot display HTML string






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have two pages here. I use the first page(mpdfData.php) to get the data. And I send the data to the second page(mpdfPage.php) to create a HTML page that includes the data I have sent from the first page.



The idea is to form the second page and use it to print a PDF by converting it from HTML to PDF via the PHP code in the first page.



The problem I am facing is, when I get the HTML code of the second page back to the first, the values I have sent from page one do get displayed, instead the code itself <?php echo $user?> & <?php echo $pass?> get displayed in the target PDF.



How do I over come this?



<!-- mpdfData.php -->
<?php
$html="";
if (isset($_POST['submit']))
$user=$_POST['userName'];
$pass=$_POST["password"];
?><div hidden><?php
include 'mpdfPage.php';
?><div><?php



if ($html !== '')
require_once __DIR__ . '/vendor/autoload.php';
// Create an instance of the class:
$mpdf = new MpdfMpdf();

// Write some HTML code:
$mpdf->WriteHTML($html);

// Output a PDF file directly to the browser
$mpdf->Output();


?>

<html>
<head>
<title>User Login</title>
<link rel="stylesheet" type="text/css" href="styles1.css" />
</head>
<body>
<form name="frmUser" method="post" action="">
<div class="message1"><h2>PDF PAGE:</h2></div>
<table border="0" cellpadding="10" cellspacing="1" width="500" align="center" class="tblLogin">
<tr class="tableheader">
<td align="center" colspan="2">Enter PDF Details</td>
</tr>
<tr class="tablerow">
<td>
<input type="text" name="userName" placeholder="User Name" class="login-input"></td>
</tr>
<tr class="tablerow">
<td>
<input type="password" name="password" placeholder="Password" class="login-input"></td>
</tr>
<tr class="tableheader">
<td align="center" colspan="2">
<input type="submit" name="submit" value="Print Pdf" class="btnSubmit"></td>
</tr>
</table>

</form>
</body>
</html>


<!-- mpdfPage.php -->
<html>
<head>
<style>
table
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;


td, th
border: 1px solid #dddddd;
text-align: left;
padding: 8px;


tr:nth-child(even)
background-color: #dddddd;

</style>
</head>
<body>

<h2>HTML Table</h2>
<form name="table" method="post" action="">
<table>

<tr>
<th>User Name</th>
<th>Password</th>
</tr>
<tr>
<td><?php echo $user?></td>
<td><?php echo $pass?></td>
</tr>

</table>
</form>
</body>
</html>

<?php
$html = file_get_contents(__FILE__);
?>









share|improve this question




























    0















    I have two pages here. I use the first page(mpdfData.php) to get the data. And I send the data to the second page(mpdfPage.php) to create a HTML page that includes the data I have sent from the first page.



    The idea is to form the second page and use it to print a PDF by converting it from HTML to PDF via the PHP code in the first page.



    The problem I am facing is, when I get the HTML code of the second page back to the first, the values I have sent from page one do get displayed, instead the code itself <?php echo $user?> & <?php echo $pass?> get displayed in the target PDF.



    How do I over come this?



    <!-- mpdfData.php -->
    <?php
    $html="";
    if (isset($_POST['submit']))
    $user=$_POST['userName'];
    $pass=$_POST["password"];
    ?><div hidden><?php
    include 'mpdfPage.php';
    ?><div><?php



    if ($html !== '')
    require_once __DIR__ . '/vendor/autoload.php';
    // Create an instance of the class:
    $mpdf = new MpdfMpdf();

    // Write some HTML code:
    $mpdf->WriteHTML($html);

    // Output a PDF file directly to the browser
    $mpdf->Output();


    ?>

    <html>
    <head>
    <title>User Login</title>
    <link rel="stylesheet" type="text/css" href="styles1.css" />
    </head>
    <body>
    <form name="frmUser" method="post" action="">
    <div class="message1"><h2>PDF PAGE:</h2></div>
    <table border="0" cellpadding="10" cellspacing="1" width="500" align="center" class="tblLogin">
    <tr class="tableheader">
    <td align="center" colspan="2">Enter PDF Details</td>
    </tr>
    <tr class="tablerow">
    <td>
    <input type="text" name="userName" placeholder="User Name" class="login-input"></td>
    </tr>
    <tr class="tablerow">
    <td>
    <input type="password" name="password" placeholder="Password" class="login-input"></td>
    </tr>
    <tr class="tableheader">
    <td align="center" colspan="2">
    <input type="submit" name="submit" value="Print Pdf" class="btnSubmit"></td>
    </tr>
    </table>

    </form>
    </body>
    </html>


    <!-- mpdfPage.php -->
    <html>
    <head>
    <style>
    table
    font-family: arial, sans-serif;
    border-collapse: collapse;
    width: 100%;


    td, th
    border: 1px solid #dddddd;
    text-align: left;
    padding: 8px;


    tr:nth-child(even)
    background-color: #dddddd;

    </style>
    </head>
    <body>

    <h2>HTML Table</h2>
    <form name="table" method="post" action="">
    <table>

    <tr>
    <th>User Name</th>
    <th>Password</th>
    </tr>
    <tr>
    <td><?php echo $user?></td>
    <td><?php echo $pass?></td>
    </tr>

    </table>
    </form>
    </body>
    </html>

    <?php
    $html = file_get_contents(__FILE__);
    ?>









    share|improve this question
























      0












      0








      0








      I have two pages here. I use the first page(mpdfData.php) to get the data. And I send the data to the second page(mpdfPage.php) to create a HTML page that includes the data I have sent from the first page.



      The idea is to form the second page and use it to print a PDF by converting it from HTML to PDF via the PHP code in the first page.



      The problem I am facing is, when I get the HTML code of the second page back to the first, the values I have sent from page one do get displayed, instead the code itself <?php echo $user?> & <?php echo $pass?> get displayed in the target PDF.



      How do I over come this?



      <!-- mpdfData.php -->
      <?php
      $html="";
      if (isset($_POST['submit']))
      $user=$_POST['userName'];
      $pass=$_POST["password"];
      ?><div hidden><?php
      include 'mpdfPage.php';
      ?><div><?php



      if ($html !== '')
      require_once __DIR__ . '/vendor/autoload.php';
      // Create an instance of the class:
      $mpdf = new MpdfMpdf();

      // Write some HTML code:
      $mpdf->WriteHTML($html);

      // Output a PDF file directly to the browser
      $mpdf->Output();


      ?>

      <html>
      <head>
      <title>User Login</title>
      <link rel="stylesheet" type="text/css" href="styles1.css" />
      </head>
      <body>
      <form name="frmUser" method="post" action="">
      <div class="message1"><h2>PDF PAGE:</h2></div>
      <table border="0" cellpadding="10" cellspacing="1" width="500" align="center" class="tblLogin">
      <tr class="tableheader">
      <td align="center" colspan="2">Enter PDF Details</td>
      </tr>
      <tr class="tablerow">
      <td>
      <input type="text" name="userName" placeholder="User Name" class="login-input"></td>
      </tr>
      <tr class="tablerow">
      <td>
      <input type="password" name="password" placeholder="Password" class="login-input"></td>
      </tr>
      <tr class="tableheader">
      <td align="center" colspan="2">
      <input type="submit" name="submit" value="Print Pdf" class="btnSubmit"></td>
      </tr>
      </table>

      </form>
      </body>
      </html>


      <!-- mpdfPage.php -->
      <html>
      <head>
      <style>
      table
      font-family: arial, sans-serif;
      border-collapse: collapse;
      width: 100%;


      td, th
      border: 1px solid #dddddd;
      text-align: left;
      padding: 8px;


      tr:nth-child(even)
      background-color: #dddddd;

      </style>
      </head>
      <body>

      <h2>HTML Table</h2>
      <form name="table" method="post" action="">
      <table>

      <tr>
      <th>User Name</th>
      <th>Password</th>
      </tr>
      <tr>
      <td><?php echo $user?></td>
      <td><?php echo $pass?></td>
      </tr>

      </table>
      </form>
      </body>
      </html>

      <?php
      $html = file_get_contents(__FILE__);
      ?>









      share|improve this question














      I have two pages here. I use the first page(mpdfData.php) to get the data. And I send the data to the second page(mpdfPage.php) to create a HTML page that includes the data I have sent from the first page.



      The idea is to form the second page and use it to print a PDF by converting it from HTML to PDF via the PHP code in the first page.



      The problem I am facing is, when I get the HTML code of the second page back to the first, the values I have sent from page one do get displayed, instead the code itself <?php echo $user?> & <?php echo $pass?> get displayed in the target PDF.



      How do I over come this?



      <!-- mpdfData.php -->
      <?php
      $html="";
      if (isset($_POST['submit']))
      $user=$_POST['userName'];
      $pass=$_POST["password"];
      ?><div hidden><?php
      include 'mpdfPage.php';
      ?><div><?php



      if ($html !== '')
      require_once __DIR__ . '/vendor/autoload.php';
      // Create an instance of the class:
      $mpdf = new MpdfMpdf();

      // Write some HTML code:
      $mpdf->WriteHTML($html);

      // Output a PDF file directly to the browser
      $mpdf->Output();


      ?>

      <html>
      <head>
      <title>User Login</title>
      <link rel="stylesheet" type="text/css" href="styles1.css" />
      </head>
      <body>
      <form name="frmUser" method="post" action="">
      <div class="message1"><h2>PDF PAGE:</h2></div>
      <table border="0" cellpadding="10" cellspacing="1" width="500" align="center" class="tblLogin">
      <tr class="tableheader">
      <td align="center" colspan="2">Enter PDF Details</td>
      </tr>
      <tr class="tablerow">
      <td>
      <input type="text" name="userName" placeholder="User Name" class="login-input"></td>
      </tr>
      <tr class="tablerow">
      <td>
      <input type="password" name="password" placeholder="Password" class="login-input"></td>
      </tr>
      <tr class="tableheader">
      <td align="center" colspan="2">
      <input type="submit" name="submit" value="Print Pdf" class="btnSubmit"></td>
      </tr>
      </table>

      </form>
      </body>
      </html>


      <!-- mpdfPage.php -->
      <html>
      <head>
      <style>
      table
      font-family: arial, sans-serif;
      border-collapse: collapse;
      width: 100%;


      td, th
      border: 1px solid #dddddd;
      text-align: left;
      padding: 8px;


      tr:nth-child(even)
      background-color: #dddddd;

      </style>
      </head>
      <body>

      <h2>HTML Table</h2>
      <form name="table" method="post" action="">
      <table>

      <tr>
      <th>User Name</th>
      <th>Password</th>
      </tr>
      <tr>
      <td><?php echo $user?></td>
      <td><?php echo $pass?></td>
      </tr>

      </table>
      </form>
      </body>
      </html>

      <?php
      $html = file_get_contents(__FILE__);
      ?>






      php html






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 7:26









      GauthamKGauthamK

      124




      124






















          1 Answer
          1






          active

          oldest

          votes


















          1














          The problem you are getting because of the file_get_contents(__FILE__) don't execute the PHP code and it will provide raw contents of the file.
          You can achieve that using the following way.



          <?php ob_start(); ?>

          <html>
          <head>
          <style>
          table
          font-family: arial, sans-serif;
          border-collapse: collapse;
          width: 100%;


          td, th
          border: 1px solid #dddddd;
          text-align: left;
          padding: 8px;


          tr:nth-child(even)
          background-color: #dddddd;

          </style>
          </head>
          <body>

          <h2>HTML Table</h2>
          <form name="table" method="post" action="">
          <table>

          <tr>
          <th>User Name</th>
          <th>Password</th>
          </tr>
          <tr>
          <td><?php echo $user?></td>
          <td><?php echo $pass?></td>
          </tr>

          </table>
          </form>
          </body>
          </html>

          <?php $html = ob_get_clean(); ?>





          share|improve this answer























          • This solved my problem. Thank you.

            – GauthamK
            Mar 23 at 10:09











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311594%2fhow-to-get-the-html-page-loaded-and-ready-before-i-get-the-code-for-the-current%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          The problem you are getting because of the file_get_contents(__FILE__) don't execute the PHP code and it will provide raw contents of the file.
          You can achieve that using the following way.



          <?php ob_start(); ?>

          <html>
          <head>
          <style>
          table
          font-family: arial, sans-serif;
          border-collapse: collapse;
          width: 100%;


          td, th
          border: 1px solid #dddddd;
          text-align: left;
          padding: 8px;


          tr:nth-child(even)
          background-color: #dddddd;

          </style>
          </head>
          <body>

          <h2>HTML Table</h2>
          <form name="table" method="post" action="">
          <table>

          <tr>
          <th>User Name</th>
          <th>Password</th>
          </tr>
          <tr>
          <td><?php echo $user?></td>
          <td><?php echo $pass?></td>
          </tr>

          </table>
          </form>
          </body>
          </html>

          <?php $html = ob_get_clean(); ?>





          share|improve this answer























          • This solved my problem. Thank you.

            – GauthamK
            Mar 23 at 10:09















          1














          The problem you are getting because of the file_get_contents(__FILE__) don't execute the PHP code and it will provide raw contents of the file.
          You can achieve that using the following way.



          <?php ob_start(); ?>

          <html>
          <head>
          <style>
          table
          font-family: arial, sans-serif;
          border-collapse: collapse;
          width: 100%;


          td, th
          border: 1px solid #dddddd;
          text-align: left;
          padding: 8px;


          tr:nth-child(even)
          background-color: #dddddd;

          </style>
          </head>
          <body>

          <h2>HTML Table</h2>
          <form name="table" method="post" action="">
          <table>

          <tr>
          <th>User Name</th>
          <th>Password</th>
          </tr>
          <tr>
          <td><?php echo $user?></td>
          <td><?php echo $pass?></td>
          </tr>

          </table>
          </form>
          </body>
          </html>

          <?php $html = ob_get_clean(); ?>





          share|improve this answer























          • This solved my problem. Thank you.

            – GauthamK
            Mar 23 at 10:09













          1












          1








          1







          The problem you are getting because of the file_get_contents(__FILE__) don't execute the PHP code and it will provide raw contents of the file.
          You can achieve that using the following way.



          <?php ob_start(); ?>

          <html>
          <head>
          <style>
          table
          font-family: arial, sans-serif;
          border-collapse: collapse;
          width: 100%;


          td, th
          border: 1px solid #dddddd;
          text-align: left;
          padding: 8px;


          tr:nth-child(even)
          background-color: #dddddd;

          </style>
          </head>
          <body>

          <h2>HTML Table</h2>
          <form name="table" method="post" action="">
          <table>

          <tr>
          <th>User Name</th>
          <th>Password</th>
          </tr>
          <tr>
          <td><?php echo $user?></td>
          <td><?php echo $pass?></td>
          </tr>

          </table>
          </form>
          </body>
          </html>

          <?php $html = ob_get_clean(); ?>





          share|improve this answer













          The problem you are getting because of the file_get_contents(__FILE__) don't execute the PHP code and it will provide raw contents of the file.
          You can achieve that using the following way.



          <?php ob_start(); ?>

          <html>
          <head>
          <style>
          table
          font-family: arial, sans-serif;
          border-collapse: collapse;
          width: 100%;


          td, th
          border: 1px solid #dddddd;
          text-align: left;
          padding: 8px;


          tr:nth-child(even)
          background-color: #dddddd;

          </style>
          </head>
          <body>

          <h2>HTML Table</h2>
          <form name="table" method="post" action="">
          <table>

          <tr>
          <th>User Name</th>
          <th>Password</th>
          </tr>
          <tr>
          <td><?php echo $user?></td>
          <td><?php echo $pass?></td>
          </tr>

          </table>
          </form>
          </body>
          </html>

          <?php $html = ob_get_clean(); ?>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 23 at 7:56









          RopAli MunshiRopAli Munshi

          800518




          800518












          • This solved my problem. Thank you.

            – GauthamK
            Mar 23 at 10:09

















          • This solved my problem. Thank you.

            – GauthamK
            Mar 23 at 10:09
















          This solved my problem. Thank you.

          – GauthamK
          Mar 23 at 10:09





          This solved my problem. Thank you.

          – GauthamK
          Mar 23 at 10:09



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311594%2fhow-to-get-the-html-page-loaded-and-ready-before-i-get-the-code-for-the-current%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해