krisw44 Posted October 11, 2012 Share Posted October 11, 2012 Ok, so I have a site that I am building, with a content manager. In the content manager i am putting some php code to display in the page. Here is the holder for the page content: <div id="contentholder" class="yesprint"> <div id="innercontent"> <?php echo $row['content']; ?> </div> </div> Here is the code that is getting loaded as $row['content']: <form name="qform" id="qform"> <input type="text" name="p19q2" value="<?php echo $valarr['p19q2']; ?>"/><br/> <input type="text" name="p19q3" value="<?php echo $valarr['p19q3']; ?>"/><br/> <input type="text" name="p19q4" value="<?php echo $valarr['p19q4']; ?>"/><br/> <input type="radio" name="p19q5" value="123" <?php if($valarr['p19q5'] == '123'){ echo 'checked="checked"'; } ?>/>123 <input type="radio" name="p19q5" value="456" <?php if($valarr['p19q5'] == '456'){ echo 'checked="checked"'; } ?>/>456<br/> <input type="text" name="p19q6" value="<?php echo $valarr['p19q6']; ?>"/><br/> <textarea type="textarea" cols="30" name="p19q7" rows="7"><?php echo $valarr['p19q7']; ?></textarea><br/> </form> <button type="button" onclick="saveXML()">Save</button> It is currently showing the php code in the value tags as the value for each input, instead of processing the php. If I copy the source code and run it alone it works fine though. Here is the combined source snippet: <div id="contentholder" class="yesprint"> <div id="innercontent"> <form name="qform" id="qform"> <input type="text" name="p19q2" value="<?php echo $valarr['p19q2']; ?>"/><br/> <input type="text" name="p19q3" value="<?php echo $valarr['p19q3']; ?>"/><br/> <input type="text" name="p19q4" value="<?php echo $valarr['p19q4']; ?>"/><br/> <input type="radio" name="p19q5" value="123" <?php if($valarr['p19q5'] == '123'){ echo 'checked="checked"'; } ?>/>123 <input type="radio" name="p19q5" value="456" <?php if($valarr['p19q5'] == '456'){ echo 'checked="checked"'; } ?>/>456<br/> <input type="text" name="p19q6" value="<?php echo $valarr['p19q6']; ?>"/><br/> <textarea type="textarea" cols="30" name="p19q7" rows="7"><?php echo $valarr['p19q7']; ?></textarea><br/> </form> <button type="button" onclick="saveXML()">Save</button> </div> </div> Any thoughts or suggestions on this would be much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/269367-nesting-issue-i-think/ Share on other sites More sharing options...
Jessica Posted October 11, 2012 Share Posted October 11, 2012 No. Don't store PHP in your database. Bad. Quote Link to comment https://forums.phpfreaks.com/topic/269367-nesting-issue-i-think/#findComment-1384595 Share on other sites More sharing options...
DarkerAngel Posted October 11, 2012 Share Posted October 11, 2012 (edited) Is the file format being interpreted by PHP? IE: if the file extension is .html it *might* not be process by PHP thus resulting in your problem. (depends on server configuration.) Make sure the file ends in .php maybe? EDIT: I might have read your problem wrong Jessica might be right. Edited October 11, 2012 by DarkerAngel Quote Link to comment https://forums.phpfreaks.com/topic/269367-nesting-issue-i-think/#findComment-1384596 Share on other sites More sharing options...
ManiacDan Posted October 11, 2012 Share Posted October 11, 2012 +1. Super bad. Store placeholders in your templates. Use a templating language like twig or smarty to replace the values you want. Quote Link to comment https://forums.phpfreaks.com/topic/269367-nesting-issue-i-think/#findComment-1384598 Share on other sites More sharing options...
krisw44 Posted October 11, 2012 Author Share Posted October 11, 2012 Jessica: I understand the issues with it, but not sure how else to retrieve and load the data without having to manually build each page. DarkerAngel: Yes, the main page is a .php page. It process all of the main php requests properly, just not the ones being called within the second level. ManiacDan: I'll take a look at those snippets. Quote Link to comment https://forums.phpfreaks.com/topic/269367-nesting-issue-i-think/#findComment-1384600 Share on other sites More sharing options...
Jessica Posted October 11, 2012 Share Posted October 11, 2012 What "data" are you storing that NEEDS to have PHP in it? Quote Link to comment https://forums.phpfreaks.com/topic/269367-nesting-issue-i-think/#findComment-1384601 Share on other sites More sharing options...
krisw44 Posted October 11, 2012 Author Share Posted October 11, 2012 It is a workbook. User A stores the data and user B can view it when they log into a resource panel. User A can also log back in to view/change their answers at any time or see if they are correct once User B has corrected it. Quote Link to comment https://forums.phpfreaks.com/topic/269367-nesting-issue-i-think/#findComment-1384603 Share on other sites More sharing options...
ManiacDan Posted October 11, 2012 Share Posted October 11, 2012 So store the editable bits in the database, and the template on the filesystem. When user B goes to view the page, select all of user A's inputs from the table, and str_replace them into the template (or use a templating engine) Quote Link to comment https://forums.phpfreaks.com/topic/269367-nesting-issue-i-think/#findComment-1384604 Share on other sites More sharing options...
Jessica Posted October 11, 2012 Share Posted October 11, 2012 There is no part of that description that has to do with storing PHP in your database. Quote Link to comment https://forums.phpfreaks.com/topic/269367-nesting-issue-i-think/#findComment-1384605 Share on other sites More sharing options...
krisw44 Posted October 11, 2012 Author Share Posted October 11, 2012 I like that idea Maniac. Going to go give it a shot. I'm templated before, not sure why i didn't think to do it here. Appreciate the help and idea bouncing. Quote Link to comment https://forums.phpfreaks.com/topic/269367-nesting-issue-i-think/#findComment-1384609 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.