Home >Backend Development >PHP Tutorial >PHP reads the phone number from the database and generates a picture_PHP tutorial

PHP reads the phone number from the database and generates a picture_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:50:011007browse

The following is the code:

Copy code The code is as follows:

$id=$_GET[id];
include("admin/config.php");
$sql="select * from user where id=$id";
$data=mysql_fetch_array(mysql_query ($sql));
$p=SBC_DBC($data[Phone],1);
function get_str($str,$strlen=16) {
$str=stripslashes($str);
for($i=0;$i<$strlen;$i++)
if(ord(substr($str,$i,1))>0xa0) $j++;
if($ j%2!=0) $strlen++;
$tmp_str=substr($str,0,$strlen);
return $tmp_str;
}
if($p<>'' ){
//Generate a 5-digit digital image
Header("Content-type:image/png"); //Tell the browser that the following data is an image, rather than displaying it as text

//Define image width and height
$nwidth=120;
$nheight=25;
$im=@imagecreate($nwidth,$nheight) or die("Can't initialize new GD image stream"); ​​//Create image

//Picture color settings
$background_color=imagecolorallocate($im,255,255,255); //Matching color
$text_color=imagecolorallocate($im,23 ,14,91);

//Draw the image border
imagefilledrectangle($im,0,0,$nwidth-1,$nheight-1,$background); //Color the rectangular area
imagerectangle($im,0,0,$nwidth-1,$nheight-1,$background_color); //Draw a rectangle

//srand((double)microtime()*1000000); // Get the millionth of a second value of the current time, using the millionth of a second at the time of execution as the random seed
//$randval=rand();
$randval=$p; //5 digits Number
imagestring($im,8,10,2,$randval,$text_color); //Draw horizontal string


//Add interference factors
//for( $i=0;$i<478;$i++)
//{
//$randcolor=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
//imagesetpixel($im,rand()%100,rand()%30,$randcolor); //Point
//}
//imagestring($im,3,5,5," A Simple Text String",$text_color);
//imageinterlace($im,1);
imagepng($im); //Create a png graphic
imagedestroy($im); //End Graphic

}else{
echo "The merchant did not enter a phone number";
}

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319432.htmlTechArticleThe following is the code: Copy the code The code is as follows: ?php //No blank line in front $id=$_GET[ id]; include("admin/config.php"); $sql="select * from user where id=$id"; $data=mysql_fetch_arra...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn