Posts Tagged ‘php’

For those who are interested in running Linux, especially on an older PC, Xubuntu just might fit the bill. Its installation files fit on one disc and include a versatile window manager to boot. However, the basic install isn’t really capable of being a LAMP and FTP-enabled web server. This tutorial explains how to get [...]


If you have a PHP application with a few include files, chances are you don’t want your users to navigate to them, by mistake or otherwise. So here’s a tiny script that checks if a user is looking at the include file by itself and redirects them to the proper place:
if(preg_match(“/includename/”,$_SERVER['PHP_SELF'])){
header(“Location:properlocation.php”);}
You don’t need to put [...]


It’s a bit of a head-scratcher at first, seeing as the jQuery docs mysteriously disavow a postJSON possibility, let alone a function, but it’s definitely doable. So here’s the glorious code:
function postjson(url,data,bS,s,e){
$.ajax({type:”POST”,url:url,data:data,dataType:”json”,
beforeSend:bS,success:s,error:e});}
Use it like so:
postjson(“name.php”,”name=Bob”,
function(){$(“#name”).text(“…”);},
function(json){$(“#name”).text(json.name);},
function(){$(“#name”).text(“Error”);});
If name.php’s output looks like this…
{“name”:”Bob”}
…the above should, upon execution, change the ID “name” to contain the text “Bob.” [...]