代码在localhost上工作正常,但在远程服务器php java脚本上没有

时间:2017-01-06 04:50:59

标签: javascript php

这是我现在注册新用户的代码我已经将我的网站上传到远程服务器并将数据库凭据更改为新的远程服务器连接。更新新注册后无法完成。它显示错误未插入,否则所有其他查询在远程服务器上运行完全正常。

<?php 
include_once '../databaseconnection.php';

$databaseconnection = new Databaseconnection();


$email_address = "";
$mobile_number = "";






$checkpostrequest = ($_SERVER["REQUEST_METHOD"]==="POST");

if($checkpostrequest)

{
    $error = false;

    $erromessage = "";

$errordupchk = false;
$erromessagedup = "";





if(isset($_POST['email_address']))
{
    $emailchk="select id from user where email='".$_POST['email_address']."'";
  $emailchkexe=mysqli_query($databaseconnection->databaselink,$emailchk);

  $emailchk_fromsuperadmintable ="select id from super_admin where admin_email='".$_POST['email_address']."'";
  $emailchk_fromsuperadmintableexe=mysqli_query($databaseconnection->databaselink,$emailchk_fromsuperadmintable);

  if (mysqli_num_rows($emailchkexe)>0  || mysqli_num_rows($emailchk_fromsuperadmintableexe)>0) {

    $erromessagedup.='<li>This email id is already registered with us .</li>';

    $errordupchk=true;
  }
}



if(isset($_POST['mobile_number']))
{
    $mobilechk="select id from user where mobile='".$_POST['mobile_number']."'";
    $mobilechkexe=mysqli_query($databaseconnection->databaselink,$mobilechk);
  if (mysqli_num_rows($mobilechkexe)>0) {

    $erromessagedup.='<li>This mobile number is already registered with us .</li>';

    $errordupchk=true;
  }
}




    if(empty($_POST['email_address']))

            {

                $erromessage .= "<li>Email Address field should not be blank.</li>";

                $error = true;

            }

            if(!empty($_POST['email_address']))
                {
                    if (!filter_var($_POST['email_address'], FILTER_VALIDATE_EMAIL) === true)
                    {

                        $erromessage .= "<li>Please enter proper Email Address.</li>";

                        $error = true;

                    }
                }

    if(empty($_POST['password']))

            {

                $erromessage .= "<li>Password field should not be blank.</li>";

                $error = true;

            }

    if(empty($_POST['con_password']))

            {

                $erromessage .= "<li>Password Confirmation field should not be blank.</li>";

                $error = true;

            }

    if(!empty($_POST['email_address']) && !empty($_POST['confirm_email']))
            {
            if($_POST['password']!=$_POST['con_password'])

                        {

                            $erromessage .= "<li>Password do not be match.</li>";

                            $error = true;

                        }
            }

    if(empty($_POST['mobile_number']))

            {

                $erromessage .= "<li>Mobile number field should not be blank.</li>";

                $error = true;

            }




    if(empty($_POST['check']))

            {

                $erromessage .= "<li>Please tick the check box.</li>";

                $error = true;

            }








if(!$errordupchk)

                {
        if(!$error)

            {

                $email_address = mysqli_real_escape_string($databaseconnection->databaselink,$_POST['email_address']);

                $mobile_number = mysqli_real_escape_string($databaseconnection->databaselink,$_POST['mobile_number']);

                $password = mysqli_real_escape_string($databaseconnection->databaselink,$_POST['password']);

                $mobile_verify   = "NO";



                $insertquery = "INSERT INTO user (email, password, mobile, mobile_verify)
VALUES ('$email_address', '$password', '$mobile_number', '$mobile_verify')";

                $insertqueryexe = mysqli_query($databaseconnection->databaselink,$insertquery);
                if ($insertqueryexe)
                {



                    $ran_var_frm_fir_form=mt_rand(100000,1000000);
                    $_SESSION['otp_first']=$ran_var_frm_fir_form;
                    $mobile_no=$mobile_number;  


                                         /*Send SMS using PHP*/    

                    //Your authentication key
                    $authKey = "110008AaxKKSVs576d5f30";

                    //Multiple mobiles numbers separated by comma
                    $mobileNumber = $mobile_no;

                    //Sender ID,While using route4 sender id should be 6 characters long.
                    $senderId = "grbbiz";

                    //Your message to send, Add URL encoding here.
                    $message = urlencode("Your one time password for www.grabbizz.com is".$_SESSION['otp_first'].".Thank you for registering with us.Please make sure you do not share this password with anyone.");

                    //Define route 
                    $route = "4";
                    //Prepare you post parameters
                    $postData = array(
                        'authkey' => $authKey,
                        'mobiles' => $mobileNumber,
                        'message' => $message,
                        'sender' => $senderId,
                        'route' => $route
                    );

                    //API URL
                    $url="https://control.msg91.com/api/sendhttp.php";

                    // init the resource
                    $ch = curl_init();
                    curl_setopt_array($ch, array(
                        CURLOPT_URL => $url,
                        CURLOPT_RETURNTRANSFER => true,
                        CURLOPT_POST => true,
                        CURLOPT_POSTFIELDS => $postData
                        //,CURLOPT_FOLLOWLOCATION => true
                    ));


                    //Ignore SSL certificate verification
                    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
                    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);


                    //get response
                    $output = curl_exec($ch);

                    //Print error if any
                    if(curl_errno($ch))
                    {
                        echo 'error:' . curl_error($ch);
                    }

                    curl_close($ch);

                    //echo $output;






                    $getid="select id from user where email='".$email_address."'";
                    $getidfetch = mysqli_fetch_object(mysqli_query($databaseconnection->databaselink,$getid));
                    $_SESSION['regid']=$getidfetch->id;
                    $response = array();
                    $response['successvalue'] = true;
                    $response['responsemessage'] = $erromessage;
                    header('Content-type: application/json');
                    echo json_encode($response);

                }
                else
                {
                    $response = array();
                    $response['successvalue'] = false;
                    $response['responsemessage'] = "not inserted";
                    header('Content-type: application/json');
                    echo json_encode($response);
                }

            }

        else

            {



                $response = array();
                $response['successvalue'] = false;
                $response['responsemessage'] = $erromessage;
                header('Content-type: application/json');
                echo json_encode($response);

                //header('location:../index.php');

            }


            }

            else
            {
                $response = array();
                $response['successvalue'] = false;
                $response['loginask'] = true;
                $response['responsemessage'] = $erromessagedup;
                header('Content-type: application/json');
                echo json_encode($response);
            }


}




 ?>

这是java脚本代码

$(document).ready(function(){


$( "input[name='tinsignup']" ).keyup(function(event){
    if(event.keyCode == 13){
        $( "#signbut" ).trigger( "click" );
    }
});
$( "input[name='passsignup']" ).keyup(function(event){
    if(event.keyCode == 13){
        $( "#signbut" ).trigger( "click" );
    }
});




  $(".regbutton").click(function(){
    $("#validationmessages").html('');
    $("#validationmessages").removeAttr("class","alert alert-danger");
    });
    $("#btnsubmit").click(function(){
        //$("#validationmessages").hide();
        //event.preventDefault();
        //$("#validationmessages").attr("class","alert alert-warning");
          $("#validationmessages").html("<img src='img/Preloader_11.gif' alt='loading'/> <b>Please wait...</b>");
          //setTimeout( function(){$('#validationmessages').fadeOut();} , 4000);
          //$("#validationmessages").show();
          var dataStringreg =  $("#indexpageform").serialize();          
       $.ajax({     
         url:"processing/indexformprocessiog.php",
           type:"POST",
           dataType:"json",
           data:dataStringreg,
           cache: false, 
           success: function(response)
       {
       if(response.successvalue)
       {

        $("#validationmessages").attr("class","alert alert-success");
        $("#validationmessages").html("<i class='fa fa-check-circle fa-fw fa-lg'></i><ul>"+response.responsemessage+"</ul>");
        setTimeout( function(){$('#validationmessages').fadeOut();} , 1000);
        window.location='verify.php';

       }
       else
       {
        $("#validationmessages").html('');
        $("#validationmessages").attr("class","alert alert-danger");
        $("#validationmessages").html("<ul>"+response.responsemessage+"</ul>");
        $('#validationmessages').fadeIn();
        if (response.loginask) {
          $("#validationmessages").after('<div class="col-sm-12 alert"><a href="javascript:;" id="loginpop" class="btn btn-primary">login</a></div>');}
          $("#loginpop").click(function(){
            //alert('ok');
            $('#myModal').modal('toggle');
            $('input[name="tinsignup"]')[0].focus();
          });
        }

        //setTimeout( function(){$('#validationmessages').fadeOut();} , 4000);



      }

       }); 
    });
     $("#signbut").click(function(){
       //$("#validationmessignin").hide();
          $("#validationmessignin").html("<img src='img/Preloader_11.gif' alt='loading'/> <b>Please wait...</b>");
          var dataString =  $("#signinform").serialize();
      $.ajax({     
         url:"processing/login_verify.php",
           type:"POST",
           dataType:"json",
           data:dataString,
           cache: false, 
           success: function(response)
       {
       if(response.successvalue)
       {
        //$("#validationmessignin").attr("class","alert alert-success");
        $("#validationmessignin").html("<i class='fa fa-check-circle fa-fw fa-lg'></i>"+response.responsemessage+"");
        $('#validationmessignin').fadeIn();
        setTimeout( function(){$('#validationmessignin').fadeOut();} , 1000);
        setTimeout( function(){window.location='altair/index.php';} , 1000);
       }
       else if (response.successvalueverifyotp) 
       {
        window.location='verify.php';
       }
       else
       {
        $("#validationmessignin").html(response.responsemessage);
        $('#validationmessignin').fadeIn();
        setTimeout( function(){$('#validationmessignin').fadeOut();} , 3000); 
        }

      }

       }); 
    });
     $("#forpassbut").click(function(){
      //$("#validationmessignin").hide();
          $("#validationmessignin").html("<img src='img/Preloader_11.gif' alt='loading'/> <b>Please wait...</b>");
          var dataStringforgot =  $("#signinform").serialize();
      $.ajax({     
         url:"processing/forgot_password.php",
           type:"POST",
           dataType:"json",
           data:dataStringforgot,
           cache: false, 
           success: function(response)
       {
       if(response.successvalue)
       {
        //$("#validationmessignin").attr("class","alert alert-success");
        $("#validationmessignin").html("<i class='fa fa-check-circle fa-fw fa-lg'></i>"+response.responsemessage+"");
        $('#validationmessignin').fadeIn();
        setTimeout( function(){$('#validationmessignin').fadeOut();} , 3000);
        //setTimeout( function(){window.location='index.php';} , 1000);


       }
       else
       {

        //$("#validationmessignin").attr("class","alert alert-danger");
        $("#validationmessignin").html(response.responsemessage);
        $('#validationmessignin').fadeIn();
        setTimeout( function(){$('#validationmessignin').fadeOut();} , 3000);



        }


      }

       }); 
    });      









});

0 个答案:

没有答案