matak
Jan 9 2007, 01:44 PM
I learned the way to load other files with the code posted on this forum. Now i wanted to try something for my side menu. I am calling this a string, --> $tekst , maybe it's called something else i'm not sure Now let's say i have a file called details.txt In that file i would like to have something like this $detailsaboutphp1 = ("details details details 1"); $detailsaboutphp2 = ("details details details and even more details 2"); How to make a code that loads those $strings on click of a mouse. [REMINDER:]When we tried to load external file we used this: CODE <?php if ( !isset($_REQUEST['content']) ) { $content = "home"; $menulhome="menulhome"; $menurhome="menurhome"; } else { $content = $_REQUEST['content']; } ?> Than we included other files with a href CODE <a href="index.php?content=details">Details</a> For loading details.xxx in place where we placed this code CODE <div><?php include("$content.xxx");?></div> [/END OF REMINDER]All i need now is a way for that Details to load other $string that is defined in text file.. Thank you
Reply
Spectre
Jan 9 2007, 04:31 PM
First and foremost, always sanitize user-provided data. Search this forum for many a thread in which it has been discussed. Anyway, including the file containing that code should assign it to the respective variables. Included files are evaluated within the same scope as from where the include() function was called, meaning that you should have access to the variables immediately after including them. Functions, classes, and global variables are, of course, declared on a global scope no matter where they come from.
Reply
matak
Jan 9 2007, 06:26 PM
So basicly you wanna say that if i included my details.txt anywhere in page with this CODE <?php include("details.txt");?> which contains string $detailsabout, and $detailsabout1 that i can call them separatly with <a href> Does that mean that all of this time i've been doing it wrong?! I thought when file was included that it shows just the files name, i didn't know that that file can contain variables that can be shown separatly on click.. well, this makes more sense now. thanks, i'm going to try something and if it works i'm just gonna be massively happy! Thanks QUOTE(spectre) First and foremost, always sanitize user-provided data. Search this forum for many a thread in which it has been discussed. Sorry for not searching, i just don't know how to search for this question, beacouse something like this is hard to explain and even harder to ask at second hand, i probably read this answer million times before but it makes sense only when you get to the point when it can make sense. I hope you understand and don't mind for asking something that's been asked for houndered time...
Reply
BuffaloHELP
Jan 9 2007, 10:05 PM
If you want to use external file to store your variables that is in PHP format, like your example, I found the following methods to be the best use. 1) Store them as PHP format when using INCLUDE when you save an external file, insert <?PHP and end with ?> such that CODE <?PHP $var1 = "string1"; $var2 = "string2"; ?> This will simplify your include "filename"; within your PHP script. As far as I can tell, if you insert PHP header you only have to say INCLUDE command. If you do not insert PHP header, then you have to open the file, read line by line and address them as per variable. Either way it will work. I just found that when saving external file with PHP variables, it's easier to recall when I save it as above sample. 2) If you're not going to save external file with PHP header use REQUIRE require is used when you have external files that contains functions, let's say, and you want to seperate many functions from all other script codes. Just for fun, if you save HTML codes as text file format and use INCLUDE command, it will behave just like the regular HTML command. I have been using this method for GFXTrap affiliation insert.
Reply
jlhaslip
Jan 10 2007, 12:31 AM
And further to what BH has inserted into this topic, "included" files are always treated as HTML files, BUT, if you save the file as a php extension, the contents will be more secure than a regular text file, due to the fact that with the php extensin, the file would be parsed through the php parser if someone tries to link directly to it. This also works to "hide" your file contents of "included" files. Some coders double up their extensions as thusly: "filename.inc.php" : the 'inc' tells them they are Includes and the 'php' causes them to be secured as above.
Reply
Saint_Michael
Jan 10 2007, 03:45 AM
Interesting on that little security feature, in which case most likely that is used for login, store,admin scripts for added security. I did find an additional way, a bit more complex but does the same thing. CODE $current_url = $_SERVER['PHP_SELF']; echo "<a href="$current_url">http://www.totaldream.org" .$current_url. "</a>";
With this if I look at this right when you click on the link that uses this set up the server will load regardless of where it is located, you click the link and it will bring you there. so in a way you could echo your whole nav system like that.
Reply
matak
Jan 10 2007, 07:26 AM
OT Question, problem is solved before this post
Thanks for those security tips, i was just about to ask that question but you beat me with answer.. Oh well few credits less So what is the proper way to arrange files so that you don't get into trouble and conflicts later. Is it the same to put all of the content in one content.inc.php file, or is it better to make separate file for each categorie you have on site [EXAMPLE:]If i have News, which display in my index, and than maybe Stories which display on href=stories. Is it better way to store variables in same file, beacouse some of them are going to be displayed on both links so that i don't need to copy/paste them in two separate files. [/EXAMPLE]I feel that I'm getting a bit closer to understanding the proper way to build small custom CMS system, so i wouldn't want to go in wrong direction with directory and file structure. And good tut's about that, or do you arrange structures based on your feeling (like after Format C:  )
Reply
Spectre
Jan 10 2007, 01:57 PM
I would use a structured database system for a CMS rather than flatfiles, such as MySQL (which is available via Trap17). In my opinion, flatfiles are useful for storing data where a database or even just a single table in a database is a bit of 'overkill' - in that the data you are storing is so small or insignificant that it isn't worth interfacing with a database engine (which is remarkably easy with MySQL in PHP anyway). Otherwise, I would recommend a database better suited for dealing with larger amounts of dynamic data.
Reply
Saint_Michael
Jan 10 2007, 02:19 PM
What makes PHP fun is that you can have many includes as you want one file, just have to make sure they are coded correctly. my website uses a combination of mysql tables and flatfiles for different stuff although I had made a booboo on moving some files and messed everything up. Examples would for flat files would be counters, logging IP's MySQL forums,, guestbooks, mail, or other large applications (see fantastico for those examples) What makes PHP fun is that you can have many includes as you want one file, just have to make sure they are coded correctly. my website uses a combination of mysql tables and flatfiles for different stuff although I had made a booboo on moving some files and messed everything up (not worried havn't done much with it anyways). Examples would for flat files would be counters, logging IP's MySQL forums,, guestbooks, mail, or other large applications (see fantastico for those examples)
Reply
matak
Jan 11 2007, 06:49 PM
QUOTE(Saint_Michael @ Jan 10 2007, 03:19 PM)  What makes PHP fun is that you can have many includes as you want one file, just have to make sure they are coded correctly.
Yes, I know!! I just figured it out yesterday. I knew that it is possible, but i didn't realize it would be this easy. Of course, for now i'm just going to stick by echo-ing html code when clicking hyperlinks, but now i understand the real power of PHP (or any other program). I just didn't know that it works that way, i always thought that i would need to make some powerfull function to do such a thing. With understanding of this, really simple thing i can get to programing smart and fun functions by the way. I'm not saying that is easier, just it's more fun. My worst problem is that i'm messy when saving and testing files, and i lose code all the time. You always have that feeling that it could be done better, more neat and simple. Not always is that true but i guess now that i learned this basic principle that i am going to be more neat when arranging files. Currently I'm developing template Made in pure CSS without IE Hacks, simple but functional, it's almost done. I even made small tut about it so i'll post it. Although it changed a bit from start, beacouse in half of making that tut i learned great thing about CSS so It's really simple but functional code. Also some of you mention database, yes it is great thing but i just don't feel i'm ready for storing data into tables 'couse i haven't learned that much yet. After almost 5 months wrestling with HTML, CSS, and some PHP finally i learned something worth mentioning. I just hope that rest of the stuff isn't going to be that hard, and that this great support on Trap17 is going to be that great if not even better if that is even possible. Have fun coding, i know i am!!
Reply
Recent Queries:--
save string to txt php - 4.65 hr back.
-
php if string text - 7.47 hr back.
-
php if string txt - 7.58 hr back.
-
find string in text file php - 15.65 hr back.
-
php load variable from file - 27.12 hr back.
-
php get string from text file - 33.32 hr back.
-
php load other file - 38.95 hr back.
Similar Topics
Keywords : php, load, string, text, file, solved, loading, string, text, file, click, link
- Php Configuration File
"config.php" (16)
Need Some Help In File Browser
listing all sub folders and files in them. (8) Hey I want to create a very simple file browser, so that, it reads all the sub-folders which are
places in a directory, and the files inside the sub-folders (It reads only files inside sub-folders
and list them in simply. ) Also, it creates a directory (any name) inside each sub folder. My
Following code reads on the files inside the main directory, it does not read the files inside the
sub-folders.. I appreciate any help. CODE <? $path = "./"; $dir_handle =
@opendir($path) or die("Unable to open $path"); whil....
Updating Php File Through A Web Form
(5) Hello, i'm not sure if this can be done with php or not but what i need is a way to make an php
file that have an html form on it and it will take the info you put in to that form and write it to
an existing php file, for example: if i have the file news.php and the file news_update.php. if you
went to news_update.php you would get an form with a text area for you to write a new addition for
the news.php file and when you hit submit it will add what you typed in the form to the file
news.php. If this is going to be a big code or a hard one to make but some one think....
File Checker-how To Check File Whith Html Through Html?
(2) edit:sorry for the mistake it is php not html and its with not whith my code checking script= CODE
<?php $file = '$CHECK'; if (file_exists($file)) {
echo "The file $filename exists"; } else { echo "The file $filename
does not exist"; } ?> my question is how to check the file whith html example:on a page
a text box is provided and a button the user writes a file name (or website) the user clicks on the
submit button then it checks and show it (with the code above) i got the code C....
I Just Wrote A Script For A Php Text Editor!
(8) Yes, I just wrote out a script for a PHP text editing program. It is very basic but I would like to
be able to actually use this and update it. First, I need version 0.7 to be proofread. It will be
upgraded to 0.8 after closed beta, 0.9 after open beta, 1.0 when ready. I would love to have some
people help with this project. Right now it is a simple PHP script and HTML form. Here is the
current script. I would like it to be proofread. $fileName = "$_REQUEST ";
$fHandle = fopen($fileName , 'w') or die("Can't write file."); $fCont....
Php Text Editor
(1) Is there any possible way using XML and PHP that you could create a text editor that can save files
in your documents and also make a hotlink to your site. Much like a online notepad. I would like to
know how I would make on of these and whether or not MySQL or XML would be a good language to use
for storing data. My current idea deals with only PHP and iframes. It really isn't an editor
though, more like a notes page. I would like a way though to be able to create a database with info
stored from the PHP script which and be able to save to your hard drive. Also, i....
Php And Flash Image Gallery
Need some help in creating or editing an xml file while viewing some o (5) Hello there and thanks for the helping hand you are offering. PHP newbie here! /ph34r.gif"
style="vertical-align:middle" emoid=":ph34r:" border="0" alt="ph34r.gif" /> So here is my problem:
On my website I have a flash image gallery.The way the gallery works is by uploading pictures in a
folder and editing? an xml file.(pics.xml) where it adds the following code when you upload a
picture: CODE <pictures> <image location="nameofpicture1.jpg"
desc="" /> <image location="nameofpicture2.jpg" desc="" /....
No File Extension
(3) On MediaWiki, the URL of the content is http://YOURWIKI.com/index.php/Blah Is it possible to
create a page or two that doesn't have a file extension? If so, how is it done?....
File Upload
File upload (1) I need to add a facility on my customer's website so his clients can send him jobs, typically
5mb - 50mb. I've looked around the web and researched this, and tried a few tests (failed), but
my brain's beginning to hurt. Could someone please tell me the best way to go about this,
please. The site is done in Flash, but I'm sure a link to an html page would be ok if necessary.....
<?php ?> Unique Visitors Script
Flat file unique visitors script (no sessions) (2) This is really simple script. Well at least this part is, but it could be extendable. Only problem
is that it's not really for massive websites with hundread of visitors a day, but rather for
small ones. But it is a good script to figure out how to make a visitor counter script. Anyway
here's the snippet. CODE <?php function getVisits($variable) {
$visits = array(); if ($handle =
opendir('stats/')) { while (false !== ($file =
readdir($handle))) { ....
[php]simple Flat File Text Manipulator
Example on how to use forms to write to files in PHP (3) I made a simple flat file text editor, that can show you probably how simple it is to use forms with
php and write that data to file. This example has 2 files, submit.php, and postit.html. Submit.php
is used to write title, and some text, and add html tags, and paragraph tags where new paragraphs
are. Here's the file with comments. I think that HTML really doesn't need some more
explaining. CODE Title: <br /> <input type="text"
name="title" size="53"> <br /> Text: <br />
<textarea nam....
Edit .txt File In Ftp Via Webpage
file on external ftp (2) Right Im new here and stuggling with a problem im having. I've currently got a Login Script to
login to a external ftp and it displays the folders contents, however i need it so it echos a
specific file (coursedata.cfg) into a formarea which you can then edit the file and when u click
save it overwrites the file with the new one. Im really quiet getting annoyed with it xD as
everything i do ends up trying to include the file from the webserver the script is hosted on and
not the external ftp source. thanks Full Code Bellow Simple FTP Manager body { fon....
Forms, Text Files, And Php For A Signature Generator.
Help a little. (1) Hello everyone! I am in need of some code a for a signature generator I am making. I am using
BuffaloHELP's code for the php file, now I am trying to improve that code by making a form in a
html file that will have the user say what is on the sig! But now, I need help getting the form
data that is posted by the user to get into that sig! There is a file, sig.txt, where that tells
the php file what text will go on the sig. But how can I make the form data in the html file go into
the text file so it will go onto the sig? You might want to read BuffaloHELP&....
Php Help Needed Including File In A Page.
(2) i'm a noob in php programming, i can understand and modify php programs, but i dont know to
write on my own. So please somebody who is well versed in php help me. My need is, I'm
currently builiding a knowledge base website , i've my own design for the website, check here,
http://laschatz.info/kzone/ Each page in the left hand site has a tree navigation of all the
topics available. Since this information must be same in all the pages, presently I need to change
all the pages after adding a new category. Could you please help me in such a way that I can ad....
Help Needed With Directory/file Listing Code Infinite Loop
Made an infinite loop but why is this so? (5) Hi all ive got a small and simple (for the moment atleast /unsure.gif"
style="vertical-align:middle" emoid=":unsure:" border="0" alt="unsure.gif" /> )file and directory
listing script in php as follows CODE $dir = "."; $num = 0; $file =
scandir($dir); while($file = scandir($dir)){ echo
$file[$num]; echo "<BR>"; $num = $num + 1;
}; the concept is simple enough, the directory to start with is the current one, so scan this
directory and wh....
Display Random File In A Directory
how to display a random file from a set directory. (9) hi, could someone please help me with this? I have some files in a directory and i want to know how
i can randomly display link/s to one or more of the files in my directory for download. But it must
not at any time display index.php which is also in the directory with the downloads. Thanks in
advance for any help given /unsure.gif" style="vertical-align:middle" emoid=":unsure:" border="0"
alt="unsure.gif" />....
String/text Formatting?
(4) right i was wondering if someone could help me with this: I notice on this site if i make a topic
for example WAppY rOCks WaP, it will come out like Wappy Rocks Wap. I also want to do this to my
forums, can anyone give me the code to format a string of text in this way? THANKS IN ADVANCE ....
File Format Unknown! (wap)
someone PLEASE HELP! (6) hi people :-) listen please can someone help me find the error in this wapsite page, its driving me
nuts! It works fine on some phones but not on others (giving a file format unknown error) and im
having serious problems finding the error but i bet its something stupid/simple. CODE <?php
include ("config.php"); include ("core.php");
header("Content-type: text/vnd.wap.wml"); header("Cache-Control:
nostore, nocache, mustrevalidate"); print "<?xml version=\"1.0\....
File In Database
Question.thanks (1) Hi all i write this code i want when you see download.php (this code) my file goes for download for
user sorry my english is not very good its a file database project for my university but when i
browse this code my soruce file (.zip) echo in my page and dont goes for download my next querstion
about safe mode i saw (php.net and zend) when safemode is on file databaseing and header() is not
working . is it true ? if is it true i save my file at hosting and no (database) i want write
standard script . plz help me thanks more and more CODE include("config.php&....
Php Writes Into Txt File
a question (8) QUOTE $fp=fopen("test.txt","a"); fputs($fp,"ok"); ?> The above method is only to
add "ok" at the end (DO NOT write on a new line) I want to know... How to add data on a new line
and at the end of txt file??! thx~....
File String Delete?
(2) Say i have a file file.txt... Can someone give me an example of how to delete a string from this
file ie.. The file contains: wappy::sucks::at::php --- i want to delete sucks::....
Page Loading Time V2
how long does your page take to load? (3) As my knowledge of PHP increases, I have learned more, in this version, I use a class. V1:
http://www.trap17.com/forums/page-loading-time-t4782.html CODE <?php class microtimer { //
Starts, Ends and Displays Page Creation Time function getmicrotime() {
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec); }
function s() { $this->st = $this->getmicrotime();
} fun....
Simple Text Counters
Counters i use on wap sites ;-) (15) First create a dir "counters" in root add to it dailyhits.txt, hits.txt, online.txt an CHMOD 0777,
place this on index: CODE //online counter $tim = 120+time(); $time =
time(); $f = "counters/online.txt"; $nusk = file($f);
$sk = count($nusk); $in = $HTTP_USER_AGENT.$REMOTE_ADDR; $fp =
fopen($f, "w+"); for($i=0; $i<$sk; $i++) {
list($nix, $timf) = explode("|", $nusk[$i])....
Dynamic Image / Signature Generator
a simple code to change text on an image (12) In search of dynamically changing quote, saying or all other types of text on an image I came across
a code that I have modified to fit my initial usage. This procedure requires two files and short
knowledge of PHP. If you are familiar with Trap17's sig rotation code you will understand this
procedure very fast. Code 1: dynamic_sig.php (you can rename this to index.php and you'll see
at the end why) Code 2: a simple text file named anything (I will call it name.txt ) Code 1
CODE <?php header("Content-type: image/png"); ....
Include File.php?id=something
using the include() function (13) Well, I am making a full CMS system for my site, and want to make the index.php file to include the
view.php?id=1 file. I tried with this code, but it didn't work: CODE <?php include
'view.php?id=1' ?> This is the error I get: CODE Warning:
main(view.php?id=1) [function.main]: failed to open stream: Invalid argument
in C:\server\xampp\htdocs\test\index.php on line 1 Warning:
main() [function.include]: Failed opening 'view.php?id=1' for inclusion
(i....
How To Use A Link To Call Function In Php?
(8) The title says it all, really. How do you call a function using in PHP? I'm doing a project
and I stumbled upon this problem. I don't want to use query string in the href part like
since that would mess up the other part of my code. Can anyone pleae help me? I've pasted the
code below. /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> Thanksh.
CODE <?php function display($x){ //coding goes here. } ?>
<html> <body> <p align="center"> <a href="what g....
I Need Help With File Edit In Php
with ftp (6) Currently i have CODE <?php if($_POST['user']=="" or
$_POST['pass']=="" or $_POST['host']==""
or $_POST['root']=="" or
!isset($_POST['run'])){ print('<form method=post
name=form>'); print('FTP username <input type=\'text\'
name=user value=""><br>'); print('FTP password <input
type=\'password\'....
Script: Php Jukebox
A one file script! (4) This scripts is so simple, you dont need to edit ANY of it! All you have to do is make a folder
called 'songs' and put some audio files in it. Here is the whole page, I named it index.php
and put it in a folder called 'music': CODE <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"> <html> <head>
<title>PHP jukebox</title> </head> <body> <!-- ©2005 Craig
lloyd. All rights reserved. Visit cragllo.com for more sc....
Getting List Of Directories And Files Using Php
PHP Function for Directory and File List (6) is there a php function that lists the content of some folder.... example: /New folder new.txt
left.gif download.zip dc.exe ....so is there..? /rolleyes.gif' border='0'
style='vertical-align:middle' alt='rolleyes.gif' /> ....
Page Loading Time
how long does your page take to load? (7) All you have to do is add this code to your page where you want the loading time to be shown, the
bottom is the most common place. CODE <?php $loadbegintime = microtime();
$loadbeginarray = explode(" ", $loadbegintime); $loadbegintime =
$loadbeginarray[1] + $loadbeginarray[0]; $loadendtime =
microtime(); $loadendarray = explode(" ", $loadendtime);
$loadendtime = $loadendarray[1] + $loadendarray[0];
$total_script_time ....
Looking for php, load, string, text, file, solved, loading, string, text, file, click, link
|
|
Searching Video's for php, load, string, text, file, solved, loading, string, text, file, click, link
|
advertisement
|
|