PHP online generation of QR code (Google API) example

Source: Internet
Author: User
Tags php online

Generate two-dimensional code online via the API generated by Google online.

Code:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Two-dimensional code generation-www.jbxue.com</title>
<script language=javascript>
Function post () {
if (document.getElementById (' content '). value== ') {alert (' contents cannot be empty! '); document.getElementById (' content '). focus (); return false;}
if (Ckregdatapost () ==false) {return false;}
}
</SCRIPT>
<body>
<style>
Body{text-align:center;background: #f5f5f5; Line-height:22px;font-size:14px;color: #888;}
. Newcrop{margin:10;}
. er{width:700px;margin:0px auto;border:1px Solid Gray}
Span{background: #645; color: #fff}
Body form {text-align:center;padding:3px 6px 3px 6px;}
Input.txt{color: #00008B; Background-color: #ADD8E6; border:1px inset #00008B; width:200px;}
input.btn {color: #00008B; Background-color: #ADD8E6; border:1px outset #00008B;p adding:2px 4px 2px 4px;}
Input.smallinput{border:1 solid black; font-size:9pt; Font-style:normal; Font-variant:normal; Font-weight:normal; height:18px; Line-height:normal}
</style>
<body class= "Newcrop" ><div class= "ER" >
<?php
$content =$_get[' content ';
$width =$_get[' width ']?$_get[' width ']:300;
$height =$_get[' height ']?$_get[' height ']:300;
if ($content) {
echo "The text you typed is: <span> $content </span><br/>";
echo "You choose the width is: <span> $width </span><br/>";
echo "The height you choose is: <span> $height </span><br/>";
echo "generated two-dimensional code image is: <br/>";
$wen = UrlEncode (mb_convert_encoding ($content, ' utf-8 ', ' gb2312 ')). "";
echo "<br/>
Image address: <a href= ' https://chart.googleapis.com/chart?cht=qr&chld=h&chs={$width}x{$height}&chl={$wen} ' target= ' _blank ' >https://chart.googleapis.com/chart?cht=qr&chld=h&chs={$width}x{$height}&chl={$ Wen}</a><br/>
Copy to your friend. <a href= ' Javascript:history.go (-1); ' > Back to prev </a> ";
}else{
?> (Script Academy edit finishing Www.jbxue.com)
<form action= "" method= "Get" onsubmit= "return post ();" >
Two-dimensional code generation tool <p>width:<select name= "width" >
<option value= ">100</option>"
<option value= ">200</option>"
<option value= "Selected>300</option>"
<option value= ">400</option>"
<option value= ">500</option>"
</select>
Height: <select name= "Height" >
<option value= ">100</option>"
<option value= ">200</option>"
<option value= "Selected>300</option>"
<option value= ">400</option>"
<option value= ">500</option>"
</select></p>
Enter URL or text: <br/>
<textarea rows= "5" cols= "name=" content id= "content" ></textarea>
<br/><br/>
<input type= "Submit" value= "Generate Picture"/> <input type= "reset" value= "re-fill" >
<br/>
</form><? }?>
<div></body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.