Reputation: 597
i am working on a project where i am creating a page through php but the page when created is blank i mean with no html but what i need to do is to have html as well in that page
here is the code with the help of which i am creating the page
$ourFileName = $title.".php";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
but when the page creat i want this html to b also in that page
<div class="content">
<form action="" class="valid" method="post" enctype="multipart/form-data">
<div class="row">
<label>Title</label>
<div class="right"><input type="text" name="title" value="<?php echo $row['title'];?>"
/></div>
</div>
<div class="row">
<label>Link</label>
<div class="right"><input type="text" name="link" value="http://localhost/admin/your page name"
/></div>
</div>
<div class="row">
<label></label>
<div class="right">
<button type="submit"><span>Enter menu item</span></button>
<input type="hidden" name="hidden" />
</div>
</div>
</form>
</div>
Upvotes: 0
Views: 79
Reputation: 1156
Use include sentence:
http://php.net/manual/en/function.include.php
Remeber to use php extension when you include tags combining with html to avoid the ignoring of php code from the webserver
Upvotes: 0
Reputation: 4178
If you mean you want to combine php and html you can wrap your php into the html site, example:
<html>
<title>...</title>
<?php
echo 'this comes from php';
?>
<p>Some HTML Text</p>
<?php
echo '<b>You could also add some html tags here</b>';
?>
</html>
Make sure you save it as .php
so it gets executed by the php process.
If you want to create html files out of php you must use something like this:
<?php
file_put_contents('somefile.html', '<html>...</html>');
?>
Upvotes: 3
Reputation: 91734
If I understand the question correctly, you are using:
$ourFileName = $title.".php";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
To add the file containing the code shown in your page.
That will not work. Apart from the fact that you are opening and closing the file without doing anything with it, your included file / html contains php.
If you want the php in that file to execute, you need to include the file instead of opening and writing it:
$ourFileName = $title.".php";
include $ourFileName;
Upvotes: 0