PHP - Explicity Make File For Include Only
Hello,
Is there a function to make a PHP file explicitly to be used as an include only? Or would it just be easier to set a variable in the parent page and test for it in the include page? I just wanted to make sure there wasn't a more efficient way than using the latter method. Thanks, Carson Similar TutorialsI have a php file that generates a string that I need to use in a .js (javascript)file. Being that php developers sometimes using javascript with php, Im hoping someone can help me with this, cause i dont know any javascript. Code: [Select] //This is the varible inside the .js file var suggestionText = "I need to be able to include my string generated by the php file here..."; I want to include a php file after an succesfully login. Let's suposed that I have a login form on index.php. If the login was ok I want to include a php file with some content instead of the login form. Something like: Code: [Select] <? if($_POST['ok']){ require('content.php'); } else { //login form } ?> It's ok to include in the code the name of the file that you have on server ? From security point of view. Thanks Can I include a class file in the same page that I use an instance of the same class with my action attribute with my form. Here's the code Code: [Select] <?php include 'Resources/User.php';?> <html> <head> <title></title> <link href="stylesheets/styles.css" rel="stylesheet" type="text/css"/> </head> <body> <form action = "Resources/testClass.php" method="post" enctype="multipart/form-data"> <label>First Name: </label> <input type="text" name="fname" id="fname" size="25" maxlength="25"/> <label>Last Name: </label> <input type="text" name="lname" id="lname" size="25" maxlength="25"/> <label>Email: </label> <input type="text" name="email" id="email" size="25" maxlength="40"/> <label>Username: </label> <input type="text" name="username" id="username" size="25" maxlength="32"/> <label>Password: </label> <input type="password" name="password" id="password" size="25" maxlength="32"/> <label>Re-enter Password: </label> <input type="password" name="conf_pass" id="conf_pass" size="25" maxlength="32"/> <br /><br /> <input type="submit" name="submit" id="submit" value="Register"/> <input type="reset" name="reset" id="reset" value="Reset"/> </form> </body> </html> Hello, Im trying to pass a variable to a newly created page using GET. Code: [Select] $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Restaurant' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title'>" . $nt[$i] . "</a>" . "<br/>"; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); header.php Code: [Select] <head> <?php $title = $_GET['Title']; ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p>HEADER UPDATED!</p> <p>TESTING - the heading below should read (title goes here in capital letters)</p> <?php <h1>$title</h1> ?> //This is line 12 </body> </html> Im getting the error; Parse error: syntax error, unexpected '<' in D:\Hosting\3753557\html\1pw\mexican.php on line 12 I suspect that I have my syntax muddled in header.php? Is there a better way to pass variables to a newly created page? (fopen). Many thanks for any ideas. www.desmond-otoole.co.uk/secure/securefunctions.php /bank/admin/index.php what should I do in the index.php file to access securefunctions.php
require("../secure/SecureFunctions.php"); Nothing seems to work
I just get a stupid google chrome page saying How do I include a file that is located two directories above the file that I want to include the file into? My absolute hosting path is /home/content/52/8840652/html if this would be of any use. I'm not quite sure about the PHP include functions. Any help would be greatly appreciated, Thanks!
I am using an inclue file on my layout.php page. My catalog uses a template file to list product details. One part of it is responsible for putting these details into nifty little tabs: <?php $template = '{magictabs style=black_rounded, tabwidth=110px}'; $template .= 'Technical Specifications'; $template .= '::'; $template .= '<table colspan="3"><tr><td>'; $template .= $details; $template .= '</td></tr></table>'; $template .= '||||'; ?> I don't want it to output $details, I want it to output a separate script instead. How do I include this separate file as a variable? I want this: <?php include('specs.php'); ?> to replace the $details variable. Hello, I have a simply query that will if a simple two different things: Code: [Select] $cssyn = mysql_query("SELECT `12` FROM `12345` WHERE `abc` = '$_SESSION[number]'"); $cssy = mysql_fetch_row($cssyn); if($cssy[0] == "YES") { echo "Yes"; } else { echo "No"; } The YES or NO result is stipulated earlier on so thats not the problem. But basically before I added the if statement simply would have echoed a table with all the rows etc from another query. However I would like to give the user a choice between echoeing the results into one table or a neater two. I have separated the code for the table and the queries into two separate files but say if I use: file_get_contents then it just prints the HTML and doesnt actually populate it will the queried parts. Nor if I use something like include() then it wont echo anything, which it wouldnt unless called so what I am asking is: Is there a way to get EVERYTHING from the file if the answer is YES or the other file if NO. Here is a section of php file A include_once(dirname(__FILE__) . '/PhpfileB.php') $VALID_RATING_IDS = $Ratethese Here is all of php file B $Ratethese = "array("1", "2",);" I need the var $VALID_RATING_IDS to = $Ratethese from file B I am trying to include an array from php file B in php file A. Is this possible? How can i accomplish this? In my code include_once "http://myserver.com/someFile.php" does not work but include_once "/someFile.php" works I NEED to be able to full URL. Anyone know what PHP setting I need to change to get this working for me? Thanks This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=308660.0 Hi all, I'm at a dead-end here. I have a php file that I can query to return an array containing a bunch of data about a job listing. I include and query it by calling it like so within another file on my site. Quick Notes: The original file is in a different directory on my site than the page it's being included in. I have tried returning the array at the end of the script. I can print_r the array on the page I'm including the script on (so the URL path is correct). If I go to this URL directly and print_r on the array, I see the entire array as expected. Also, if I include the file on page 2 like I did above with print_r on the array in the original file, I see the array printed out on page 2. Code: [Select] include 'http://www.example.com/php/job-details.php?job=jobname&city=thecity'; However, if I do not print_r on the array in the original file and just include it on page 2, I cannot do anything with it and the array variable isn't found. Is this a case of variable scope? I'm so frustrated... Here is the code I have in my original file: Code: [Select] <? include('functions.php'); $jobtitlematch = $_GET["job"]; $jobcitymatch = $_GET["city"]; //echo $jobtitlematch; //echo $jobcitymatch; $url = 'http://somesite.com/something'; $xml = simplexml_load_file($url); foreach($xml->job as $job) { $jobtitle = makeURL((string)$job->title); $jobcity = makeURL((string)$job->region); if ($jobtitle == $jobtitlematch && $jobcity == $jobcitymatch) { $jobdata[] = array( Title => ((string)$job->title), URL_Title => makeURL((string)$job->title), Location => ((string)$job->region), URL_Location => makeURL((string)$job->region), Department => ((string)$job->department), URL_Department => makeURL((string)$job->department), Overview => ((string)$job->joboverview), Responsibilities => ((string)$job->responsibilities), Qualifications => ((string)$job->qualifications), Keywords => ((string)$job->metakeywords) ); } return $jobdata; //I have also tried return global $jobdata; } print_r($jobdata); ?> Thanks in advance for any help you can provide... Hi I'm in a need of help here, I need to inluded this: "http://site.com/products.php?do=groups&groupid=2" in a a tpl file. Any way that this can be done? an example would be greatly appreciate it. cheers hi php freaks, Is there a way to parse an include file through the php engine and then place the contents into a variable? Code: [Select] $x = include ($myfile); I'm really embarrassed asking this.. I have two files. config.php & program.php config.php<php $max_columns = 3; ?> program.php<?php include ('config.php'); echo $max_columns; ?> I can't get the script to echo anything. I have tried... $max_columns = '3'; $max_columns = "3"; include_once include ("config.php"); include ('/path/to/file/config.php'); require .....etc. etc. Any thoughts? PLEASE, I'm going nuts here. Thanks for you patience with what must be a very trivial question for you guys Hi peeps iv been trying to figure out this but i cant see it....its probably obvious!!! in the $header variable the include files dont show... any ideas here the php code <? session_start(); ?> <link href="/styles/main.css" rel="stylesheet" type="text/css" /> <? //get data $button = $_GET['submit']; $search = $_GET['search']; $search = strtoupper($search); $header = ("<table width='100%' border='0' height='80' cellpadding='4' bgcolor='#000000' > <tr> <td width='39%' height='76' valign='top'><p><span class='stigrosheadfont'><strong>www.StigRos.com</strong></span><strong><span class='headnocrap'><br /> ( No Crap - Just Quality Movie & Music Downloads )</span></span><br /> <a href='http://mysite' class='headerlinkcolor'>Home</a> | <a href='register.php' class='headerlinkcolor'>Register</a> | <a href='#' class='headerlinkcolor'>Contact us</a></strong></td> <td width='47%' valign='bottom'><p class='normalblacktext'>You are currently logged in, <b>$_SESSION[username]</b></td> <td width='14%' valign='top'><div align='center'> <div align='center'><span class='headfont'><strong>Disclaimer</strong></span></div> <div align='center'> <? include_once 'countertest.php'; ?> <? date('F d, Y'); ?></div></td> </tr> </table>"); $s = $_GET['s']; if (!$s) $s = 0; $e = 10; // Just change to how many results you want per page $next = $s + $e; $prev = $s - $e; if (strlen($search)<=2) echo "Must be greater then 3 chars $user"; else { echo $header; echo " <form action='search.php' method='GET'> <center> <br> <input name='search' type='text' class='blacktext' size='50'> <input name='submit' type='submit' class='blacktext' value='Search Film'></font></p> </center> </form> "; //connect to db include('db.php'); //explode out search term $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { //construct query $x++; if ($x==1) $construct .= "keyword LIKE '%$search_each%'"; else $construct .= " OR keyword LIKE '%$search_each%'"; } //echo outconstruct $constructx = "SELECT * FROM movies WHERE $construct"; $construct = "SELECT * FROM movies WHERE $construct LIMIT $s,$e"; $run = mysql_query($constructx); $foundnum = mysql_num_rows($run); $run_two = mysql_query("$construct"); if ($foundnum==0) echo "No results found for <b>$search</b>"; else { echo "<table bgcolor='#000000' width='80%' height='1px' align='center'><br /></table><table bgcolor='#000000' width='80%' height='10px' align='center'><tr><td><div align='right'><font color='#E6E6E6'>Showing 1-10 of <b>$foundnum</b> results found for <b>$search.</b></font></div></td></tr></table><p>"; echo "<br>"; while ($runrows = mysql_fetch_assoc($run_two)) { //get data $title = $runrows['film']; $desc = $runrows['description']; $url = $runrows['dl_link']; $imdb = $runrows['imdb']; $pic = $runrows['pic']; $film = $runrows['film']; echo "<table width='900' border='1' align='center'> <tr> <td width='229' align='center'><IMG SRC='$pic'></td> <td class='blacktext' width='655' align='center'><b>$film</b><br /><br />$desc<br /><br /><a href='$url' target='_blank'><b>Download Now</b></a> | <a href='$imdb' target='_blank'><b>IMDb</b></a></td> </tr> </table> "; } ?> <table width='100%'> <tr> <td> <div align="center"> <?php if (!$s<=0) echo "<a href='search.php?search=$search&s=$prev'>Prev</a>"; $i =1; for ($x=0;$x<$foundnum;$x=$x+$e) { echo " <a href='search.php?search=$search&s=$x'>$i</a> "; $i++; } if ($s<$foundnum-$e) echo "<a href='search.php?search=$search&s=$next'>Next</a>"; } } ?> </div> </td> </tr> </table> How to include root files from subdirectory in php? I have tried include '../configure.php'; but got error. Also tried include($DOCUMENT_ROOT."../configure.php"); but same result. For example, I have "root/admin" directory, and can't connect (from "/admin" dir) to the file configure.php which is in root. There are also other files to include. I have an include file that is included in every page of my website. I'm using sessions and trying to streamline code. The very first line of any page is my include file, and the very first thing in that file is: Code: [Select] <?php session_start(); ?> The page doesn't register that a session was started. Do I have to have session_start() on every single page? Or is there a way to have it in my include file so it is automatically on every page for me? Thank you! |