Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我已经在我的数据库中插入了信息,并且我已经验证了它。但如果我点击插入它是重定向到另一个页面_Php_Javascript_Html_Mysql - Fatal编程技术网

Php 我已经在我的数据库中插入了信息,并且我已经验证了它。但如果我点击插入它是重定向到另一个页面

Php 我已经在我的数据库中插入了信息,并且我已经验证了它。但如果我点击插入它是重定向到另一个页面,php,javascript,html,mysql,Php,Javascript,Html,Mysql,我已经在我的数据库中插入了信息,并且我已经验证了它。但如果我点击插入它是重定向到另一个页面。我想在AJAX概念中完成此操作,请帮助我。提前谢谢 HTML编码 <form id="myform" action="bl/checkout_report.php?action=check_out" method="post" name="myform"> <table width="200" border="0"> &nbsp;&nbsp;&

我已经在我的数据库中插入了信息,并且我已经验证了它。但如果我点击插入它是重定向到另一个页面。我想在AJAX概念中完成此操作,请帮助我。提前谢谢

HTML编码

<form id="myform" action="bl/checkout_report.php?action=check_out" method="post" name="myform">
  <table width="200" border="0">
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <h3><u><b>Shipping Details</b></u></h3>
   <tr>
  <th scope="row"><label>Name*</label></th>
  <td><input id="fname" name="fname" type="text" class="shipping-required"></td>
</tr>
 <tr>
 <th scope="row"><label>Shipping Address*</label>;</th>
 <td><textarea name="address" id="address" class="shipping-required"></textarea></td>
 </tr>
 <tr>
<th scope="row"><label>Nearest Landmark*</label></th>
<td><textarea name="land" id="land" class="shipping-required"></textarea></td>
</tr>
 <tr>
<th scope="row"><label>City*</label></th>
<td><input id="city" name="city" type="text" class="shipping-required"></td>
 </tr>
 <tr>
 <th scope="row"><label>State*</label></th>
  <td><select id="state" name="state"> <option selected="" value="Default" class="shipping- required">(Please select a state)</option>  
 <option>Andhara Pradesh</option>
 <option>Assam</option>
 <option>Bihar</option>
 <option>Delhi</option>
 <option>Gujarat</option>
 <option>Tamil Nadu</option>
  </select></td> 
   </tr>
   <tr>
    <th scope="row"><label>Pin Code*</label></th>
   <td><input id="code" name="code" type="text" class="shipping-required"></td>
  </tr>
  <tr>
  <th scope="row"><label>Mobile Number*</label></th>
  <td><input id="mobile1" name="mobile1" type="text" class="shipping-required"></td>
   </tr>
  <tr>
   <th scope="row"> <label>Mail id</label></th>
   <td><input id="mail1" name="mail1" type="text" class="shipping-required"></td>
  </tr>
  <td><input type="hidden" id="pwd" name="pwd" value="<?php echo "$password"?>"></td> 
 <tr>
 <td><input id="submit" name="submit" type="submit" value=" Continue" onclick="return  formValidate()"></td>
  </tr>
 </table>
 </form>
你试过jquery了吗


如果你不想使用jQuery,那么你应该试试。

你可以使用
jQuery表单插件。
这个插件也可以帮助你上传文件。
所以我认为这对你来说是最好的

这里是这个插件的文档

这里有一些例子

您的函数
formValidate
非常复杂,请尝试用简单的方式为egs编写此函数:

function formValidate()
{ 
    alert("ok");
    var fname = document.myform.fname;
    var address = document.myform.address;
    var land = document.myform.land;
    var city = document.myform.city;
    var state = document.myform.state;
    var code = document.myform.code;
    var mobile1 = document.myform.mobile1;
    var mail1 = document.myform.mail1;
    var status=true; 
    if(!item1(fname)) 
    {  
        status=false;
    }
    if(!idd(address))
    {
        status=false;
    }
    if(!lad(land))
    {
        status=false;   
    }
    if(!place(city))
    {
        status=false;   
    }
    if(!native(state))
    {
        status=false;   
    }
    if(!pin(code))
    {
        status=false;
    }
    if(!number(mobile1))
    {
        status=false;
    }
    if(!id(mail1))
    {                          
        status=false;
    }
    //thinking all functions return true or false
    if(status)  
        document.myform.submit();
    return status;  
} 

您可以编写自己的Ajax脚本XHR Create object,也可以使用现有库(如jQuery)来简化工作


检查stackoverflow中现有的ex:

是的,也许您可以只发布相关代码。没有人会通过250行随机代码来试图破译你想要的。你已经给出了大量的代码,但没有明确你需要的。我认为你在验证检查中的返回出错了..一旦检查了你的代码..为什么是jquery?看起来OP已经用纯JS编写了所有内容。
(function($)
{
    $('#form').submit(function()
    {
        //check for validation..
        return false;
    }); 
});
function formValidate()
{ 
    alert("ok");
    var fname = document.myform.fname;
    var address = document.myform.address;
    var land = document.myform.land;
    var city = document.myform.city;
    var state = document.myform.state;
    var code = document.myform.code;
    var mobile1 = document.myform.mobile1;
    var mail1 = document.myform.mail1;
    var status=true; 
    if(!item1(fname)) 
    {  
        status=false;
    }
    if(!idd(address))
    {
        status=false;
    }
    if(!lad(land))
    {
        status=false;   
    }
    if(!place(city))
    {
        status=false;   
    }
    if(!native(state))
    {
        status=false;   
    }
    if(!pin(code))
    {
        status=false;
    }
    if(!number(mobile1))
    {
        status=false;
    }
    if(!id(mail1))
    {                          
        status=false;
    }
    //thinking all functions return true or false
    if(status)  
        document.myform.submit();
    return status;  
} 
$("#foo").submit(function(event){
  var request = $.ajax({
    url: "/checkout_report.php",
    type: "post",
    data: serializedData
  });
});