blesseld Posted July 9, 2010 Share Posted July 9, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/207205-need-help-posting-php-to-a-php-file-page-creation-feature-for-template/ Share on other sites More sharing options...
trq Posted July 9, 2010 Share Posted July 9, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/207205-need-help-posting-php-to-a-php-file-page-creation-feature-for-template/#findComment-1083360 Share on other sites More sharing options...
blesseld Posted July 9, 2010 Author Share Posted July 9, 2010 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); Quote Link to comment https://forums.phpfreaks.com/topic/207205-need-help-posting-php-to-a-php-file-page-creation-feature-for-template/#findComment-1083362 Share on other sites More sharing options...
trq Posted July 9, 2010 Share Posted July 9, 2010 Its pretty hard to tell what is part of your current code and what you want in the file. Just remember that all single quotes within a single quoted string will need to be escaped. Quote Link to comment https://forums.phpfreaks.com/topic/207205-need-help-posting-php-to-a-php-file-page-creation-feature-for-template/#findComment-1083364 Share on other sites More sharing options...
blesseld Posted July 9, 2010 Author Share Posted July 9, 2010 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) Quote Link to comment https://forums.phpfreaks.com/topic/207205-need-help-posting-php-to-a-php-file-page-creation-feature-for-template/#findComment-1083404 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.