glow Posted November 7, 2012 Share Posted November 7, 2012 Hi Im not sure if "includes" would be the solution to this but I need to include a piece of php code inside a tab in a nother page. this is the php code sample: <td class="grid"> <p>Additional Administrator Login</p> </td> <td class="grid"> <p>Username <input type="text" name="admin_username" value="<?php echo $userXML[0]["username"]; ?>" /></p> <p>Password <input type="text" name="admin_password" value="<?php echo $userXML[0]["password"]; ?>" /></p> </td> </tr> the php code comes from the same domain. Any help would be appreciated, I've been at this for days now. Quote Link to comment https://forums.phpfreaks.com/topic/270420-duplicating-a-piece-code-into-another-page/ Share on other sites More sharing options...
Volter9 Posted November 7, 2012 Share Posted November 7, 2012 If you want just to insert the same piece of code, there's a different solutions: Includes from another file *.php (recommended, most easiest) Selection from Data Base: MySQL or others (most hardest way) Storage Classes. Note: OOP required (you're creating class and storing inside of class piece of code) Quote Link to comment https://forums.phpfreaks.com/topic/270420-duplicating-a-piece-code-into-another-page/#findComment-1390857 Share on other sites More sharing options...
Jessica Posted November 7, 2012 Share Posted November 7, 2012 Please do not store your code in a database - that should never be done. You can either include the file, or create a function which generates that section. Quote Link to comment https://forums.phpfreaks.com/topic/270420-duplicating-a-piece-code-into-another-page/#findComment-1390861 Share on other sites More sharing options...
glow Posted November 7, 2012 Author Share Posted November 7, 2012 hi and thank you both for your responces. I'm just starting to learn php so some of your suggestion maybe alien to me still. Any code samples would go along way and hugely appreciated. Regarding the "include" i already tried including the the php page with the tab and it wont shot up. the script that creates the tabs came wih an an example of how to include your own php pages i just edited the code to add my php page and it wont show up. But even if i can get it to show up I'm just looking to display only a portion of that php page. this is the include code that I used: <?php include($DOCUMENT_ROOT . "/admin/inc/settings.php"); ?> and i get this error: Notice: Undefined variable: DOCUMENT_ROOT in C:\Program Files\EasyPHP-12.1\www\examples\innertabs.php on line 1 Warning: include(/admin/inc/settings.php): failed to open stream: No such file or directory in C:\Program Files\EasyPHP-12.1\www\examples\innertabs.php on line 1 Warning: include(): Failed opening '/admin/inc/settings.php' for inclusion (include_path='.;C:\php\pear') in C:\Program Files\EasyPHP-12.1\www\examples\innertabs.php on line 1 Im working localy by the way. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/270420-duplicating-a-piece-code-into-another-page/#findComment-1390885 Share on other sites More sharing options...
Barand Posted November 7, 2012 Share Posted November 7, 2012 $_SERVER['DOCUMENT_ROOT'] Quote Link to comment https://forums.phpfreaks.com/topic/270420-duplicating-a-piece-code-into-another-page/#findComment-1390916 Share on other sites More sharing options...
Volter9 Posted November 8, 2012 Share Posted November 8, 2012 Please do not store your code in a database - that should never be done. You can either include the file, or create a function which generates that section. +1 Jessica, never store code in data bases, and never (sometimes yes, but only at home!) don't use eval()s in code! But it was only a option, just option. It's one way of storing code, but bad way Quote Link to comment https://forums.phpfreaks.com/topic/270420-duplicating-a-piece-code-into-another-page/#findComment-1390978 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.