PHP - Php Rookie: Reloading Same Dynamic Page
Hi everybody
I am a PHP rookie for now, and I want to reload the same dynamic page - it's content in several languages - by clicking little flags which are located at some point on the page - AND ITS NOT WORKING. Clicking on the flag triggers a PHP script which basically says Code: [Select] ]$_SESSION['lang'] = <Some_language>; require ('webpage.php'); where webpage.php is the dynamic page, in different languages, with it's content drawn out from a database (which contains the content in all languages I chose to display, blah, blah) Funny thing - when I look at the page html (View Page Source) - it seems OK (identical from one page to the next) ! But WHAT is displayed after the first attempt to change the language is not. Is something fundamentally wrong with my approach ? Mike Similar TutorialsHello, I have links at above of the page. if i click a link a new page will appear. The menu links above are same for all pages. Which is better reloading the whole page with all menu links or keeping the above menu link permanent/unchange reloading bottom division with ajax? I mean only one page will contain the menu.Is it better? Or every page will contain the menu above.Is it better then the first one? I say many web site they have link menus above if i click a link from above it seems the whole page reloads or chages. For example:http://www.sitepoint.com/ Thank you. I have a php generated image: (number.txt contains a number 1 or 2) pic.php Code: [Select] <?php // Set the content-type header('Content-type: image/bmp'); // Create the image $im = imagecreatetruecolor(80, 80); $count_my_page = ("number.txt"); $hits = file($count_my_page); if ($hits[0] == 1) { $im = imagecreatefrompng("image1.png"); $hits[0] ++; $fp = fopen($count_my_page , "w"); fputs($fp , "$hits[0]"); fclose($fp); }else{ $im = imagecreatefrompng("image2.png"); $hits[0] --; $fp = fopen($count_my_page , "w"); fputs($fp , "$hits[0]"); fclose($fp); } // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 1, 1, 1); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); imagedestroy($im); ?> And I have another page index.html Code: [Select] <img src="pic.php"> <img src="pic.php"> Basically, I need one of the images on the index page to be image1 and then the second image to be image2, but it must be contained within the php file because I am unable to edit index.html. Is there anyway to do this? The method I have now where it reads a file to see if it's value is 1 or 2 doesn't seem to compute each time the image is generated. I have tried header("Cache-Control: no-cache"); header("Pragma: no-cache"); in the image code to force it not to cache but to no avail. Can anyone solve this? hey guys im sure this is possible im wondering how a user can execute a mysql query by a click of a button but without the page reloading...thanks guys What is the best function to use to ensure an order is not re-entered when the user selects reload page? I can link code if you'd like but I'm only looking for a direction to go in and search google with. 'reload current page inserts extra' that google search hasn't been fruitful. I'm trying to show the same data, but updated right away. For example. I want to update my coords on a map and refresh a div to show the new data, but as the code now, it keeps the same data until I reload the page. Here is the code I have now. if ($north) { $ylocation = $users['y'] + 1; if ($ylocation > 5) { $ylocation = 0; } $locationyupdate = ("UPDATE players SET y = '$ylocation' WHERE name='$users[name]'"); mysql_query($locationyupdate) or die("could not register");?> <script type="text/javascript"> $('#npc').load('npc.php'); $('#description').load('description.php'); </script><?} The update code is before the reload script for the two div's. The data DOES change in the database, but the two div's won't display the new data until it is refreshed again. Do I need to reactivate fetch to get the new data? This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=305930.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=314750.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=326913.0 Perhaps a slight trouble, but I can not solve it:
Match only path like:
Trainings/1/test.pdf
but dont match one more directory like this:
Trainings/1/4/other.pdf
Any suggestions?
0 down vote favorite I know this is a rookie question but whats actually happening with a progress bar what is it actually monitoring. I figure the only way to understand it is to get this answer. when i run a piece off php code how can i get a progress bar to monitor it while it runs untill completion off the code?? most progressbars i have seen are file upload and download. is it monitoring the amount off requests the browser sends when upload the file so its monitoring the bytes that are being transfer? Can someone please give me a better understanding off whats going on? I just want a simple progress bar to monitor progress while my php code is running so say if i am running this simple code to backup a websites files and folders, how could i do this??? Code: [Select] <?php if ( isset($_POST['backup']) ) { if(exec("cd {$_SERVER['DOCUMENT_ROOT']}/wp-content/plugins/s3bk/files;tar -cvpzf backup.tar ".get_option( 'isd-server')."")) { echo "done"; } } <form id="backup" method='post' action=''> <input type='submit' class="button" name='backup' value='backup'> sorry for the rookie question just really want to get my head around whats actually happening??? Thanks Hello everyone. I'm in the making of a dynamic (hopefully) site to let people browse, listen and download the music I've made through the years, where I can use an upload form (uploading a file + some relevant info) to automatically make a ... song.php?id=*** site. (By now you know, I'm totally clueless ) I've set up a database, an upload form, it's tested, everything works so far (a file gets uploaded to the server, and relevant info is posted to the db). The problem is, I dont know how to use this effectively. I'm able to retrieve a Title through searching for a specific artisthandle, like so: Code: [Select] $result = mysql_query("SELECT * FROM uploading WHERE Artist='artistname'"); while($row = mysql_fetch_array($result)) { echo "..: Artistname"; echo "<br />"; echo $row['Title']; echo "<br />"; } But from here on out, I don't know - and I really fail to find tutorials (which have been my only source as of now). In general, I want my site to, systematically, work much like e.g. www.ctgmusic.com. How is it set up? How do you make ...php/?id=''' pages? How does it work? What variables or functions do I need to use? If anyone have an easy-going tutorial on these basics, I would be extatic! Hope to hear from you I'm a little confused with the use of absolute paths in PHP. I've always used relative paths but it's becoming an issue with some of the apps I'm working with and absolute would solve the problem. The thing is, I'm getting different results in different places and I'm a little confused. With regular HTML I seem to be able to use / as the root of my site. So if I do the following... Code: [Select] <img src="/images/name.jpg" /> That works fine no matter what page it's called from in the site and no matter what directory that page is in. I need to be able to do that same thing with PHP. Now, in my custom 404 page I have the following... Code: [Select] if($AddressURL == 'http://www.domain.com/blog/files/filename.zip') { header('HTTP/1.1 301 Moved Permanently'); header('Location: /download/filename.zip'); exit(); } That actually works just fine. If I go to the /blog/files/filename.zip (which doesn't exist) in a web browser it winds up downloading the file at www.domain.com/download/filename.zip as expected. Now where I get confused is that include files don't seem to work like that with PHP. If I do this... Code: [Select] require_once('/includes/config.php'); That winds up looking for an /includes folder all the way back at the local server root, not just the web root. so it's looking for /var/includes instead of /var/www/includes and of course that doesn't end up working. So, how come the include file paths work differently than regular HTML paths or header redirects in PHP? Is there any simple way I can always refer to the SITE root no matter what server it's running from? I've tried playing with $_SERVER['DOCUMENT_ROOT'] but it only seems to return the root of the current document, not the root of the whole site. So if I use it within a php file located in /var/www/includes/test.php it considers /includes the root which is not what I want. Any information would be greatly appreciated. Thanks! I have been trying to insert data into my database thru php script with no luck. I think its has to do with not being able access my database. My question is when I use MySQL command client and enter the password and get mysql> does that mean I can use that password to access my databases as long as I point to the correct database with the mysqli_connect function. I dont think I fully understand how this works. I have everything stored on my local computer and I use "localhost" in mysqli_connect function. hey guys how you all doing? ok im really looking for some help i've been playing with this code for quite some time now and still not got the hang of it. i'm currently trying to code a dynamic website as a portfolio for my designs and im trying to get to view the news.php file with an 'id' to view in the index file using an include() but for some reason its not happening very well. i keep getting the error message: Warning: include(inc/news.php?id=) [function.include]: failed to open stream: No error in C:\xampplite\htdocs\lukerodham\old\index.php on line 218 Warning: include() [function.include]: Failed opening 'inc/news.php?id=' for inclusion (include_path='.;C:\xampplite\php\PEAR') in C:\xampplite\htdocs\lukerodham\old\index.php on line 218 just wondering if anyone could shed any light on what i may have done wrong thanks guys ive left part of the code below if this will help. Code: [Select] <?php $page = $_GET['page']; $news = $_GET['id']; if(!$page){ getnews(); } else { if($page = news){ include("inc/news.php?id=".$news); } else include("inc/".$page.".php"); } ?> hey guys stuck on this one cant see why it wont work, hope someone can help. im trying to just change the content not the whole page while still only a admin can see it. if you get my jist. but everytime i click the link nothing shows up for some reason. thanks in advance. Code: [Select] <?php session_start(); include("login.php"); ?> <html> <body> <?php if(isset($_SESSION['user'])){ ?> <table width='90%' height='100%' border='1' align='center'> <tr valign='top'> <td><table width='60%' border='0' align='center'> <tr> <td colspan='3' align='center'>You've succesfully logged in.<p></td> </tr> <tr> <td><a href='index.php?page=post.php'>post news</a></td> <td><a href='index.php?page=mail.php'>mailing list</a></td> <td><a href='index.php?page=stats.php'>site stats</a></td> <td><a href='login.php?logout'>logout</a></p></td> </tr> <tr> <td colspan='3'> <?php $page = $_GET['page']; if($page){ include("inc/".$page.".php"); } ?> </td> </tr> </table></td> </tr> </table> ?> <?php } else { die(); } ?> </body> </html> I have written the following php statement and it works to show pages titles if I have an id in the url example. www.mysite.com/index.php?id=3 then the right page title is displayed but if I am on my home page www.mysite.com with no id the page title isn't displayed. I am running the code in the header in the title brackets. here is the code. The last else doesn't display my home page title any help would be great thank you very much... <title> <? if (isset($_GET['id'])) if($_GET['id'] == '1') { echo "LBT Services Page"; } else if($_GET['id'] == '2') { echo "About LBT"; } else if($_GET['id'] == '3') { echo "Contact LBT"; } else if($_GET['id'] == '4') { echo "Your Message to LBT has been Submitted"; } else if($_GET['id'] == '5') { echo "LBT Links Page"; } else if($_GET['id'] == '6') { echo "LBT Back-UP Plans"; } else { echo "LBT Home page"; } ?></title> Hi Guys, I'm pulling a html page from a database (html newsletter). In the code I have links that will open a lightbox and allow the user to add news articles into it via ajax. So the html is being updated without being send back to the browser. I have a "save" button which when the user clicks, I want to grab all of the html of the page and save it to the database. Not quite sure how to do this as the html that is being saved, is updated since it was retrieved by the browser. Does anyone know how I would display a dynamic page title to my content pages? I currently have my index.php displaying the title for my page, but the content that i am displaying dynamicly also uses this title, want these pages to have their own titles.. Thanks Hey, I'm trying to make a dynamic php website. So far it's been working fine. All my pages are in a page folder and with my code I'm able to access it via "index.php?page=nameofphpfile" etc. Now I added a page under there with a similar code to the index and it is conflicting. This is the code for the index.php $page=$_GET['page']; if ($page) { include("pages/".$page.".php"); } else { echo "This Page Does Not Exist."; } } On my skin.php page when I try to put a GET variable in, I get the word THIS PAGE DOES NOT EXIST. I'm really stuck and need help, I know it's brief so please help me out here! -Francis |