After the verification code is generated through the ajax submission request, continue to use an ajax submission event, and compare the verification code entered by the user with the one received in the text message. If the verification code is correct, the registration is successful, and if it is incorrect, an error message will be returned
<?php //点击发送短信验证码 $.ajax({ async : false, type: "get", url: "code.php", // data: {}, success: function (data) { //发送短信验证码 $.ajax({ async : false, type: "post", url: "smsyzm.php", // data: {"yzm": data, 'yzmtel': $('#phone').val()}, dataType: "json", success: function (data) { } }); } });
It should be noted here that continuous ajax requests need to be submitted asynchronously, otherwise the data may not be received (async: false)
Modify the smsyzm.php code to decrypt the code sent to the mobile phone
<?php $param = base64_decode($_POST['yzm']);
The display results are as follows: