Kevin Pirnie' Articles

Here is a little snippet for anyone who needs it. What it does?   Generates a random character string, stores it to a session variable (for verification), then renders a png image with a white background and random colors of the random characters. Change any variables you need.  And call is using a simple <img> tag. Here's the code: <? $string = ''; // String of characters to randomly render $chars = 'a,b,c,d,e,f,g,h,j,k,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,G,J,K,L,M,N,P,Q,R,S,T,U,V,W,X,Y,Z,1,2,3,4,5,6,7,8,9,$,%,&,*,@,#,~'; $ca = explode(',', $chars); // Shuffle up the array shuffle($ca); // Now make it a complete string, but only allow 8 characters foreach (array_slice($ca, 0, 8) as $ltr) { $string .= $ltr; } //Store the string in the session $_SESSION['SecImg'] = $string; //Set the browser header to render this as an image… Read More