2 months ago
This will get the last entry into a database where COL is equal to something.
SELECT * FROM TABLE WHERE COL=something ORDER BY id DESC LIMIT 0,1
2 months ago
Takes a birth date and will spit out how old that person is.
function getAge($date)
{
{
$age--;
}
return $age;
}
2 months ago
This is just a basic way to query a MySQL database.
$sql = 'SELECT * FROM table';
for ($i=0; $i<$num; $i++)
{
}
2 months ago
Handles response from an ajax request.
function ajaxRequest()
{
var opt = 's=whatever you want to pass';
var page = 'ajax_page.php';
var http = createRequestObject();
http.onreadystatechange = function()
{
if((http.readyState == 4) && (http.status == 200))
{
var text = http.responseText;
}
}
http.open('POST', page, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", opt.length);
http.setRequestHeader("Connection", "close");
http.send(opt);
}
2 months ago
Checks to see if browser is IE based or other.
function createRequestObject(handler)
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
var xmlHttp = new XMLHttpRequest();
xmlHttp.onload=handler;
xmlHttp.onerror=handler;
return xmlHttp;
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
return xmlHttp;
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
return xmlHttp;
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
}
2 months ago
Checks emails format, unlike others it supports have a plus (+) sign in the address.
NOTE: this is easy for the user to by pass, as it is in javascript witch is not server side code.
function emlChk(str) // email format checker/validator.
{
var filter=/^([\w-]+((?:\.|\+)[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if(filter.test(str))
{
return true
} else {
return false
}
}