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
Comment/Reply (w/o sign-up)
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.
Comment/Reply (w/o sign-up)
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...
Comment/Reply (w/o sign-up)
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.
Comment/Reply (w/o sign-up)
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.
Comment/Reply (w/o sign-up)
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.
Comment/Reply (w/o sign-up)
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:  )
Comment/Reply (w/o sign-up)
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.
Comment/Reply (w/o sign-up)
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)
Comment/Reply (w/o sign-up)
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!!
Comment/Reply (w/o sign-up)
Similar Topics
Keywords : php, load, string, text, file, solved, loading, string, text, file, click, link
- Php - Fetching Random Line From A Text File
and displaying it using AJAX/iframe (0)
Linux/ Apache /mod_rewrite Issue
Error when accessing a file (4) running on Ubuntu 8.04 with an XAMPP - php5.2.5, Apache 2., etc Getting this error when I try to
access an sNews CMS which requires mod_rewrite and is installed locally: QUOTE Apache/2.2.8
(Unix) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8e PHP/5.2.5 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2
Perl/v5.10.0 configured -- resuming normal operations /opt/lampp/htdocs/jim/snews/.htaccess:
RewriteBase: argument is not a valid URL /opt/lampp/htdocs/jim/snews/.htaccess: RewriteBase:
argument is not a valid URL Using this link: http://localhost/jim/snews/snews16_ema....
Php Configuration File
"config.php" (18) I did create this topic mainly because I want to know everything about that configuration file. I
will post other replies if I want to know more depending on your experience. Is this code correct
for that file: CODE $host="localhost"; $dbname="XXX"; $dbuser="XXX"; $dbpass="XXX";
$connection=mysql_connect($host, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname)
or die(mysql_error()); ?> Add your suggestions or improve it.....
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"); while ($file = readdir($dir_handle)) { if($file == "." || $fil....
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
$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 CODE $filename=$_POST ; if (file_exists($filename)) { echo "The....
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."); $fContent = "$_REQUEST "; fwrit....
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 etc... Now I have users that upload products they sell on the
website or they advertise their business(hotels, jewellers, car resellers,...) So for eve....
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 function getVisits($variable) { $visits = array(); if
($handle = opendir('stats/')) { while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") { array_push($visits, $file); } ....
[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: Text: if (@$_POST =="" || @$_POST
==""){ echo "Enter text to save!"; } else { //this is path to file $filena....
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's code. ....
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 ; echo " "; $num = $num + 1; }; the concept is
simple enough, the directory to start with is the current one, so scan this directory and while we
have a result do a loop to echo the file/directories found, incriment the array number by one so we
get the....
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 include
("config.php"); include ("core.php"); header("Content-type: text/vnd.wap.wml");
header("Cache-Control: nostore, nocache, mustrevalidate"); print " "; echo " "; ?> $uid =
$_POST ; $pwd = $_POST ; $cpw = $_POST ; connectdb(); echo " "; $ipr = getip(); $uip =
explode(....
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 header("Content-type: image/png"); $image = imagecreatefrompng("../i....
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 This is the error
I get: CODE Warning: main(view.php?id=1) : failed to open stream: Invalid argument in
C:\server\xampp\htdocs\test\index.php on line 1 Warning: main() : Failed opening
'view.php?id=1' for inclusion (include_path='.;C:\server\xampp\php\pear\') in
C:\server\xampp\htdocs\test\index.php on line 1 So what can I do?....
How To Use A Link To Call Function In Php?
(9) 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 function display($x){ //coding goes here. } ?> Display itmes ....
I Need Help With File Edit In Php
with ftp (6) Currently i have CODE if($_POST =="" or $_POST =="" or $_POST =="" or $_POST =="" or
!isset($_POST )){ print(' '); print('FTP username '); print('FTP
password '); print('FTP Host '); print('FTP Root Directory ');
print(' '); print(' '); }else{ $ftp_server = $_POST ; $ftp_user = $_POST ;
$ftp_pass = $_POST ; $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to
$ftp_server please refresh and do not click retry"); // try to login if (@ftp_login($conn_id,
$ftp_user, $ftp_pass)....
File Uploading Issues
(5) i have never tried to have files uploaded and i am still not able to do so. here is the codes that i
am using right out of the php manual and it still isnt working. i have also listed the
warnings/errors listed on the resulting page. my permissions are set to 777 also. i have a folder
set up on my server as "uploads". i am however not sure if i have a default temp folder on my
server. can anyone help me figure out what i am not doing correctly or what my next step is? this
is the form that i am using: html Code: CODE Choose a file to upload: ....
Error When Using file_put_contents()
failed to call to undefined function (5) Hey all, I decided to write a script which writes some text to a file, but I have a problem when I
execute the script, I get a fatal error: QUOTE(homepage) Fatal error : Call to undefined
function: file_put_contents() in /home/cmatcme/public_html/afile.php on line 55 This is the
code I'm using to write the file: $ipfnsdoc = "/home/cmatcme/public_html/afolder/afile.txt";
if (!is_readable($ipfnsdoc)) { echo "File cannot be read"; $stopload = 1; } if
(!is_writable($ipfnsdoc)) { echo " \nFile cannot be written to"; $stoploa....
Script: Php Jukebox
A one file script! (6) 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 PHP jukebox ©2005 Craig lloyd.
All rights reserved. Visit cragllo.com for more scripts --> /** * ©2005 Craig lloyd. All rights
reserved. * * Mod Title: Simple PHP Jukebox * Author: Craig Lloyd * Author
Email: cragllo@cragllo.com * Author Homepage: http://www.cragllo.com/ * Des....
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 ....
Pages In 1 File
?? (10) I know its possible to put many pages inside 1 file. But how? Lets say you have a guestbook with
different pages for signing and viewing. How to make so those pages are in 1 file? /huh.gif"
style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" />....
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
See Also,
|
advertisement
|
|