PHP - Problem With Second Web Page Content Using .htaccess Page Mod_rewrite
About a year ago I wrote a mod_rewrite in at sites htaccess file. It was to call a page that queried the database based on a unite code that was assigned to a member. If the member was assigned a code that was FL1001, the URL www.marketingteammates.com/FL1001 would bring up a page that quaried that member and displayed their database content.
In the users table of the site, it quaried the field webPageID and the information was called. It called a page webpage.php that quaried the info. The URL in the address bar still displayed www.marketingteammates.com/FL1001. Here are the lines of code in the htaccess file.
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([A-Za-z])([A-Za-z])([0-9]+)$ /webpage.php?webPageID=$1$2$3 [NC,L]I now have a second page completely different from the webpage.php. It is a page storeNumber.php and would query a field storeNumberID. This field could contain any kind of string such as Store#101, or mystore101, or #101 is my store. I tried using the same rewite rule just replaceing the webpage.php and variable with storeNumber.php and $storeNumberID. This doesn't work. It also leads me to wonder if there can even be two different pages in the mod_rewrite. How would it diferentiate one from the other. Thanks for any help in advance. Mike Similar TutorialsThis topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=321843.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=355043.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=357656.0 Hello everybody,
I am honestly quite a newb when it comes to mod_rewrite.
We run a small social media page with different areas and I would like to change the URLs to something more clean and professional.
User profiles look like this:
http://www.sky-mp3.com/index.php?action=cm&siteid=59&wahl=artists&tat=details&keyid=477siteid 59 is the artists list and the keyid at the end is the ID of the artist but should be like: http://www.sky-mp3.com/mischuraor in worse case like: http://www.sky-mp3.com/user/mischuraCMS pages look like this: http://www.sky-mp3.com/index.php?siteid=106but should be like: http://www.sky-mp3.com/charts(page name instead of siteid) What I know so far: - I have to add something to the .htaccess file - I need to change something in the code (but I don`t know where) Im good he? What would be the first step on the path to clean URLs for me? I found alot of infos here and there but found nothing yet for this specific case. Kind regards from and thx in advance from Cologne Hi every one I want to share a page content(or an article) into my facebook page via php . How should I do that ? Thanks Hi I use fake IP to check if my 503 custom error page works but it doesn't?. I have another question should i stop people from hotlinking to my rss feed which is also sitemap? and stop people from hotlinking to my robots.txt?. Thanks
RewriteEngine on This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=351923.0 Hello, I'm learning how to write simple CMS and I'd like it to support page aliases. So that instead of http://www.myweb.com/?id=123 I could use http://www.myweb.com/some-page for example. I don't want to use rewrite rules in .htaccess but I'd like to do it similarly as Drupal. I understood Drupal redirects 404 page not found error to index.php and then somehow handles it. Can you advise how to do it please? Or is there any tutorial or example available? Thank you in advance! Vojta Quesion: Show each movie in the database on its own page, and give the user links in a "page 1, Page 2, Page 3" - type navigation system. Hint: Use LIMIT to control which movie is on which page. I have provided 3 files: 1st: configure DB, 2nd: insert data, 3rd: my code for the question. I would appreciate the help. I am a noob by the way. First set up everything for DB: <?php //connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //create the main database if it doesn't already exist $query = 'CREATE DATABASE IF NOT EXISTS moviesite'; mysql_query($query, $db) or die(mysql_error($db)); //make sure our recently created database is the active one mysql_select_db('moviesite', $db) or die(mysql_error($db)); //create the movie table $query = 'CREATE TABLE movie ( movie_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, movie_name VARCHAR(255) NOT NULL, movie_type TINYINT NOT NULL DEFAULT 0, movie_year SMALLINT UNSIGNED NOT NULL DEFAULT 0, movie_leadactor INTEGER UNSIGNED NOT NULL DEFAULT 0, movie_director INTEGER UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (movie_id), KEY movie_type (movie_type, movie_year) ) ENGINE=MyISAM'; mysql_query($query, $db) or die (mysql_error($db)); //create the movietype table $query = 'CREATE TABLE movietype ( movietype_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, movietype_label VARCHAR(100) NOT NULL, PRIMARY KEY (movietype_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); //create the people table $query = 'CREATE TABLE people ( people_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, people_fullname VARCHAR(255) NOT NULL, people_isactor TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, people_isdirector TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (people_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Movie database successfully created!'; ?> ******************************************************************** *********************************************************************** second file to load info into DB: <?php // connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //make sure you're using the correct database mysql_select_db('moviesite', $db) or die(mysql_error($db)); // insert data into the movie table $query = 'INSERT INTO movie (movie_id, movie_name, movie_type, movie_year, movie_leadactor, movie_director) VALUES (1, "Bruce Almighty", 5, 2003, 1, 2), (2, "Office Space", 5, 1999, 5, 6), (3, "Grand Canyon", 2, 1991, 4, 3)'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the movietype table $query = 'INSERT INTO movietype (movietype_id, movietype_label) VALUES (1,"Sci Fi"), (2, "Drama"), (3, "Adventure"), (4, "War"), (5, "Comedy"), (6, "Horror"), (7, "Action"), (8, "Kids")'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the people table $query = 'INSERT INTO people (people_id, people_fullname, people_isactor, people_isdirector) VALUES (1, "Jim Carrey", 1, 0), (2, "Tom Shadyac", 0, 1), (3, "Lawrence Kasdan", 0, 1), (4, "Kevin Kline", 1, 0), (5, "Ron Livingston", 1, 0), (6, "Mike Judge", 0, 1)'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Data inserted successfully!'; ?> ************************************************************** **************************************************************** MY CODE FOR THE QUESTION: <?php $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); mysql_select_db('moviesite', $db) or die(mysql_error($db)); //get our starting point for the query from the URL if (isset($_GET['offset'])) { $offset = $_GET['offset']; } else { $offset = 0; } //get the movie $query = 'SELECT movie_name, movie_year FROM movie ORDER BY movie_name LIMIT ' . $offset . ' , 1'; $result = mysql_query($query, $db) or die(mysql_error($db)); $row = mysql_fetch_assoc($result); ?> <html> <head> <title><?php echo $row['movie_name']; ?></title> </head> <body> <table border = "1"> <tr> <th>Movie Name</th> <th>Year</th> </tr><tr> <td><?php echo $row['movie_name']; ?></td> <td><?php echo $row['movie_year']; ?></td> </tr> </table> <p> <a href="page.php?offset=0">Page 1</a>, <a href="page.php?offset=1">Page 2</a>, <a href="page.php?offset=2">Page 3</a> </p> </body> </html> This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=328210.0 Some code from my pages ,
Page1 ( Redirecting page )
<html> <title>login_redirect.</title> body> <form name="redirect" action="http://mysite/page2.php" method="post"> <input type="hidden" name="mac" value="$(mac)"> </form> <script language="JavaScript"> <!-- document.redirect.submit(); //--> </script> </body> </html>Page 2 ( select product ) <?php session_start(); ini_set('display_errors',1); error_reporting(E_ALL); include '../lib/config.php'; include '../lib/opendb.php'; // get user mac adres from redirect post page1 $_SESSION['macid'] = $_POST['mac']; // set $macid for other use ( maybe not needed, am learning ) $macid = $_SESSION['macid']; // echo $macid does show mac adress, so variable is not empty here if (!empty($_POST["submit"])) { $product_choice = $_POST['accounttype']; $query= "SELECT AccountIndex, AccountCost, AccountName FROM AccountTypes WHERE AccountIndex='$product_choice'"; $result = mysql_query($query) or die('Query failed. ' . mysql_error()); while($row = mysql_fetch_array($result)) { $_SESSION['AccountIndex'] = $row['AccountIndex']; $_SESSION['AccountCost'] = $row['AccountCost']; $_SESSION['AccountName'] = $row['AccountName']; } header('Location: page3.php'); } // did leave out the other/html/form stuff herePage 3 ( show Session variables ) <?php ini_set('display_errors',1); error_reporting(E_ALL); session_start(); print_r($_SESSION); ?>Now, on page 3 i do see the right session varables, only the "macid" is empty. why ? I have a php page in which javascript called like this <script language="JavaScript" type="text/javascript" src="http://www.test.com/test.php"></script> the output of the page shows a well detail table , but when i use file_get_content method to get that all detail in a varaible its just took above javascript like $a=<script language="JavaScript" type="text/javascript" src="http://www.test.com/test.php"></script> when i right click on page to view source it show just <script language="JavaScript" type="text/javascript" src="http://www.test.com/test.php"></script>. But on actual page there is a html table which detail i have to store in table, Can any one tell me method. Hello. I am attempting to display content from a database to a web page. I have SELECT * etc to do this, plus the menu that should be displayed has links to pages. This would display text to the page depending on the link, for this to work I use the id of the page ($Get['id']). Following advice (not code), I have attempted the following:
<!DOCTYPE html> <html> <?php include 'includes/headsection.php'; ?> <body> <?php // query database if (!empty($_GET['id']) && (intval($_GET['id']) == $_GET['id'])) { $pdo_statement = $conn->prepare("SELECT * FROM pages WHERE id=:id ORDER BY id ASC"); $pdo_statement->execute(['id' => $_GET['id']]); $result = $pdo_statement->fetchAll(); } ?> <!-- topMenu --> <table id="topMenu"> <tr> <td><h1 class="siteName">Site name</h1></td> <td> <?php if(!empty($result)) { foreach($result as $row) { ?> <a href="index.php?id=<?php echo $row['id']; ?>"><?php echo $row['menuheader']; ?></a> <?php } } ?> </td> </tr> </table> This issue is that the top menu (home, etc), does not appear, and there are no errors to suggest what I have done wrong. Any help will be appreciated. I include a picture of what I mean. There should be Home | other | etc...
Currently, in my files, I echo content through either a function called error() or a funtion called info(). Each function has 3 require statements for the header, body and footer files and that is all that is contained in the function. What I want to do is, if error() is called, is kind of leave the script and exit it. Surprisingly I have used exit; at the end of the functions to stop any more of the script being executed. Is this the best way of doing it? Good day everyone! I know this is possible but I do not know how to do it. I have a single page, this page has no dynamic content. I have a set of links. What I need is to have content placed on the page based on the link the user clicks. Example: I have pictures of animals. When the user click a Zebra, the Zebra info is placed on the page. So the page does not change, meaning the content on the page changes but not the page it self. The idea is instead of creating different html pages for each animal profile, the profile is generated to the page from a php include file. Is is this possible? Can anyone, some one please point me to how I can get this going. Thanks everyone! IC What I'm trying to do is get a php file with content to load into my basic page template based on the page id, however it's not loading anything, however there are no errors coming up. I've looked everywhere I could find, and tried everything I could think of. I really could use some help on this. Below is the page template code and the code I'm trying to use to get the content to load up. page_templ.php Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > <link rel="stylesheet" type="text/css" href="templates/content/style.css" > <!--This is the css used for IE because we need to correct some things for it.--> <!--[if IE]> <style type="text/css"> @import 'templates/content/styleIE.css'; </style> <![endif]--> </head> <body> <?php //We need to load our language files with our common text varibles require("content/langeng.php"); ?> <div id="header"> <? //Lets show the header. I use html where I can so smartphones load as little advanced code as possible require_once("header.php"); ?> </div> <div id="menu"> <?//Now our menu. require_once("menu.php"); ?> </div> <div id="mbody"> <?//Now the primary site content. //Load up our postvars.php file require_once("content/postvars.php"); ?> </div> </body> </html> postvars.php Code: [Select] <?php $id = $_POST["id"]; if ( $id == "home" ) { include 'main_c.php'; } elseif ( $id == "guides" ) { include 'guides_c.php'; } elseif ( $id == "trips" ) { include 'trips_c.php'; } ?> Most of the websites I have built have not been large and not dynamic in nature, but I need to make one now with a boatload of content on it. and I’m needing a little resource help where I can research something. I’m sure all developers do this, and I know I need a massive database or 2 and the PHP knowledge I already have, but I’m just looking for a little guidance about how to do this the easiest way. It may actually sound like a stupid question and I might be over-thinking a bit. So… Lets say I have 500 articles that I want to make available to a site visitor and give them the option to choose what they want to look at through nav menus and submenus. I want the same page to display to the user, regardless of what article is chosen. how does PHP play a part in that? Would I be right by saying the following? If the home page had this content on it: This website is a course in PHP coding. <a href="courseTemplate.php" target="_blank">Click here</a> to view course #1. and I wanted all the course content to be displayed through the use of the “courseTemplate.php” file, how simple is that? I would assume that these types of things would be the results and the techniques to accomplish the goal, right? => a resulting URL that looks like this: www.site.com/courseTemplate.php?id=1 => storing all the text of the course material in one single field of a DB record. NOT storing the layout-oriented code (HTML, etc.) and echoing it out with the rest of the text. => making use of the GET() function somehow to pull the course’s text content out of the database. Can someone show me a website that demonstrates this? I don’t think this is very difficult, and I’m sure there are web resources available that show how this is done. I’m almost sure that most news agency websites do this, and I know for a fact that most forum software has this template technique written into it, regardless if SEO is included or not. Sorry for the basic nature of this question. I know some of my previous posts have been such where I’ve asked much more difficult questions than this. I have seen youtube tutorials on issues similar to this, but nothing pulled up by google really shows this in a very simplistic nature. thanks. I'm doing a cURL post to a server and it returns "true No_Error Data was accepted 10356546 3770 false 0 " Form --> Method=Post --> submit.php (this is the page that's doing the cURL post and the server returns data that appears on this page). How do I take this and put it into a string? http://buildmyweb.org/testing/starter/
at the link above, you can see a test-page. the problem im having is that the content in the footer gets cutoff on the right side of the footer when viewed in an ipad. id love to hear it if anyone can figure out why
here is the html:
<!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" /> <meta name="keywords" content = "Under Construction" /> <meta name="description" content="is currently Under Construction." /> <title>Under Construction</title> <link rel="stylesheet" type="text/css" href="bmw_footer_abs.css" /> </head> <body id="page_home"> <div id="wrapper"> <div id="banner"> </div> <!-- close banner --> <div id="main"> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> </div> <!-- close main --> </div> <!-- close wrapper --> <div id="footer"> <div id="footer_content"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> <!-- close footer_content --> </div> <!-- close footer --> </body> </html>and the css: html { position: relative; min-height: 100%; } body { margin: 0 0 100px; /* bottom = footer height */ } #footer { position: absolute; left: 0; bottom: 0; height: 100px; width: 100%; min-width:1000px; background:gray; } #wrapper { position:relative; top:0px; margin:0 auto; width:1000px; text-align:left; background:pink; padding:0px; } /* **************** BANNER *************** */ #banner { float:left; background:green; width:100%; height:10px; } /* **************** MAIN *************** */ #main { float:left; width:100%; background-color:#f0f3f8; } /* **************** FOOTER *************** */ #footer { font-size:85%; line-height:1.3; } #footer_content { width:1000px; margin:0px auto; background:orange; } Hello! I would like to use cURL to login to the website: lockerz.com I have some code, but it doesn't seem to work: <?php // INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'http://lockerz.com/auth/login'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'email-email=EMAIL@hotmail.com&password-password=PASSWPRD'); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL # not to print out the results of its query. # Instead, it will return the results as a string return value # from curl_exec() instead of the usual true/false. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec ($ch); // SET FILE TO DOWNLOAD curl_setopt($ch, CURLOPT_URL, 'http://lockerz.com/auction'); // EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch); // CLOSE CURL curl_close ($ch); echo $content; ?> Thank you very much if you can help! |