Asked  2 Years ago    Answers:  5   Viewed   75 times

I have a site architechure where I assign content to variables and then print them in a master page. My problem is that php code in the sub pages is imported into the variables as strings. Is there anyway to make sure that the code is actually executed and the results is imported in the variables instead?

In the example below the php code in signup_header.php is imorted as a string to $page_header. The result is that "getVerifiedEmail(); ?>" is displayed in the form element instead of the e-mail address.

master.php

<!DOCTYPE HTML>
<html>
<head>
    <?php echo $page_header; ?>
</head>

<body id="home">
    <div class = "container">
       <?php echo $page_content; ?>
    </div>
</body>
</html>

signup.php:

<?php
    $page_content = file_get_contents("./include/signup_content.php");
    $page_header = file_get_contents("./include/signup_header.php");
    include('master.php');
?>

signup_header.php

<script type="text/javascript">
   $(document).ready(function(){
   $('input[name="name"]').attr('value', "<?php echo $idpAssertion->getVerifiedEmail(); ?>");
    });        
</script>

signup_content.php

<section>
    <form class="task" method="POST">
        Name: <input type="text" name="name" maxlength="30" value=""/><br/>
        Email: <input type="text" name="email" value=""/><br/>
        UserId: <input id="userId" type="text" name="userId" value="" /><br/>
    </form>
</section>

 Answers

5
<?php
    $page_content = "./include/signup_content.php";
    $page_header = "./include/signup_header.php";
    include('master.php');
?>

and

<!DOCTYPE HTML>
<html>
<head>
    <?php include $page_header; ?>
</head>

<body id="home">
    <div class = "container">
       <?php include $page_content; ?>
    </div>
</body>
</html>

that's all

I hope that signup_content.php contains the similar template only

Thursday, September 29, 2022
3

Your form is using a POST method already, so I will start with that. It means using your submit button as a real HTML submit button (ie drop the onclick event). Then add a onsubmit handler to your post:

<form name="printView" method ="post" action="printOnly.php" target="popUp" onsubmit="popup(this);">

Add this function in your Javascript to create the popup, and then submit the form to it:

function popup(form) {
    window.open('', 'formpopup', 'view text','menubar=yes,scrollbars=yes,resizable=yes,width=640,height=700');
    form.target = 'formpopup';
}
Tuesday, September 6, 2022
 
1

You must enable php! Check the folder mods-enabled in the Apache directory (default: /etc/apache2/) to see if you find a file named php. I don't remember the extension but I think it's .so.

Also check in /var/log/apache2/error.log to see if you have any other errors.

Monday, November 7, 2022
 
4

Readfile will read the file directly into the output buffer, and file_get_contents will load the file into memory, when you echo the result the data is copied from memory to the output buffer effectively using 2 times the memory of readfile.

Saturday, October 1, 2022
4

Here's another way using Visual Studio: If you do New Item in Visual Studio and you select Web Form, it will create a standalone *.aspx web form, which is what you have for your current web form (is this what you did?). You need to select Web Content Form and then select the master page you want attached to it.

Wednesday, October 12, 2022
 
rodix
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 

Browse Other Code Languages