Registration Form No refresh Validation +php No refresh Refresh verification code

Source: Internet
Author: User

NativePhpNo Refresh (verify+Refresh Verification Code)

Overview: This case has not only realized the PHP registration page Verification Code No refresh refresh function

It also realizes the non-refresh validation of the form. The effect is absolutely practical. This example is only a test sample, not database validation.

The source file is divided into 2 parts : code.php and zhuce.php.

Where the code.php file is a captcha file,thezhuce.php file is the registration page.

Gossip less, code presents.

<?Phpsession_start ();    Generate Verification Code Picture Header ("content-type:image/png"); $im = Imagecreate (44,18); Draw a picture of the specified width $back = imagecolorallocate ($im, 245,245,245); Defines the background color Imagefill ($im, 0,0, $back);    Fill the background color into the picture you just drew $vcodes = "";    Srand (Double) microtime () *1000000);     Generate 4 digits for ($i =0; $i <4; $i + +) {$font = Imagecolorallocate ($im, Rand (100,255), Rand (0,100), Rand (100,255));//Generate Random Color    $authnum =rand (1,9);    $vcodes. = $authnum;    Imagestring ($im, 5, $i *10, 1, $authnum, $font);    } $_session[' Vcode ' = $vcodes;    for ($i =0; $i <100; $i + +)//Add interfering pixels {$randcolor = Imagecolorallocate ($im, Rand (0,255), Rand (0,255), Rand (0,255)); Imagesetpixel ($im, Rand ()%70, Rand ()%30, $randcolor);    Image point Function} imagepng ($IM); Imagedestroy ($im);?><imgsrc= "code.php" /><?php echo $_session[' Vcode '];echo "211";?>
<?Phpsession_start (); if (Isset ($_post[' auth ')) {$auth = $_post[' auth '];//$test =$_post[' test '];  $error = "Incorrect verification code"; $true = "OK"; if ($_session["vcode"] = = $auth) {echo $true; Header ("location:");}   else{$tests =$_post[' test ']; echo $error;}}?> <HTML><Head> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /> </Head><title>Login</title><styletype= "Text/css"><!--#textboxs{Height:18px;width:100px;}Table{margin:0 Auto;}img{width:60px;Height:30px;}. Text{font-size:14px;vertical-align:Bottom;Color:#0000FF;}. Style1{font-size:18px;Color:#0000FF;font-family:"The Young Circle";} -</style><Scriptlanguage= "JavaScript">   functionReloadcode () {varVerify=document.getElementById ('Safecode'); Verify.setattribute ('src','code.php?'+math.random ()); //The random number must be added here, or the same address will reload .}  </Script></Head><Body><Tablewidth= "$"><TR><TDAlign= "Center"valign= "Bottom"class= "Style1"bgcolor= "#C7D3F9">Please enter a verification code</TD></TR></Table><formMethod= "POST" ><Tablewidth= "$"Border= "0"bgcolor= "C7d3f9">  <TR>    <TDclass= "text">Verification Code:</TD>    <TDAlign= "Right"valign= "Bottom"><inputtype= "text"name= "Auth"ID= "Textboxs"/></TD>  </TR><TR><TD><imgsrc= "Code.php?act=yes"Align= "Middle"ID= "Safecode"></TD></TR></Table><Tablewidth= "$"><TR><TDAlign= "Right"><inputtype= "button"value= "Verification code not clearly visible"OnClick= "Reloadcode ();"><inputname= "Submit"type= "Submit"value= "Submit"></TD></TR><TR><TD><inputtype= "text"name= "Test"value= "<?php if (Isset ($tests)) {echo $tests;}? > "></TD></TR></Table></form></Body></HTML>

About the interaction before the form submission, here do not do a detailed, interested can add my friend private chat!

Registration Form No refresh Validation +php No refresh Refresh verification code

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: 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.