表单未经php验证就提交到另一个页面

表单未经php验证就提交到另一个页面,php,html,Php,Html,这是我用于在线注册的代码 当我提交另一个页面时,验证不起作用,表单在未经任何验证的情况下提交到另一个页面。我只是需要知道如何提交验证,有人能帮忙吗 IP产品介绍和VoIP PBX 多伦多电器培训日 事件信息 请到多伦多机场费尔菲尔德套房酒店(Fairfield Inn&Suites Toronto Airport)加入我们,Grandstream将在白天提供四次不同的会议 Grandstream IP产品介绍 上午8:45-10:15 Grandstream简介,以及Grandstream产

这是我用于在线注册的代码
当我提交另一个页面时,验证不起作用,表单在未经任何验证的情况下提交到另一个页面。我只是需要知道如何提交验证,有人能帮忙吗


IP产品介绍和VoIP PBX
多伦多电器培训日
事件信息
请到多伦多机场费尔菲尔德套房酒店(Fairfield Inn&Suites Toronto Airport)加入我们,Grandstream将在白天提供四次不同的会议

Grandstream IP产品介绍 上午8:45-10:15
Grandstream简介,以及Grandstream产品的基本信息,包括ATA、网关、路由器和电话

IP摄像机和IP监控产品介绍 下午12:45-2:15
IP摄像机和监控产品的基本信息,以及全新GVR3550网络录像机的介绍

UCM VoIP PBX的高级技术培训 下午2:30-4:30
本课程将重点介绍UCM系列的高级功能,包括即将推出的软件的新功能和用于T1网络的全新UCM6510 VoIP PBX

现在注册 姓名*:
验证必须在请求到达服务器时进行。您的流程如下所示:

在浏览器->用户单击提交->数据提交到Submission.php->验证中显示的表单应在此处进行


将验证代码放在Submission.php中。

仔细检查表单属性中的操作。如果您在表单属性中提到页面名称,那么它将提交另一个页面而不进行验证。若要在同一页面中进行验证,请从“表单中的操作”属性中删除页面名称。Other wise将验证检查放在另一个页面中,在表单属性中的操作中提到了这一点。

对我来说,您似乎是PHP表单处理的新手。对于初学者来说,重新发明轮子是危险的,因为很容易在脚本中打开安全漏洞。使用一个可以为您处理表单的框架或CMS(例如,and或只是使用简单的as或完整的东西,如,或)


除非你真的知道自己在做什么,否则不要自己做任何事情。开始可能需要一些时间,但从长远来看肯定会有回报。

检查表单属性中的
操作
,看看这是否是目标文件。你必须在Submission.php中进行验证,也可以选择通过表单pageA中的javascript进行验证将上述验证内容添加到Submission.php中page@PacketTracer任何可以在表单页面中验证并提交到不同页面的方法Hi sandeep您应该使用javascript或jquery alsoValidate ur数据的客户端验证,然后重定向到Submission或使用相同的脚本!首先测试是否是POST请求,如果是,则验证并保存数据(如果正确),如果不正确,则显示表单和错误消息(如果有)。$\u服务器['REQUEST\u METHOD']告诉您该方法是GET还是POST。
<?php
// define variables and set to empty values
$nameErr = $cnameErr = $mobilenoErr = $emailErr = $cityErr= $postalcodeErr = $addressErr = "";

$name = $cname = $mobileno = $email = $city= $postalcode = $address = "";


if ($_SERVER["REQUEST_METHOD"] == "POST") {
   if (empty($_POST["name"])) { 
     $nameErr = "Name is required";
   } else {
     $name = test_input($_POST["name"]);
     // check if name only contains letters and whitespace
     if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
       $nameErr = "Only letters and white space allowed"; 
     }
   }

   if (empty($_POST["cname"])) {
     $cnameErr = "Company Name is required";
   } else {
     $cname = test_input($_POST["cname"]);
   }

   if (empty($_POST["mobileno"])) {
     $mobilenoErr = "Mobile Number is required";
   }else {
     $mobileno = test_input($_POST["mobileno"]);
     // check if name only contains letters and whitespace
     if (!preg_match("/^[789][0-9]{9}$/",$mobileno)) {
       $mobilenoErr = "Not A Valid Number"; 
     }
   }

   if (empty($_POST["email"])) {
     $emailErr = "Email is required";
   } else {
     $email = test_input($_POST["email"]);
     // check if e-mail address is well-formed
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
       $emailErr = "Invalid email format"; 
     }
   }
   if (empty($_POST["city"])) {
     $cityErr = "City is required";
   }  else {
     $city = test_input($_POST["city"]);
     // check if name only contains letters and whitespace
     if (!preg_match("/^[a-zA-Z ]*$/",$city)) {
       $cityErr = "Only letters and white space allowed"; 
     }
   }
   if (empty($_POST["postalcode"])) {
     $postalcodeErr = "Postal Code is required";
   } else {
     $postalcode = test_input($_POST["city"]);
   }

   if (empty($_POST["address"])) {
     $addressErr = "Address is required";
   } else {
     $address = test_input($_POST["address"]);
   }
}


function test_input($data) {
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   return $data;
}
?>
<div class="gridContainer clearfix">
  <div id="div1" class="fluid"><!-- header ends here-->
    <div id="header" class="fluid">
      <div class="fluid logo_container zeroMargin_tablet">
      <div class="fluid logo_mvc"></div>
      <!-- logo_mvc ends here-->
      <div class="fluid logo_gsm"></div>
      <!-- logo_gsm ends here-->
    </div>
    <!-- logo_container ends here-->
</div>
    <div class="fluid imageslide zeroMargin_desktop">
      <div class="fluid imageslide_gs zeroMargin_desktop"></div>
      <!-- imageslide_gs ends here-->
      <div class="fluid imageslide_content">
      <h1>IP Product Introduction and VoIP PBX
Appliance Training Day @ Toronto</h1>
      </div><!-- imageslide_content ends here-->
      <div class="fluid imageslide_product"></div>
      <!-- imageslide_product ends here-->
    </div><!-- imageslide ends here-->
    <div class="fluid content">
    <div class="fluid content_det">
    <h3>Event information</h3>
    <p>Please join us at the Fairfield Inn & Suites Toronto Airport where Grandstream will offer four different sessions during the day. </p>
    <h3>Introduction to Grandstream IP products</h3>
    <p><b>8:45am - 10:15am</b><br/>
Introduction to Grandstream, and basic information on Grandstream products including ATAs, gateways, routers and telephones. </p>
<h3>Introduction to IP cameras IP and Surveillance products</h3>
    <p><b>12:45pm - 2:15pm</b><br/>
Basic information on IP cameras and surveillance products, and the introduction of the brand new GVR3550 Network Video Recorder. </p>
<h3>Advanced Technical Training for UCM VoIP PBX's</h3>
    <p><b>2:30pm - 4:30pm</b><br/>
This session will focus on the advanced features of the UCM series, including the new features of the upcoming software and the brand new UCM6510 VoIP PBX for T1 networks. </p>
    </div><!-- content_det ends here--><div class="fluid contet_form">
    <h2>Register Now</h2>
    <form method="post" action="Submission.php">
    <div class="fluid div_form"><label><b>First name *:</b></label>
    <input type="text" size="20px" name="name" placeholder="Enter Your Name Here" value="<?php echo $name; ?>"/><span class="error"><?php echo $nameErr;?></span>

    </div>


    <div class="fluid div_form"><label><b>Company Name *:</b></label>
    <input type="text" size="20px" name="cname" placeholder="Enter Your Company Name Here" value="<?php echo $cname; ?>"/><span class="error"><?php echo $cnameErr;?></span></div>

    <div class="fluid div_form"><label><b>Mobile Number *:</b></label>
    <input type="text" size="20px" name="mobileno" placeholder="Enter Your Mobile Number Here" value="<?php echo $mobileno; ?>"/><span class="error"><?php echo $mobilenoErr?></span>
     </div>

    <div class="fluid div_form"><label><b>Email Id *:</b></label>
    <input type="email" size="20px" name="email" placeholder="Enter Your Email Id Here" value="<?php echo $email; ?>"/><span class="error"><?php echo $emailErr?></span></div>


    <div class="fluid div_form"><label><b>City *:</b></label>
    <input type="text" size="20px" name="city" placeholder="Enter Your City Name Here" value="<?php echo $city;?>"/><span class="error"><?php echo $cityErr?></span></div>

    <div class="fluid div_form"><label><b>Postal Code *:</b></label>
    <input type="text" size="20px" name="postalcode" placeholder="Enter Postal Code Here" value="<?php echo $postalcode; ?>"/><span class="error"><?php echo $postalcodeErr?></span>
     </div>

    <div class="fluid div_form"><label><b>Address *:</b></label>
    <input type="text" size="20px" name="address" placeholder="Enter Address Here" value="<?php echo $address; ?>"/><span class="error"><?php echo $addressErr?></span></div>


<button name="submit">Submit</button>
    </form>
    </div><!-- contet_form ends here-->
    </div><!-- content ends here-->
  </div><!-- div1 ends here-->
</div>
</body>