Jump to content

Bottyz

Members
  • Posts

    107
  • Joined

  • Last visited

Everything posted by Bottyz

  1. lol. Don't panic. Try changing all ' single quotes in the defines to " double quotes (might cause other issues) or use \ before every ' in your defines text. What this does is basically tells php to not class the ' as the end of the define statement.
  2. whats the page source of the broken page look like? Can you copy and paste here?
  3. usually site maps are stored in the base directory of the website. Well, as per google's preferred requirement... so http://www.website.com/sitemap.xml or Sitemap.xml Not sure if you can do a search for it?
  4. if you get stuck then post some code, and i'll have a look. But if you are calling individual files from your /html/ directory then in the individual files you should be putting your define statements. I'm not sure there would be any other way of doing it, short of having a /defines/ directory too and when you call your individual pages you call the relevant php defines page from the defines directory but i think that'll complicate things.
  5. I think we'd need to see code to know whats wrong.
  6. You should be ok just changing the extension from .html to .php. I cant see there being many issues. As for changing the index.php, just do as per my example. So for each title/meta tag you create a new define statement, making a relevant name for each item... define(TITLE, 'title of page'); define(METATAGDESC, 'meta description'); etc etc... and then at the top of your index.php you call the relevant php file using whatever script you do currently. And as long as it is included before the head section of the index.php page you can use the php echo function to retrieve the define statements. To retrieve the defines just echo their names within the <?php ?> brackets. <title><?php echo TITLE ?></title> If you get stuck then post some code and i'm sure if i dont get time to have a look somebody will. good luck
  7. could you not save them as php files instead of html files? Then include define statements for your meta tags in the included files? such as: include file define (META_TITLE, 'title of page'); then in your index.php have: <title><?php echo META_TITLE; ?></title> As long as you include the file before the the title brackets within the page.
  8. Perfect thanks I knew i was missing a trcik somewhere.
  9. Something like the following should work for you. You may want to tweak it. $check = mysql_query("SELECT email FROM temp_members_db WHERE email = '$email'") $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { header("refresh: 5; signup_ac.php"); die('Sorry, the email <b>'. $email .'</b> is already in use.'); }
  10. Hi all, If a user registers on my registration page with any details that include single (') or double (") quotes, it makes the db sql query error. I thought i'd had this one mastered but obviously not. Is it just a case of adding the addslashes() function somewhere in the script? Can anybody help me position it correctly, or spot where it has gone wrong with my current script? //get data function previous_request_value($str) { if (isset($_REQUEST[$str]) ) return $_REQUEST[$str]; else return ''; } //strip slashes function cndstrips($str) { if (get_magic_quotes_gpc()) return stripslashes($str); else return $str; } //check that the value returned from checkbox is numerical function chkbox_num($num) { if (is_numeric($num)) return $num; else return ''; } //validate user inputs $user_name=cndstrips(trim(previous_request_value('user_name'))); $user_companyname=cndstrips(trim(previous_request_value('user_companyname'))); $user_1stline=cndstrips(trim(previous_request_value('user_1stline'))); $user_address2=cndstrips(trim(previous_request_value('user_address2'))); $user_town=cndstrips(trim(previous_request_value('user_town'))); $user_county=cndstrips(trim(previous_request_value('user_county'))); $user_postcode=cndstrips(trim(previous_request_value('user_postcode'))); $user_country=(trim(previous_request_value('user_country'))); $user_email=cndstrips(trim(previous_request_value('user_email'))); $user_tel=cndstrips(trim(previous_request_value('user_tel'))); All help, as always is much, much appreciated!
  11. Ok then, So using a similar code to the one you supplied above: <?php define('LANG_BASE', '/' . $lang); define('THIS_FILE', 'http://www.website.com/' . basename($_SERVER['PHP_SELF'])); function switchLangHref($lang) { $href = '/' . $lang . '/' . basename($_SERVER['PHP_SELF']); if (!empty($_SERVER['QUERY_STRING'])) { $href .= '?' . $_SERVER['QUERY_STRING']; } return $href; } ?> <div id="language"> Select Language: <a href="<?php echo THIS_FILE; ?>"><img src="images/gb.png" alt="English"></a> <a href="<?php echo switchLangHref('fr'); ?>"><img src="images/fr.png" alt="Fran&#231;ais"></a> <a href="<?php echo switchLangHref('de'); ?>"><img src="images/de.png" alt="Deutsch"></a> <a href="<?php echo switchLangHref('es'); ?>"><img src="images/es.png" alt="Espa&#241;ol"></a> </div> I can keep the english versions of the files such as: http://www.website.com/index.php and then have a directory of duplicated files for the other languages such as: http://www.website.com/fr/index.php. I can't see an easy way of using defines and loading the different languages within a single page as first suggested, that would still be search engine friendly. Additionally, this way i am able to keep my existing english file structure, I don't need to update anything in the search engines and I don't need the 'GET' param as I can link to all the languaged pages from within the languaged pages. It does make more work for me though in keeping everything upto date and editing. Is this right? Or am I still going about it in the worst way possible?
  12. OK, i'm a bit lost now. I can't see how: <a href="<?php echo HREF_BASE; ?>/my_file.php?normal=parameters">...</a> will direct the user to the current page in another language? This language selection is loaded by every page exactly the same so i can't set the constant my_file.php or index.php, etc otherwise it will redirect to just index.php for example. For the user to stay on the current page i'd have to use the basename() along with lang?=en would i not? I'm not sure how this would work :S
  13. Ok a bit closer still Thanks for the suggestion guys. Hows this look? session_start(); // language code $valid_langs = array('en', 'fr'); if (isset($_SESSION['lang']) && in_array($_SESSION['lang'], $valid_langs)) { include('/lang/' . $lang . '/index.php'); } else { $_SESSION['lang'] = 'en'; include('/lang/' . $lang . '/index.php'); } I've switched to session variables so that the current language can be kept... Not sure if there is a better method than that? Now, for the language links, how could i make them so that they point to the page they are currently on but with the correct language directory selected? Could i do the following? <a href="<?php $_SESSION['lang'] = 'fr'; header("Location: basename($_SERVER['PHP_SELF'])"); ?>">French</a> Would that work? I'm not that polished on php code and whats allowed from within hrefs! The above would set the session variable and reload the page, thus loading the alternative language. This would also allow me to keep my urls the same for all the languages... for example, www.website.com/index.php would stay the same for every language but load the english as default.
  14. Right, ok. I think I understand a bit more. So if I were to use the defines file suggestion and the following code: if (isset($lang)) { include('/lang/' . $lang . '/index.php'); } else { // default to english $lang = 'en'; include('/lang/' . $lang . '/index.php'); } at the beginning of every page, along with the language selection links that use the following: index.php?lang=en it should work?
  15. So there could be problems using the suggestion above? SEO is quite important for the site i'm maintaining. So does this mean my original idea would cause the least problems but would be more of a tedious job to maintain? I don't really wanna go down the route of having multiple urls (fr.website.com and so on) for each language. So the question remains... any ideas on making the basename($_SERVER['PHP_SELF']) add the _FR?
  16. Thats a much better idea I agree. Thanks! One question... What would code would I need to put in the language selection link? And would this still work with the search engines? I mean with the text not actually within the page itself? Cheers Guys!!
  17. Hi all, I have been considering different ways of making a language selection script or snippet that would work with my site. And am just a little bit stuck with one part. The scenario: I have a site which uses a global php navigation file, which is included into each page using the 'include()' function. The languages selection div (with flag icons), is stored within this file. For this example, I have the english and french languages to select from.... When a user visits the website the pages are all in english as default. But when they click on the french flag I want the user to then be sent to a duplicated page (same as the current page, wherever they are) with the french text. I plan on duplicating all of the pages i want available in the alternate language and instead of being just index.php or contactus.php I'll rename them with '_fr' such as index_fr.php and contactus_fr.php What i'm stuck with is making the script pick up the current page and then add the _fr part to the middle of the href link. I know you can pick up the current page using: substr(strrchr($_SERVER['PHP_SELF'], "/"), 1); but how to I change it so that it would make this add the _fr? As always, any help would be great!! Cheers all.
  18. Hey all, I prepend and append php files with gzip compression code. Currently i can achieve this with the code below which will prepend/append every php file, however, i want to be able to exclude certain php pages from this. The current code in my .htaccess is this: php_value auto_prepend_file begin_gzip.php php_value auto_append_file end_gzip.php Which obviously compresses all php files. The begin_gzip.php is as follows: <?php ob_start("ob_gzhandler"); ?> and the end_gzip.php is: <?php ob_flush(); ?> The pages i want to exclude contain php download scripts which stop working with the compression enabled. So is there a way to exclude these files by name or am i going to have to add the begin/end code to each individual php page i want to compress? Any help would be much appreciated as i've exhausted google and i'm stuck now.
  19. Hey all, (I'm not 100% sure this is the right place for this request, so sorry if it needs moving). I want to be able to prepend and append php files with gzip compression code. However, the problem i have is that i want to be able to exclude certain php pages from this. The current code in my .htaccess is this: php_value auto_prepend_file begin_gzip.php php_value auto_append_file end_gzip.php Which obviously compresses all php files. The begin_gzip.php is as follows: <?php ob_start("ob_gzhandler"); ?> and the end_gzip.php is: <?php ob_flush(); ?> The pages i want to exclude contain php download scripts which stop working with the compression enabled. So is there a way to exclude these files by name or am i going to have to add the begin/end code to each individual page i want to compress? Cheers!
  20. @jay6390 I agree, your method is much simpler. I may have a look to see if any of my scripts can be sped up the same way! thanks.
  21. I dont have access to be able to turn the output buffering off on the web hosts server. Is there any other way of doing it? Do you think i have a php_flag in a .htaccess which is causing the issue?
  22. why not selected all from db and use a foreach loop to work out the difference between the two values and if they are then output whatever you wanted, whereas if not just go to the next record?
  23. the php info states that this is set to 1.
  24. i'm not 100% sure what you are trying to describe but if it is what i am thinking, i am already checking user permissions without queries by setting session variables when they log in. When the user then accesses product download pages the session variable is checked before they are allowed to see the page. I think the problem lies when i am checking the db to find the file download path and filename. But if i don't query this where would i retrieve the information from if i dont want the user to be able to see it? Thanks for your help so far!
  25. Hi yes, its a script i've written. I need it to only allow logged in users and users with sufficient permissions to access certain files. I don't think this is achieveable without sessions/queries is it?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.