PHP - An External Php File?
I was just wondering if it was possible to have an external php file that can be included in the head of a web page, like a .js file. If this isn't possible maybe have a .js file containing php code that can be executed regarding the JavaScript around it...
Similar Tutorialswhen tyring to pass a variable to a extenal javascript file it just shows up as a sting and the variable isnt beening executed
var timezone_offset = <?= $timezone_offset ?>;im guessing its probably down to the fact the variable is being passed from my framework controller... so im wondering how do you send a variable to a external javascript file when using a framework? $this->view->timezone_offset = "test"; // in my controller // passing varibales to template in my view if (preg_match("/\.html$/i", $file_name)) { extract($this->_variables); require_once PRIVATE_DIRECTORY . 'application' . DS . 'views' . DS . $file_name; }thanks guys What is the best way to load a .jsp file on an external sever? Hi, I am looking to fetch the contents of https://bb.kdg.be/webapps/blackboard/content/listContent.jsp?course_id=_98522_1&content_id=_1288143_1 in PHP However, the page works with cookies, javascript redirect, and https. Therefor I cannot manage to make a local copy of the actual contents. I have tried with curl, file_get_contents, file, fopen, and numerous user-written functions online, none of which worked. Please make sure you TEST your answer before posting it, because it is probably not as obvious as it seems! Thanks! My external css file works on everything except for body, however, it works when I include the css on the page itself:
body{ margin-top: 0px; padding-top: 0px; margin-bottom: 0px; padding-bottom: 0px; background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNS4xIFdpbmRvd3MiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OERFQkEzRUJDNUM5MTFFMUE3NzBCMTZBMEExNEQ5NUQiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OERFQkEzRUNDNUM5MTFFMUE3NzBCMTZBMEExNEQ5NUQiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo4REVCQTNFOUM1QzkxMUUxQTc3MEIxNkEwQTE0RDk1RCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4REVCQTNFQUM1QzkxMUUxQTc3MEIxNkEwQTE0RDk1RCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PiSp0pIAAAAySURBVHjaYmBgYOAHYmYGCADR/CDiDxDzQAW5gPgLlM3ACsQKUBqhBYjZkY3CMBMgwACvHQKnyUp+6gAAAABJRU5ErkJggg=="); background-color:#b20a22; -webkit-transition: all 300ms ease-in-out; -moz-transition: all 300ms ease-in-out; -ms-transition: all 300ms ease-in-out; -o-transition: all 300ms ease-in-out; transition: all 300ms ease-in-out; }What could be wrong? Hi! I am trying to use the View Model Design Pattern in my application The problem is that it is the first time I use it and I am a beginner. So, I have the logic in the Model and the "front end" in View. I am talking about a sign up page. In the current Html file I am trying to access an error array from the model file and display it to the user above the input field.
Here is the a snippet from the Model (Signup.php) $account = new Account($con); //the account which takes as param the db connection $error = null; //the array // anything the user writes gets inside this array if (isset($_POST["submitButton"])) { $firstName = UnifyFormInput::unifyUserFLName($_POST["firstName"]); $lastName = UnifyFormInput::unifyUserFLName($_POST["lastName"]); $username = UnifyFormInput::unifyFormUserName($_POST["username"]); $email = UnifyFormInput::unifyFormEmail($_POST["email"]); $password = UnifyFormInput::unifyFormPassword($_POST["password"]); //contain true or false based on the query being successful or not $success = $account->register($firstName, $lastName, $username, $email, $password); if ($success) { $_SESSION["userLoggedIn"] = $username; header("Location:index.php"); }else{ $error = $account->getError(Constants::$registerFailed); } } //compact — creates array containing variables and their values //call render function from View file to show the register page content View::render('register', compact('error')); And here is the view: <?php if (!empty($error)) { echo $account->getError(Constants::$loginFailed); } ?> <input type="text" class="form-control" name="firstName" placeholder= "First Name" value="<?php getInputValue("firstName"); ?>" required>
Hi All,
I want to include my terms and conditions in an ebay listing.
The reason for this is to ease the process if and when i need to change the terms.
I stopped using eBay about a year ago and back then is used this code to display my terms withing the eBay lisitng.
<?php include ('http://www.example.com/terms.php'); ?>
NOw when i put that code into the listing it doesnt display.
I tested this out on my own server and it didnt display there either so I now it isnt eBay.
I also tried emoving the brackets without success.
The only way I can get it to display as include on my server is to use a relative path, which isnt the result I need
Has something changed in the past year?
Is there another way to display an external file using an absolute path to an external file?
Many Thanks
This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=319963.0 the strange thing is...I have the exact same script on another part of my page and it works! the only thing that changed are the variable names and the path (which ive checked 27000 times) What this should do is check if you have a signature in the external file and if you do and you fill out the form correctly then it replaces your old signature with your new one. and if you dont have a signature already and filled out the form correctly then it should write your signature to the file...for some reason this isnt working after checking and rechecking...i need a second pair of eyes. Help please! if (isset($_POST['change_submit2'])) { if (($_SESSION['logged_in'] == '1') && ($signature_test != '1') && ($_POST['change_box2'] == 'CHANGE') && ($invalid_character_test != '1') && ($invalid_character_test1 != '1')) { $fh1 = fopen($users_signatures_path, 'r+'); fwrite($fh1, $sig_front); frwrite($fh1, $_POST['signature']); fwrite($fh1, $sig_back); fwrite($fh1, ' '); flose($fh1); echo 'You have succesfully created a signature!'; } elseif (($_SESSION['logged_in'] == '1') && ($signature_test == '1') && ($_POST['change_box2'] == 'CHANGE') && ($invalid_character_test != '1') && ($invalid_character_test1 != '1')) { $users_signatures_path1 = "../../users/users_signatures.txt"; $fh1 = fopen($users_signatures_path1, 'r+'); $read_fh1 = fread($_fh1, filesize($users_signatures_path1)); $the_new_sig = str_replace($mcurrent_sig, $mnew_sig, $read_fh1); fclose($fh1); $fh1 = fopen($users_signatures_path1, 'r+'); fwrite($fh1, $the_new_sig); fclose($fh1); echo $mnew_sig; echo 'Your signature has been succesfully changed!'; } elseif ($_SESSION['logged_in'] != '1') { echo 'You need to be logged in!'; } elseif ($_POST['change_box2'] != 'CHANGE') { echo 'You must fill in the "CHANGE" box!'; } elseif ($invalid_character_test == '1') { echo 'Contains illegal characters!'; } elseif ($invalid_character_test1 == '1') { echo 'Contains illegal characters!'; } } Hi, just a very simple question: I have an array as follows: $langList = array('English', 'French', 'German', 'Dutch'); What's the easiest way to store this array in an external file, so that multiple php scripts can access its contents? And what is then the php line I need to retrieve the array from the external file? Thanks! I would like a part of my script to link to an external sites script It doesn't seem to be doing it though Othersite.com - index.php?name=hello&status=1 I would like my post.php to run that above. Can it be done? Hi all,
So im trying to improve on my PHP as my knowledge isn't that great.
lets say for argument sake my ip is:
192.168.0.1
im trying to set a external variable to set this as the url.
so on each page i use, for each link instead of typing out the ip address i can simply type:
<a href="{url}/index.php">Home</a>
and then if it is possible, to do something like this:
<link rel="stylesheet" href="{url}/main.css" type="text/css">
all in one file so in my php pages i can simple include 1 php file and it will have all of the relevant stylesheets ect linked to it.
Edited by srwright, 30 May 2014 - 01:18 PM. Hi, I have a peice of code which publishes an image with a link from my database. However I cant get it to use external links. My code is: echo "<a href=\"" .$link . "\"> <img src=\"" .$image ."\" /> </a><BR />"; I have tried all the options I can think of but I cant get it work. Can anyone advise please? I'm building a program in php that will be able to view YouTube videos from the URL. So if I type: http://www.youtube.com/watch?v=(Video ID) Then my program works and it will return the Video ID! But then some idiot clicks on a related video and this URL is generated: http://www.youtube.com/watch?v=(Video ID)&feature=related And my program strips the first bit by replacing "http://www.youtube.com/watch?v=" with an empty string "" but then I'm still left with the "&feature=related" I thought about just replacing that with an empty string as well but sometimes there can be a URL like this: &feature=g-vrec&context=G28d9eecRVAAAAAAAABA Which has a different unique code each time. So I thought it'd be much simpler if I could use $_GET[] with an external URL, so the user types in: http://www.youtube.com/watch?v=(Video ID)&feature=related It just gets the "v" value rather than my buggy replace thing. Thanks. (Posted this in the MySQL section, but i think the php section might be the proper place)
I have a webshop db where i want to export some things linke order information to another external db on another server etc.
Example of things to move:
Table1 - orderid - orderdate Table2 - adress - shippingmethodI ONLY want it to export and import things that is not currently there. How can this be done in a php script? I know basically nothing about PHP but i have a few websites i manage that are built with PHP. I plan to learn PHP but for the time being learning Javascript has a wider range of usability for me. That being said, Im trying to link to an XML sitemap using php. in html i would use Code: [Select] <link href="sitemap.xml" /> how can i do this in PHP? I have searched google and such for how to do this but was unable to find an explanation that i could understand as relating to my need. Ok, I would just like some advice on how to go about doing something. A website that alot of my friends use to make their builds in-game goes down frequently causing them not to be able to pull up their build information. I would like to be able to use php to copy not only the html source, but the images as well to my websvr to be able to view when their site is offline. Now I know I could simply just click page -> save as complete html in internet explorer and then upload that... However I don't want to have to do that for everyone stuff.. its time consuming.. I was hoping to automate the process with a script. I know how to get the html source from a website, but I don't know how to pull the content "pictures ect." to make it actually look like their site and have more than just text. I'll appreciate any advice you can give, I think some simple direction should be enough to get me going. hi, I am building a web app and need all my php on one page and links posting to same page etc, at the moment, I am linking to my townpubs.php page see code below: townpubs.php Code: [Select] <!doctype html> <?php include "../config.php"; $loggedIn = (isset($_COOKIE['loggedin']) && $_COOKIE['loggedin'] == 'true')?true:false; $town = $_REQUEST['RSTOWN']; $towns = mysql_query("SELECT * FROM pubs WHERE RSTOWN = '".$town."' ORDER BY RSTOWN ASC"); ?> <html> <head> <meta charset="UTF-8" /> <title>My Pub Space v1.0 β</title> <style type="text/css" media="screen">@import "jqtouch/jqtouch.min.css";</style> <style type="text/css" media="screen">@import "themes/jqt/theme.min.css";</style> <script src="jqtouch/jquery.1.3.2.min.js" type="text/javascript" charset="utf-8"></script> <script src="jqtouch/jqtouch.min.js" type="application/x-javascript" charset="utf-8"></script> <script type="text/javascript" charset="utf-8"> var jQT = new $.jQTouch({ icon: 'jqtouch.png', addGlossToIcon: false, startupScreen: 'jqt_startup.png', statusBar: 'black', preloadImages: [ 'themes/jqt/img/back_button.png', 'themes/jqt/img/back_button_clicked.png', 'themes/jqt/img/button_clicked.png', 'themes/jqt/img/grayButton.png', 'themes/jqt/img/whiteButton.png', 'themes/jqt/img/loading.gif' ] }); </script> </head> <body> <!-- TOWNS --> <div id="towns" class="current"> <div class="toolbar"> <h1>View Pubs</h1> <a class="back" href="index.php" rel="external">Home</a> </div> <h2>Pubs in <?php echo $town ?></h2> <ul class="plastic"> <?php while($row1 = mysql_fetch_array($towns)) { echo '<li class="arrow"><a href="pubinfo.php?PUBID='.$row1['PUBID'].'" rel="external">'.$row1['rsPubName'].'</a></li>'; } ?> </ul> </div> </body> </html> I would like to have this on my index.php page: index.php Code: [Select] <!doctype html> <?php include "../config.php"; $loggedIn = (isset($_COOKIE['loggedin']) && $_COOKIE['loggedin'] == 'true')?true:false; $query1 = "SELECT DISTINCT rsTown FROM pubs ORDER BY rsTown asc"; $result = mysql_query($query1); $towns = mysql_query("SELECT DISTINCT RSTOWN, COUNT(PUBID) As PubCount FROM pubs GROUP BY RSTOWN ORDER BY RSTOWN ASC"); $counties = mysql_query("SELECT DISTINCT RSCOUNTY, COUNT(PUBID) As PubCount1 FROM pubs GROUP BY RSCOUNTY ORDER BY RSCOUNTY ASC"); if ($loggedin == 'true'){ $locals = mysql_query("SELECT * FROM pubs INNER JOIN favepub_copy ON pubs.PUBID=favepub_copy.PUBID WHERE USERID='".$_SESSION['USERID']."' ORDER BY rsPubName asc"); } ?> <html> <head> <meta charset="UTF-8" /> <title>My Pub Space v1.0 β</title> <style type="text/css" media="screen">@import "jqtouch/jqtouch.min.css";</style> <style type="text/css" media="screen">@import "themes/jqt/theme.min.css";</style> <script src="jqtouch/jquery.1.3.2.min.js" type="text/javascript" charset="utf-8"></script> <script src="jqtouch/jqtouch.min.js" type="application/x-javascript" charset="utf-8"></script> <script type="text/javascript" charset="utf-8"> var jQT = new $.jQTouch({ icon: 'jqtouch.png', addGlossToIcon: false, startupScreen: 'jqt_startup.png', statusBar: 'black', preloadImages: [ 'themes/jqt/img/back_button.png', 'themes/jqt/img/back_button_clicked.png', 'themes/jqt/img/button_clicked.png', 'themes/jqt/img/grayButton.png', 'themes/jqt/img/whiteButton.png', 'themes/jqt/img/loading.gif' ] }); </script> </head> <body> <div id="about" class="selectable"> <p><img src="jqtouch.png" /></p> <p><strong>My Pub Space</strong><br />Version 1.0 beta<br /> <a href="http://www.jbiddulph.com" target="_blank">By John Biddulph</a></p> <p><em>Mobile Web Development</em></p> <p><a href="mailto:john.mbiddulph@gmail.com" target="_blank">E-mail</a></p> <p><a href="http://twitter.com/#!/jmbiddulph" target="_blank">@jmbiddulph on Twitter</a></p> <p><br /><br /><a href="#" class="grayButton goback">Close</a></p> </div> <div id="home" class="current"> <?php if (!$loggedIn){ ?> <div class="toolbar"> <h1>My Pub Space</h1> <a href="#about" id="infoButton" class="button slideup">About</a> </div> <ul class="rounded"> <li class="forward"><a href="#signup">Register an account</a></li> <li class="forward"><a href="#login">Login</a></li> <li class="forward"><a href="#towns">View pubs by town</a></li> <li class="forward"><a href="#counties">View pubs by county</a></li> </ul> <div class="info"> <p>All Rights Reserved © 2011 mypubspace.com Created by: jbiddulph.com</p> </div> <?php } else { ?> <div class="toolbar"> <h1>Hi <?php echo $_SESSION['s_username'];?></h1> <a href="dologoff.php" rel="external" class="button">Logout</a> </div> <ul class="rounded"> <li class="forward"><a href="#locals">View Locals</a></li> <li class="forward"><a href="#towns">View Towns</a></li> <li class="forward"><a href="#counties">View Counties</a></li> </ul> <div class="info"> <p>All Rights Reserved © 2011 mypubspace.com Created by: jbiddulph.com</p> </div> <?php } ?> </div> <!-- LOCALS --> <div id="locals"> <div class="toolbar"> <h1>My Locals</h1> <a class="back" href="#home">Back</a> </div> <ul class="plastic"> <?php while($row1 = mysql_fetch_array($locals)) { echo '<li class="arrow"><a href="pubinfo.php?PUBID='.$row1['PUBID'].'" rel="external">'.$row1['rsPubName'].', '.$row1['rsTown'].'</a></li>'; } ?> </ul> </div> <!-- TOWNS --> <div id="towns"> <div class="toolbar"> <h1>View Towns</h1> <a class="back" href="#home">Back</a> </div> <ul class="edgetoedge"> <?php $ltr = ''; while($row1 = mysql_fetch_array($towns)) { $letter1 = substr($row1['RSTOWN'],0,1); if ($letter1 != $ltr) { print'<li class="sep">'. $letter1 .'</li>'; } $ltr = $letter1; echo '<li class="forward"><a href="townpubs.php?RSTOWN='.$row1['RSTOWN'].'" rel="external">'.$row1['RSTOWN'].'<small class="listcounter">'.$row1['PubCount'].'</small></a></li>'; } ?> </ul> </div> <!-- COUNTIES --> <div id="counties"> <div class="toolbar"> <h1>View Counties</h1> <a class="back" href="#home">Back</a> </div> <ul class="edgetoedge"> <?php $ltr = ''; while($row1 = mysql_fetch_array($counties)) { $letter1 = substr($row1['RSCOUNTY'],0,1); if ($letter1 != $ltr) { print'<li class="sep">'. $letter1 .'</li>'; } $ltr = $letter1; echo '<li class="forward"><a href="countypubs.php?RSCOUNTY='.$row1['RSCOUNTY'].'" rel="external">'.$row1['RSCOUNTY'].'<small class="listcounter">'.$row1['PubCount1'].'</small></a></li>'; } ?> </ul> </div> <form id="login" action="dologin.php" method="POST" class="form"> <div class="toolbar"> <h1>Login</h1> <a class="back" href="#">Back</a> </div> <ul class="rounded"> <li><input type="text" name="rsUser" value="" placeholder="Username" /></li> <li><input type="Password" name="rsPass" value="" placeholder="Password" /></li> </ul> <a style="margin:0 10px;color:rgba(0,0,0,.9)" href="#" class="submit whiteButton">Submit</a> </form> <form id="signup" action="dosignup.php" method="POST" class="form"> <div class="toolbar"> <h1>Sign up</h1> <a class="back" href="#">Back</a> </div> <ul class="rounded"> <li><select name="RSTOWN" class="postcodedrop"> <option value="">Choose your Town...</option> <?PHP while($row = mysql_fetch_array($result)) { echo '<option value="'.$row['rsTown'].'">'; echo $row['rsTown']; echo '</option>'; }?> </select></li> <li><input name="RSUSER" type="text" class="textbox" id="RSUSER" value="" placeholder="Username" /></li> <li><input type="Password" name="RSPASS" value="" placeholder="Password" /></li> <li>Male <input name="RSGENDER" type="radio" value="Male" /> Female <input name="rsGender" type="radio" value="Female" /></li> <li><input name="RSEMAIL" type="text" class="textbox" id="rsEmail" placeholder="Email" /></li> <li><input name="RSMOBILE" type="text" class="textbox" id="rsMobile" placeholder="Mobile No." /></li> <li><input name="RSAGE" type="text" class="textbox" id="datepicker" placeholder="DOB: dd/mm/yyyy" /></li> </ul> <a style="margin:0 10px;color:rgba(0,0,0,.9)" href="#" class="submit whiteButton">Submit</a> </form> </body> </html> I need to set empty variables at the top and link page to itself?! Okay the reason I'm doing it this way is because I work locally and then transfer them to the production site. For some reason, this isn't working even though when I view the page source, it has the right URL, but when it's clicked it goes to a blank page, but when I copy and paste, it goes to the right page. Anywho, this is what I'm trying: Code: [Select] <?php $homeURL = 'localhost:90/Elvonica'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Elvonica</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <link rel="stylesheet" type="text/css" href="<?php echo $homeURL; ?>/template/css/skySpirit.css" /> I didn't plug in the rest to ignore it since it's not part of the problem. It's printing: localhost:90/Elvonica/template/css/skySpirit.css, but when it's clicked, goes to blank page. When it is copied and pasted, it goes to the right page. I have a feeling you can't include PHP inside a link rel or any sort of that header information. If anyone could please help me how to do this, I would appreciate it. FYI: I did have just template/css/skySpirit.css and it worked until I go into a another directory like forums/index.php. Then it tries to go localhost:90/Elvonica/forums/template/css/skySpirit.css and it's not in there obviously. Thank you for anything that you can offer! I know how to do the includes with the dirname(__FILE__). Hello Everyone! I'm new to the forum and new to PHP. I'm curious about the limitations of PHP. I'm working a project that I'm not even sure is possible in PHP. The project is simple: I need a page that can track business reviews on external sites and report that activity to a database. Below is a simple mockup of the html. Code: [Select] <html> <head> <title>Boomerang Project</title> </head> <body> <h1>Like Our Work?</h1> <h2>Help Spread The Word.</h2> <p>Click on the links below to start writing a review about the service that we have provided you.</p> <h3>Complete 5 reviews recieve a gift certificate.</h3> <ul> <li><a href="" target="_blank">Yahoo</a></a></li> <li><a href="" target="_blank">Google</a></li> <li><a href="" target="_blank">Yelp</a></li> <li><a href="" target="_blank">Manta</a></li> <p>You have completed <!--Number-of-Reviews-Completed-->. <br /> <br /> <!--The form below doesn't appear until at least 5 reviews are confirmed to have been posted. At which point a script will reconfirm the postings and send 2 emails, one to business with client info and another email to client confirming the completion of the postings.--> <form> <fieldset> <label for="name">Name</label><input type="text" name="full-name" /><br /> <label for="address">Address</label><input type="text" name="address" /><br /> <label for="city">City</label><input type="text" name="city" /><br /> <label for="state">State</label><input type="text" name="state" /><br /> <label for="zipcode">Zip Code</label><input type="text" name="zipcode" /><br /> <label for="telephone">Telephone</label><input type="text" name="telephone" /><br /> <label for="email">Email</label><input type="text" name="emaile" /><br /> <input type="submit" /> </fieldset> </form> </body> </html> |