duanshan1511 2018-07-08 21:23
浏览 64

PHP表单按钮不提交; 页面仅刷新

This form originally used reCAPTCHA v1 but I have removed the associated code. I am collecting user registration info to post to MySQL database but the submit button only refreshes the page and does not lead further to the message that there is a confirmation email to follow. The files are accessible and functional but the form itself and the submission does not work.

I have tried to include reCAPTCHA v2 as a replacement and did so successfully but the form still does not submit. I have since removed it. Furthermore, I have removed fields to see if the checkbox for Terms and Conditions is the issue because it doesn't throw an error unlike the other fields if unchecked but that also didn't work. I've reviewed prior questions about PHP form submission issues and all I found was that the button type was incorrect as in not submit but it is the correct type. The database is confirmed connected which is the called for 'config.php'

PHP Code of the Form:

$data['PageName']='SIGN UP FOR YOUR FREE ACCOUNT TODAY';
$data['PageFile']='signup';
$data['PageTitle'] = 'Sign Up - GPW'; 

include('../config.php');
require_once('recaptchalib.php');

// Get a key from https://www.google.com/recaptcha/admin/create
$publickey = "6Ld3c-YSAAAAAIIdQocSje_bq1a7Sti3QymRM5hw";
$privatekey = "6Ld3c-YSAAAAAJqrQBNAR_Qb40Mh4BveQ_q8bjv0";

# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;

if($_SESSION['login']){
    header("Location:{$data['Host']}/members/index.php");
    echo('Logged In');
    exit;
}
if($post['action']=='go')optimize('common');
if($post['send']){
    if(!$post['newuser']){
        $data['Error']='Your username can not be empty.';
    }elseif(verify_username($post['newuser'])){
        $data['Error']='For your username you can use only next letters [A..Z, a..z, 0..9].';
    }elseif(!$post['newpass']){
        $data['Error']='Your password can not be empty.';
    }elseif(strlen($post['newpass'])<$data['PassLen']){
        $data['Error']="Your password must be at least {$data['PassLen']} characters long.";
    }elseif($post['newpass']!=$post['cfmpass']){
        $data['Error']='Your password and confirm should be not different.';
    }elseif($post['newuser']==$post['newpass']){
        $data['Error']='Your password can not be same as your username.';
    }elseif(!$post['newques']){
        $data['Error']='Please enter a valid security question.';
    }elseif(!$post['newansw']){
        $data['Error']='Please enter a valid security answer.';
    }elseif(!$post['newmail']||verify_email($post['newmail'])){
        $data['Error']='Please enter your valid e-mail address.';
   }elseif($data['UseExtRegForm']&&!$post['newfname']){
        $data['Error']='Please enter your first name.';
   }elseif($data['UseExtRegForm']&&!$post['newlname']){
        $data['Error']='Please enter your last name.';
   }elseif($data['UseExtRegForm']&&!$post['newaddress']){
        $data['Error']='Please enter your address.';
   }elseif($data['UseExtRegForm']&&!$post['newcity']){
        $data['Error']='Please enter your city.';
   }elseif($data['UseExtRegForm']&&!$post['newcountry']){
        $data['Error']='Please enter your country.';
   }elseif($data['UseExtRegForm']&&!$post['newzip']){
      $data['Error']='Please enter your postal code.';
   }elseif($data['UseExtRegForm']&&!$post['newphone']){
      $data['Error']='Please enter your telephone number.';
    }elseif($post['terms']!='on'){
        $data['Error']='Please read our Terms and Conditions before signup.';
    }elseif(!is_user_available($post['newuser'])){
        $data['Error']='Sorry but this username already taken.';
    }elseif(!is_mail_available($post['newmail'])){
        $data['Error']='Sorry but this e-mail address already taken.';
    }else{
        if (isset($_POST["recaptcha_response_field"])) {
            $resp = recaptcha_check_answer($privatekey,$_SERVER["REMOTE_ADDR"],$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]);
            //print_r($_SERVER["REMOTE_ADDR"]);

                if ($resp->is_valid) { 
                    create_confirmation(
                        $post['newuser'],
                        $post['newpass'],
                        $post['newques'],
                        $post['newansw'],
                        $post['newmail'],
                        $post['newfname'],
                        $post['newlname'],
                        $post['newcompany'],
                        $post['newregnum'],
                        $post['newdrvnum'],
                        $post['newaddress'],
                        $post['newcity'],
                        $post['newcountry'],
                        $post['newstate'],
                        $post['newzip'],
                        $post['newphone'],
                        $post['newfax'],
                        get_member_id($_SESSION['sponsor'])
                    );
                    unset($_SESSION['turing']);
                    $data['PostSent']=true;
                }
        } else {
            $error = $resp->error;
        }
    }
}else{
    if($data['UseTuringNumber'])$_SESSION['turing']=gencode();
}
display('members');
?>
  • 写回答

1条回答 默认 最新

  • duanji9481 2018-07-08 22:18
    关注
    type=submit name=send
    

    Missing quotes

    type="submit" name="send"
    
    评论

报告相同问题?

悬赏问题

  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法