{"id":752,"date":"2014-05-19T06:22:09","date_gmt":"2014-05-19T10:22:09","guid":{"rendered":"http:\/\/www.searchenginegenie.com\/programming-blog\/?p=752"},"modified":"2015-07-27T08:35:30","modified_gmt":"2015-07-27T12:35:30","slug":"simple-capcha-using-php","status":"publish","type":"post","link":"https:\/\/www.searchenginegenie.com\/programming-blog\/simple-capcha-using-php\/","title":{"rendered":"Simple Capcha using php"},"content":{"rendered":"<p><strong>Capcha Code:<\/strong><\/p>\n<p>Save this code as &#8220;capcha.php&#8221;<\/p>\n<p>[php]<\/p>\n<p>&lt;?php<br \/>\nsession_start();<br \/>\n$text = rand(10000,99999);<br \/>\n$_SESSION[&#8220;vercode&#8221;] = $text;<br \/>\n$height = 25;<br \/>\n$width = 65;<\/p>\n<p>$image_p = imagecreate($width, $height);<br \/>\n$black = imagecolorallocate($image_p, 0, 0, 0);<br \/>\n$white = imagecolorallocate($image_p, 255, 255, 255);<br \/>\n$font_size = 14;<\/p>\n<p>imagestring($image_p, $font_size, 5, 5, $text, $white);<br \/>\nimagejpeg($image_p, null, 80);<br \/>\n?&gt;<br \/>\n[\/php]<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n<strong>HTML:<\/strong><\/p>\n<p>&lt;img src=&#8221;capcha.php&#8221; alt=&#8221;&#8221; align=&#8221;top&#8221; \/&gt;\u00a0&lt;input id=&#8221;vercode&#8221; class=&#8221;cap&#8221; name=&#8221;vercode&#8221; type=&#8221;text&#8221; align=&#8221;texttop&#8221; \/&gt;<br \/>\n&lt;div&gt;<\/p>\n<p>&lt;input class=&#8221;sub&#8221; name=&#8221;subi&#8221; type=&#8221;submit&#8221; value=&#8221;Register&#8221; \/&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.searchenginegenie.com\/captcha_image1.php\" alt=\"\" align=\"top\" \/>\u00a0<input id=\"vercode\" class=\"cap\" name=\"vercode\" type=\"text\" align=\"texttop\" \/><\/p>\n<div>\n<p><input class=\"sub\" name=\"subi\" type=\"submit\" value=\"Register\" \/><\/p>\n<\/div>\n<p>Must set session to use the capcha<\/p>\n<p><strong>PHP Code for the html page:<\/strong><\/p>\n<p>[php]<br \/>\n&lt;?php if ($_POST[&#8220;vercode&#8221;] != $_SESSION[&#8220;vercode&#8221;])<br \/>\n{<br \/>\nheader(&#8220;location:contact.php?ver&#8221;); \/\/incorrect verification code }<br \/>\n?&gt;<br \/>\n[\/php]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Capcha Code: Save this code as &#8220;capcha.php&#8221; [php] &lt;?php session_start(); $text = rand(10000,99999); $_SESSION[&#8220;vercode&#8221;] = $text; $height = 25; $width = 65; $image_p = imagecreate($width, $height); $black = imagecolorallocate($image_p, 0, 0, 0); $white = imagecolorallocate($image_p, 255, 255, 255); $font_size = 14; imagestring($image_p, $font_size, 5, 5, $text, $white); imagejpeg($image_p, null, 80); ?&gt; [\/php] &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; HTML: &lt;img [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,43,1],"tags":[],"class_list":["post-752","post","type-post","status-publish","format-standard","hentry","category-php","category-programmer","category-programming"],"_links":{"self":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts\/752","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/comments?post=752"}],"version-history":[{"count":6,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts\/752\/revisions"}],"predecessor-version":[{"id":788,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts\/752\/revisions\/788"}],"wp:attachment":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/media?parent=752"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/categories?post=752"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/tags?post=752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}