PHP - Php Pages In Files.
Hi, (Just wanna say thanks to the guy who helped me earlier as i cannot find the topic)
I have a game, it has 3 frames, menu, header & the main content, it WAS fine until i deleted a 4th frame, now when i click a link from the menu, instead of showing the link in the 'Main' content area, it takes you to the actual page with no menu, header etc. Thanks in advance! Similar Tutorialshello , i have created web application in which i have divided the all parts of page like - main header part - contains the <!DOCTYPE to <body> part other header part - contains the logo,slideshow of the header of page then the main part and at the end footer part i have created on folder which contains the detail of page content info referenced from the other pages from main content.. here i am facing problem as the style sheet , javascripts and the other header part of file is not references well.. how to do it? please guide me with correct solution awaiting for better response... I made this for my site and decided to share with the community. Depending on how you do the code and where, this can keep count of the views in different ways. Please read the somewhat directions have in the code, make a folder called counters, and be sure to include this below function file. I named the function file index.php and belongs in the counters folder you make. <?php /* name this file index.php and place it into a folder called counters the function will create a unique text file for each unique item, good for posts or pages and store all the files in the counters folder For the total website views,add this to your header file or top of your page <?php include('counters/index.php'); $website_view_url = "http://".$_SERVER['HTTP_HOST']; } $website_views = getViews("$website_view_url"); echo "<br />".$website_views."<br />"; ?> For the total pages or scripts views,add this to your header file or top of your page <?php include('counters/index.php'); $total_page_view_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; } $total_page_views = getViews("$total_page_view_url"); echo "<br />".$total_page_views."<br />"; ?> For entire urls including queries,add this to your header file or top of your page <?php include('counters/index.php'); $page_queries_view_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; if (!empty($_SERVER["QUERY_STRING"])) { $page_queries_view_url .= "?".$_SERVER['QUERY_STRING']; } $page_queries_views = getViews("$page_queries_view_url"); echo "<br />".$page_views."<br />"; ?> for usage in posts like by id: if do not want the pages counted and did not do the above code,include the below somewhere near the beginning of your page <?php include('counters/index.php');?> Then in the posts loop, you can associate your $row['id']; or some other unique value <?php $post_views = $row['id']; $post_views = getViews("$post_views"); echo "<br />Post Views ".$post_views."<br />"; ?> if would like to combine any the above or use them all, just be sure to just include include('counters/index.php'); only one time */ function getViews($views_count_value) { $views_count_value = md5("$views_count_value"); $views_count_file_name = "counters/$views_count_value.txt"; if (!file_exists($views_count_file_name)) { $views_count =0; $file_handle = fopen($views_count_file_name, 'w') or die("can't open file"); fwrite($file_handle, "$views_count"); fclose($file_handle); } $file_handle = fopen($views_count_file_name, "r"); $views_count = fread($file_handle, filesize("$views_count_file_name")); fclose($file_handle); if ($views_count <= 0){ $views_count =1; } else { ++$views_count; } $file_handle = fopen($views_count_file_name, "w+"); fwrite($file_handle, "$views_count"); fclose($file_handle); return("$views_count"); } ?> Hello I have a simple question about file handling... Is it possible to list all files in directories / subdirectories, and then read ALL files in those dirs, and put the content of their file into an array? Like this: array: [SomePath/test.php] = "All In this php file is being read by a new smart function!"; [SomePath/Weird/hello.txt = "Hello world. This is me and im just trying to get some help!";and so on, until no further files exists in that rootdir. All my attempts went totally crazy and none of them works... therefore i need to ask you for help. Do you have any ideas how to do this? If so, how can I be able to do it? Thanks in Advance, pros So far I have managed to create an upload process which uploads a picture, updates the database on file location and then tries to upload the db a 2nd time to update the Thumbnails file location (i tried updating the thumbnails location in one go and for some reason this causes failure) But the main problem is that it doesn't upload some files Here is my upload.php <?php include 'dbconnect.php'; $statusMsg = ''; $Title = $conn -> real_escape_string($_POST['Title']) ; $BodyText = $conn -> real_escape_string($_POST['ThreadBody']) ; // File upload path $targetDir = "upload/"; $fileName = basename($_FILES["file"]["name"]); $targetFilePath = $targetDir . $fileName; $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION); $Thumbnail = "upload/Thumbnails/'$fileName'"; if(isset($_POST["submit"]) && !empty($_FILES["file"]["name"])){ // Allow certain file formats $allowTypes = array('jpg','png','jpeg','gif','pdf', "webm", "mp4"); if(in_array($fileType, $allowTypes)){ // Upload file to server if(move_uploaded_file($_FILES["file"]["tmp_name"], $targetFilePath)){ // Insert image file name into database $insert = $conn->query("INSERT into Threads (Title, ThreadBody, filename) VALUES ('$Title', '$BodyText', '$fileName')"); if($insert){ $statusMsg = "The file ".$fileName. " has been uploaded successfully."; $targetFilePathArg = escapeshellarg($targetFilePath); $output=null; $retval=null; //exec("convert $targetFilePathArg -resize 300x200 ./upload/Thumbnails/'$fileName'", $output, $retval); exec("convert $targetFilePathArg -resize 200x200 $Thumbnail", $output, $retval); echo "REturned with status $retval and output:\n" ; if ($retval == null) { echo "Retval is null\n" ; echo "Thumbnail equals $Thumbnail\n" ; } }else{ $statusMsg = "File upload failed, please try again."; } }else{ $statusMsg = "Sorry, there was an error uploading your file."; } }else{ $statusMsg = 'Sorry, only JPG, JPEG, PNG, GIF, mp4, webm & PDF files are allowed to upload.'; } }else{ $statusMsg = 'Please select a file to upload.'; } //Update SQL db by setting the thumbnail column to equal $Thumbnail $update = $conn->query("update Threads set thumbnail = '$Thumbnail' where filename = '$fileName'"); if($update){ $statusMsg = "Updated the thumbnail to sql correctly."; echo $statusMsg ; } else { echo "\n Failed to update Thumbnail. Thumbnail equals $Thumbnail" ; } // Display status message echo $statusMsg; ?> And this does work on most files however it is not working on a 9.9mb png fileĀ which is named "test.png" I tested on another 3.3 mb gif file and that failed too? For some reason it returns the following Updated the thumbnail to sql correctly.Updated the thumbnail to sql correctly. Whereas on the files it works on it returns REturned with status 0 and output: Retval is null Thumbnail equals upload/Thumbnails/'rainbow-trh-stache.gif' Failed to update Thumbnail. Thumbnail equals upload/Thumbnails/'rainbow-trh-stache.gif'The file rainbow-trh-stache.gif has been uploaded successfully. Any idea on why this is? I am using WPSQT plugin in my blog site .I code some files in PHP also.how to add that files in plugin files.
like if I'm displaying a hundred entries , my website will be super long in length so I wanna break those hundred entries into maybe like 12 per page . Then click next page or the page number to view the next 12. Hello everyone, I am new to this site and new to working with php. I am wondering about a code that i could use for splash pages for members to be able to use them. I have the splash pages set up already but have not been able to figure out how to code it so that all the members of the site can use them to promote the site. Any help would be great thanks. Aaron hi guy's i have on one page select from table, and i don't know how to limit showing content from database on 3, and rest to make number under it and when i click on that number next 3 is showen? Something like on forum when you have more topics then you can show, on botom of page are showen numbers (links). Can some explain me how to do this? i put in while loop something like this Code: [Select] while ($prom = mysql_fetch_object($res) and $i<3) and now it is limited on showing first 3, my problem is showing next 3, and if there is more how to split it on 3 per page? Hi, so....i have these 2 pages, but they don't show up in browser....can't find the error so will ask your help guys index.php <?php session_start(); if(!isset($_SESSION["manager"])){ header("Location: admin_login.php"); exit(); } //Be sure to check that manager SESSION value is in database $managerID = preg_replace('#[^0-9]#i',",$_SESSION["id"]); // Filter everything but numbers and letters $manager = preg_replace('#[^A-Za-z0-9]#i',",$_SESSION["manager"]); //Filter everything but numbers and letters $password = preg_replace('#[^A-Za-z0-9]#i',",$_SESSION["password"]); //Filter everything but numbers and letters //Run MySQL query to be sure that this person is an admin and that their password session var equals the database //Connect to the MySQL Database include("../storescripts/connect_to_mysql.php"); $sql = mysql_query("SELECT * FROM admin WHERE id='$managerID AND username='$manager' AND password='$password' LIMIT 1"); //search user $existsCount = mysql_num_rows($sql); //count the row numbers if ($existsCount == 0){ //evaluate the count header("Location: ../index.php"); exit(); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>MyOnlineStore | Admin Area</title> <link rel="stylesheet" href="../style/style.css" type="text/css" media="screen"/> </head> <body> <div align="center" id="mainWrapper"> <?php include_once("../template_header.php");?> <p><br /> <br /> </p> <p> </p> <p><br /> </p> <div id="pageContent"> <div id="admin" align="left"> <h3>Hello what you want to do?</h3> <p><a href="#">Manage Inventory</a><br /> <a href="#">Manage afggagdfag</a></p> </div> </div> <?php include_once("../template_footer.php");?> </div> <p> </p> <p> </p> <p> </p> </body> </html> admin_login.php <?php session_start(); if(!isset($_SESSION["manager"])){ header("Location: admin_login.php"); exit(); } //Be sure to check that manager SESSION value is in database $managerID = preg_replace('#[^0-9]#i',",$_SESSION["id"]); // Filter everything but numbers and letters $manager = preg_replace('#[^A-Za-z0-9]#i',",$_SESSION["manager"]); //Filter everything but numbers and letters $password = preg_replace('#[^A-Za-z0-9]#i',",$_SESSION["password"]); //Filter everything but numbers and letters //Run MySQL query to be sure that this person is an admin and that their password session var equals the database //Connect to the MySQL Database include("../storescripts/connect_to_mysql.php"); $sql = mysql_query("SELECT * FROM admin WHERE id='$managerID AND username='$manager' AND password='$password' LIMIT 1"); //search user $existsCount = mysql_num_rows($sql); //count the row numbers if ($existsCount == 0){ //evaluate the count header("Location: ../index.php"); exit(); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>MyOnlineStore | Admin Area</title> <link rel="stylesheet" href="../style/style.css" type="text/css" media="screen"/> </head> <body> <div align="center" id="mainWrapper"> <?php include_once("../template_header.php");?> <p><br /> <br /> </p> <p> </p> <p><br /> </p> <div id="pageContent"> <div id="admin" align="left"> <h3>Hello what you want to do?</h3> <p><a href="#">Manage Inventory</a><br /> <a href="#">Manage afggagdfag</a></p> </div> </div> <?php include_once("../template_footer.php");?> </div> <p> </p> <p> </p> <p> </p> </body> </html> Hi, Im trying to make pages switch. Read data from database and but every 10 data in 1 pages. I got my way on making pages by using PHP, but my way is not efficient. Please teach me and tell me the correct way or concept to do it. Or is there any website teaching this? Appreciate for the help thanks. how to convert php pages to api Hey, i was wondering if anyone knew how i could make a script so when i register a new account... There will be made a link in members.php and when you go there you see the new registered (and the old ones) name... And once you click it you get into their page (their page should be created when registering a new account). Im pretty blank how to do it so ill ask you guys :/ How can I go about making dynamic pages? eg. user types "phpfreaks.com/index.php?page=name" Hi, can someone help me to understand this? What i want to do is to write some information in a form and after i submit the form that data will be in a new php page. Thanks in advance Hi, I am looking for reliable, effective code to cache one or two of my website webpages. I know there are packages like the pear cache lite but is far beyond my needs and complex in terms of never used pear before etc. I am looking for a good cache class perhaps or a link to a good cache script. Does anyone have any code they would like to share or know of any good cache classes etc? I want to keep it relatively simple if possible. Thanks for any suggestions, help. PHPLOVER what I'm trying to do is to setup a page called settings.php that the admin runs to order to turn option in the web site on or off. I don't know how to do this since I never done this before. My code is below. <link href="mainframe.css" rel="stylesheet" type="text/css"> <?php require_once '../config.php'; $db = new DbConnector(); $db->DbConnector(); if(isset($_GET['submit'])) { $db->query('UPDATE '.SETTING_TABLE.' SET option='.$_POST['banner'].' WHERE setname='''); echo 'Process complete'; } $result = $db->query('SELECT * FROM '.SETTINGS_TABLE); echo '<table border="1">'; echo '<tr>'; echo '<form action="settings.php" methed="post">'; while($row = $db->fetchArray($result)) { echo '<tr>'; echo '<td>'.$row['setname'].'</td><td><select size="1" name="'.$row['setname']'">'; echo '<option value="on">on</option>'; echo '<option value="off">off</option>'; echo '</td>'; echo "</tr>"; } echo '<td><input type="submit" value="Submit" name="submit">'; echo '</td>'; echo "</tr>"; echo "</form>"; echo "</table>"; /* */ ?> <h2>Settings</h2> <a href = "admin.php">Admin Panel</a> Hello, I was wondering if someone could help me to "get" the webaddress of a current webpage and then pull off pieces of the page. All of my pages look like: http://localhost:8888/algebra_book/Chapters/Quadratic_Functions/introductory_problem.php BUT, the stuff to the left of Quadratic Functions WILL change in the future. So all will look like: *Quadratic_Functions/introductory_problem.php Then, I'd like to pull off a $chapter variable, which in this case is Quadratic_Functions and a $page_name variable which in this case will be introductory_problem. Thanks so much. Hi, I hope someone can help. I currently have a page that includes the main page after login, however I am looking into changing this so that when a user logs in they get 3/4 linked images that, when clicked dynamically load/include the page based on the select i.e. user selects the image laptop, that has a hyperlink, it loads the laptop page. If anyone has any ideas or suggestion,i'd appreciate it. Hi everyone, I would like to put up online exercices wth answers. These exercices and answers should only be visible 1 by 1. E.g. you start with Q1, submit yr answer and then you would see the answer. Then push next Q button and the former Q dissapears. How do I put everything in 1 srcecode, 1 php file? Thnx Hey all, I've a problem with including of my pages. When I do choose lotto on index.php , I do get the page and also can choose how many roster I want. But I can't see my lotto results, because it does refresh to the index.php again. How can I fix this problem ? this is the code of index.php: Code: [Select] <?php echo '<table class="achtergrond" border="1">'; echo '<tr><td colspan="3">'; /* Keuzelijst tonen */ echo '<center><form action="'.$_SERVER['php_self'].'" method="POST"><select name="test">'; echo '<option selected>Kies een formulier</option></center>'; echo '<option value="1">Lotto</option>'; echo '<option value="2">Euromillions</option>'; echo '</select>'; echo '<button type="submit" name="knop">OK</button>'; echo '</form>'; echo '</td></tr>'; /* Als er op de knop gedrukt is , voer het lottoformulier uit*/ if(isset($_POST['knop'])) { echo '<tr><td>'; echo $waarde; /* variabel $waarde een waarde insteken via keuzelijst */ switch($_POST['test']) { case 1; include('formulieren/lotto.php'); case 2; include('formulieren/euromillions.php'); } echo '</td></tr>'; echo '</table>'; } ?> and this is the code of lotto.php: Code: [Select] <?php echo '<table class="achtergrond">'; echo '<tr><td colspan="3">'; /* Keuzelijst tonen */ echo '<center><form action="'.$_SERVER['php_self'].'" method="POST"><select name="lotto">'; echo '<option selected>Kies aantal rooster</option></center>'; echo '<option value="1">2 roosters</option>'; echo '<option value="2">4 roosters</option>'; echo '<option value="3">6 roosters</option>'; echo '<option value="4">8 roosters</option>'; echo '<option value="5">10 roosters</option>'; echo '<option value="6">12 roosters</option>'; echo '</select>'; echo '<button type="submit" name="knop1">OK</button>'; echo '</form>'; echo '</td></tr>'; /* Als er op de knop gedrukt is , voer het lottoformulier uit*/ if(isset($_POST['knop1'])) { /* variabel $waarde een waarde insteken via keuzelijst */ switch($_POST['lotto']) { case 0; $waarde2 = 0; break; case 1; $waarde2 = 1; break; case 2; $waarde2 = 2; break; case 3; $waarde2 = 3; break; case 4; $waarde2 = 4; break; case 5; $waarde2 = 5; break; case 6; $waarde2 = 6; break; }... |