il y a 1 an
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
Copier ceci sur votre site: <script type="text/javascript" src="http://www.posteet.com/embed/1289"></script>
il y a 1 an
Takes a birth date and will spit out how old that person is.
function getAge($date)
{
{
$age--;
}
return $age;
}
Copier ceci sur votre site: <script type="text/javascript" src="http://www.posteet.com/embed/1288"></script>
il y a 1 an
This is just a basic way to query a MySQL database.
$sql = 'SELECT * FROM table';
for ($i=0; $i<$num; $i++)
{
}
Copier ceci sur votre site: <script type="text/javascript" src="http://www.posteet.com/embed/1287"></script>
il y a 1 an
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);
}
Copier ceci sur votre site: <script type="text/javascript" src="http://www.posteet.com/embed/1286"></script>
il y a 1 an
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;
}
}
}
}
Copier ceci sur votre site: <script type="text/javascript" src="http://www.posteet.com/embed/1285"></script>
il y a 1 an
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='^((?:(\\")|\.|\+|\!|\$|&|\*|\-|\=|\^|\`|\||\~|\#|\%|'|\/|\?|\_|\{|\}|\s|\@|\w)*)@(?:[\w-]+\.){1,255}(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|asia|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|travel|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|xn|ye|yt|yu|za|zm|zw)$'
if(filter.test(str))
{
return true
} else {
return false
}
}
Copier ceci sur votre site: <script type="text/javascript" src="http://www.posteet.com/embed/1284"></script>