Jump to content

gffg4574fghsDSGDGKJYM

Members
  • Posts

    195
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

gffg4574fghsDSGDGKJYM's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. header("Content-type: application/csv;chartset=utf-8"); chartset ?
  2. There many way just ask google or take a look at this http://www.fpdf.org/
  3. ' is a xml/xhtml entities only, html doesn't have a entities for apos If you are using html you don't need to make a entity of the '/apos isn't needed at all no mater what charset you are using since aposthrophe is in the first 0-127 character(ASCII), if you are using xml you must (i think it's a must for xhtml too but i'm not sure as i don't know every detail of it). If you are using it in a URL you must encode it for both html and xhtml with rawurlencode() http://www.php.net/manual/en/function.rawurlencode.php What IE version are you using ? Did you use html or xhtml ?
  4. There maybe a few WYSIWYG editor that produce valid code, but i doubt. If you really care about validation, writing code by hand is the way to go.
  5. Example of code ? sure...download some frameworks that are made in php and look at the code. If you have hard time understanding MVC i don't think it's a good idea to create another frameworks yourself. The only exception that if you are very, very specific job to do and you aren't able to do it with all actual frameworks (which i very doubt) AND you think there enough people with the same need to create a framework for it instead of a custom software.
  6. 404 mean page not found, htaccess or not. If the htaccess was working on the localhost i assume some file are missing on the server. Did you copy profile.php and bebo-skin.php in the same directory with the htaccess ? did you try to access the page directly or with the htaccess mod_rewrite ?
  7. Model sand for data/database abstraction layer. Simply put you can create a php file mysql_model.php with a list of function that get/set data, all the SQL is handled in the model. Function like get_user_name() or set_user_name(). One day if you want to use Oracle instead of MySQL you only have to rewrite the mysql_model.php and make a oracle_model.php instead. No other change in the others part of the application will change. Only some data handling are autorised in this part like datatype cast or escape string. View is everything the user see and do, the graphical user interface. All the html/css and image. You can easly change it later to use xhtml instead of html or use XML, RSS feed or even a .exe to display the data. It shouldn't containt any actual code else that some foreach to display table (or some similar). You can make the controller save all the data into a array and call the view with it, the view put the data into a html code. Controller is everything else. It receive the data from the view part, process it, save it with the model, retrieve it with model and sent it to view to be displayed. You can make a index.php get the full URL, ask the model for the data you need for that page, process the data as needed and call the view for that page with data. While it can be a good thing to build a MVC yourself to learn from it, it may not be a good idea to use it in a live production system. Many good frameworks exist for that. They have the MVC built-in.
  8. Take the example i gave you and put it in your code. And no regular expression aren't vulnerable to SQL injection so escape your string after you have tested it.
  9. This should work : <?php $email = "tes.t@hotmail.Com"; if (!eregi("^[a-z0-9\-\_\.\%\+]+@[a-z0-9\-\_]+\.[a-z]+$", $email)) { echo "Invalid Email! ".$email; } else { echo "Valid Email! ".$email; } ?> However it won't work for email address using IP address instead of a domain name. It may return some false positive and probably need to be better tested before use.
  10. You can use SHOW COLUMNS FROM `tablename`; OR DESCRIBE `tablename`; To find what the column name are...then use them in INSERT. But why did you need to insert something in a database without knowing first what the column name are ?
  11. You want to force a download ? Use that : <?php $filename = "something.csv"; $csv = "1,2,3,4 2,3,4,5 3,4,5,6"; header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.$filename); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . strlen($csv)); echo $csv; ?>
  12. I think you are looking for $_SERVER['REFERER'] instead of Request URI. But i'm not sure the referer work in a 404 or others error case, and the referer is unreliable because it's provided by the client. You may want to redirect anything that not a file to a php scripts instead to catch up 404. Like that : .htaccess Options +FollowSymLinks <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ log.php?request=$1 [NC,L] </IfModule> log.php <?php /* Tell the page doesn't exist */ header("HTTP/1.0 404 Not Found"); if (isset($_GET['request'])) { /* Save it in database or somewhere */ } ?> <html> .... </html> Or you may search for a software that read apache logs and display you only the 404 request.
  13. PHP have ftp tools you can use to download, resize the thumbnails (gd) and save them local. It always depend on how many images you have but i'm not sure you can do this without being kicked by the timeout or the user will close the window thinking your site doesn't work or the browser may display a timeout even if your script work and you increase the time limit. http://www.php.net/manual/en/book.ftp.php http://www.php.net/manual/en/ref.image.php You can also created a cron job that run each x hours and connect to the ftp, download the file, makes thumbnails and make a 'static' html file. Some sort of a html mirror of a ftp.
  14. Build your php like that php/mysql first then html : <?php require_once('database.php'); ... $error = "User profile not found"; /* if you found a error you can redirect the user because no html have been output yet */ if (isset($error)) { header("HTTP/1.0 404 Not Found"); header('Location: http://www.mysite.com/404.html'); die(); } $is_admin = false; ... /* then display the html if needed */ ?> <html> <body> <?php if (isset($error)) echo '<div class="error">'.$error.'</div>'; ?> ... <?php if ($is_admin) echo "Administration"; ?> </body> </html> Instead of half html, then php/mysql, then the bottom half html: <html> <body> <?php require_once('database.php'); ... /* now if you got a error you are stuck out of options you can't redirect because some data already been send and you can't die() because you will get half a page and no bottom*/ ?> </body> </html> If you want to push this a little bit more you can put your entire website html in a single html/php file like this : display.php <?php if (!$call_from_php) die(); /* prevent call directly from browser*/ ?><html> <head> <title><?php echo $title; ?></title> </head> <body> <?php if ($is_admin) { ?> <h1>Administator Section</h1> <?php } ?> <?php if ($is_user) { ?> <h1>Registered User Section</h1> <?php } ?> <h1>Public section for everyone</h1> </body> </html> and then in your main php file you 'call' the display like that : <?php /* database and stuff */ /* Set value for display depend on what results you have from databse*/ $call_from_php = true; $is_admin = false; $is_user = true; $username = 'joe'; require('display.php'); ?> So you don't have to mix database query, bussiness logic with html tag. If you got a error in html you know where to look all in the same file you don't have to search everywhere. You want to provide alternate content like for mobile phone, great only create a 'display_mobile.php' and call this file instead of 'display.php' when the user has the options 'mobile' in his profile. You don't have to rewrite the whole website, only the view part. It allow flexible error handling and it's easier to maintain. Maybe i put it a bit too far for your need, but you got the idea from separating html and php/mysql.
×
×
  • 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.