Jump to content

need help posting php to a php file (page creation feature for template)


blesseld

Recommended Posts

Hey,

 

I am trying to build a feature into my template that will automatically setup a page without having to create a file and paste the 5 lines of code, and then switch the page number automatically then upload it to the server....

 

No database either.

 

this is what needs to be added into the file inorder for it to work as a page:

<?php
$page_num = "1";
$pathtometa = $_SERVER["DOCUMENT_ROOT"].'/inc/meta.php';
include ("$pathtometa");
include ("$var/global-control.php");
include ("$var/page.php");
?>

 

I can create a file and post to it...but I need exactly what's above

 

        $createcontent = stripslashes($_POST['createcontent']);
        fwrite($fp, $createcontent);
        fclose($fp);

        $filename = "createdfile.php";
        $filehandle = fopen($filename, 'w') or die("can't open file");


        if ($filehandle) {

            fwrite($filehandle, $createcontent);


            fclose($filehandle);
        }

 

any help would be appreciated

 

thanks

 

 

Link to comment
Share on other sites

This entire process defeats the purpose of using a language like php to create dynamic websites.

 

Is the reason your doing things this way because you don't have access to a database? What about sqlite which is built into php5?

Link to comment
Share on other sites

The Users of the template only need simple 5 page sites, and some of them don't have access to a db,  plus it's not needed,  I am just providing the tool....

 

I posted to soon...  here is what I am working with now

$string = '<?php  
$page_num = "'. $_POST["set_page_num"]. '"; 
$pathtometa = "'. $_POST["setpathtometa"]. '"; 
include ("'. $_POST["incvar1"]. '"); 
include ("'. $_POST["incvar2"]. '"); 
include ("'. $_POST["incvar3"]. '"); 
?>';
$fp = fopen("content-page-create-page.php", "w");
fwrite($fp, $string);
fclose($fp); 

Link to comment
Share on other sites

This is what should end up in the file

 

<?php
$page_num = "1";
$pathtometa = $_SERVER["DOCUMENT_ROOT"].'/inc/meta.php';
include ("$pathtometa");
include ("$var/global-control.php");
include ("$var/page.php");
?>

 

 

domain.com/index.php

 

the users are beginners and people that don't know any code...let alone setup a database... so the idea is to build a create page feature so they don't have to create new files and copy the code above,  of course they would need to change the page number save the file then upload to the server

 

domain.com/about.php    <--page num = 2

<?php
$page_num = "2";
$pathtometa = $_SERVER["DOCUMENT_ROOT"].'/inc/meta.php';
include ("$pathtometa");
include ("$var/global-control.php");
include ("$var/page.php");
?>

 

Here is the first page

 

<?php
if ($loggedin) {
        echo <<< _END
<div class="clear"></div>
<form method="post" action="admin-create-page-1.php">
    <ul class="edit-form">
        <li><label class="label">Title</label><br /><input class="text" type='text' maxlength='300' name='createcontent' value='$createcontent' /></li>
        <li><label class="label">Title</label><br /><input class="text" type='text' maxlength='300' name='createcontent1' value='$createcontent1' /></li>
        <li><label class="label">Title</label><br /><input class="text" type='text' maxlength='300' name='createcontent2' value='$createcontent2' /></li>
        <li><label class="label">Title</label><br /><input class="text" type='text' maxlength='300' name='createcontent3' value='$createcontent3' /></li>
        <li><label class="label">Title</label><br /><input class="text" type='text' maxlength='300' name='createcontent4' value='$createcontent4' /></li>
    </ul>
<ul class="edit-form">
	<li class="edit-form-submit"><input src="../themes/theme-admin/default-admin-template/images/meta-submit.jpg" type='image' value='createpage' name='createpage' /></li>
</ul>
</form>
_END;
} else
    header("Location: $admin_redirect");
die("");
?>

 

second page

 

<?php
if ($loggedin) {
$createcontent = stripslashes($_POST['createcontent']);
$createcontent1 = stripslashes($_POST['createcontent1']);
$createcontent2 = stripslashes($_POST['createcontent2']);
$createcontent3 = stripslashes($_POST['createcontent3']);
$createcontent4 = stripslashes($_POST['createcontent4']);

$string = '<?php  
$page_num = "'. $createcontent. '"; 
$pathtometa = '. $createcontent1. '; 
include ("'. $createcontent2. '"); 
include ("'. $createcontent3. '"); 
include ("'. $createcontent4. '"); 
?>';
$fp = fopen("content-page-create-page.php", "w");
fwrite($fp, $string);
fclose($fp); 

} else
    header("Location: $admin_redirect");
die("");
?>

 

right now it inputs the content i want in the file...

 

I guess I need to see if I can setup a couple selects to save some variable for what the file should be called and then where to store it (directory)

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.