Php 在a<;中的任意位置单击时页面重定向;部门>;

Php 在a<;中的任意位置单击时页面重定向;部门>;,php,html,Php,Html,我正在设计一个网站,我遇到了一个问题。 在下面的页面“samgatha.org/register.php”中,无论我在表单框中单击什么,它都会重定向到“samgatha.org/register.php”。我找不到问题所在。 下面我发布了注册表单的主代码,我没有包括模板代码 <div id="register-box"> <?php require 'connection.php'; if($_SERVER['REQUEST_METHOD']=='POST') {

我正在设计一个网站,我遇到了一个问题。 在下面的页面“samgatha.org/register.php”中,无论我在表单框中单击什么,它都会重定向到“samgatha.org/register.php”。我找不到问题所在。 下面我发布了注册表单的主代码,我没有包括模板代码

<div id="register-box">
<?php
  require 'connection.php';
  if($_SERVER['REQUEST_METHOD']=='POST') {
    if((isset($_POST['enthu_name']))&&(isset($_POST['enthu_email']))&&(isset($_POST['enthu_contact']))&&(isset($_POST['college_name']))&&(isset($_POST['branch']))&&(isset($_POST['pass']))) {

        $var_name = mysql_real_escape_string($_POST['enthu_name']);
        if(!preg_match("/^[a-zA-Z ]*$/",$var_name)) {
            die('Only letters and white spaces allowed in Name<br>');
        }
        $var_email = mysql_real_escape_string($_POST['enthu_email']);
        if(!filter_var($var_email, FILTER_VALIDATE_EMAIL)) {
            die("Invalid email format<br>");
        }
        $var_contact = mysql_real_escape_string($_POST['enthu_contact']);
        $var_college = mysql_real_escape_string($_POST['college_name']);
        $var_branch = mysql_real_escape_string($_POST['branch']);

        $passwd = mysql_real_escape_string(md5($_POST['pass']));

        $v1 = rand(0,getrandmax());
        $v2 = rand(0,getrandmax());
        $ac_conf = $v1.$v2;
        $ac_conf_hash = md5($v1.$v2);
        $v1 = rand(0,getrandmax());
        $v2 = rand(0,getrandmax());
        $fo_pass = $v1.$v2;

        $query = "insert into student_detail (name,email,phno,college,branch,password,acc_confirm_code,forgot_pass_code)".
                "values".
                "('$var_name','$var_email','$var_contact','$var_college','$var_branch','$passwd','$ac_conf','$fo_pass')";

        $retval = mysql_query($query);
        if(!$retval) {
          die('Could not register'.mysql_error());
        }
        $reg_conf_code = "http://samgatha.org/reg_conf.php?acconf=".$ac_conf_hash."&suse=".$var_email;
        $reg_conf = "Please click on the link to activate<br>".$reg_conf_code;

        mail($_POST['enthu_email'],"Samgatha Account Confirmation (no reply) link",$reg_conf);

        header('Location: http://samgatha.org/login.php');
      }
      else {
      echo "Please enter details to continue <br>";
    }
  }
 ?>

Welcome to samgatha registrations. <br>
Please fill out the following form to participate in samgatha.
<form id="sam_register" action="register.php" method="post">

  <div class="reg-box-in">
  <label class="i2" id="ii1" for="enthu_name">Name : </label>
  <input class="i1" type="text" name="enthu_name" id="enthu_name"> <br>
  </div>

  <div class="reg-box-in">
  <label class="i2" id="ii2" for="enthu_email">E-mail Address : </label>
  <input class="i1" type="text" name="enthu_email" id="enthu_email"> <br>
  </div>

  <div class="reg-box-in">
  <label class="i2" id="ii3" for="enthu_contact">Phone No : +91</label>
  <input class="i1" type="text" name="enthu_contact" id="enthu_contact"> <br>
  </div>

  <div class="reg-box-in">
  <label class="i2" id="ii4" for="college_name">Institute : </label>
  <input class="i1" type="text" name="college_name" id="college_name"> <br>
  </div>

  <div class="reg-box-in">
  <label class="i2" id="ii5" for="branch">Discipline : </label>
  <input class="i1" type="text" name="branch" id="branch"> <br>
  </div>

  <div class="reg-box-in">
  <label class="i2" id="ii6" for="password">Password : </label>
  <input class="i1" type="text" name="pass" id="pass" maxlength="30"> <br>
  </div>

  <div class="reg-box-in">
  <button type="submit" name="register">Register</button> <br>
  </div>
</form>     


</div>

注册框上有
标记,它重定向到
login.php
。请检查您的代码,它放置了
标签。

各种html问题

未闭合链路

<a href="login.php"><div id="register" class="lay2"><div id="registert">Sign In/Up</div></div>
登录/注册

欢迎来到samgatha注册
请填写以下表格参加samgatha。
页面中是否有用于表单验证或其他可能导致表单验证的javascript?不,我没有任何javascript。嘿,您有两个关闭的
div
。这可能会导致无效的HTML。第一次关闭是提交按钮,我修复了它。。但问题仍然没有解决。解决了它。仍然存在问题(感谢指出)@klbm9999在我重新加载页面时仍然没有修复,我只是放置了标签。这个问题并不是由政府来解决的that@klbm9999我仍然没有看到结束标记,这是你的problem@klbm9999我会尝试发送你的页面,因为它可以帮助解决html格式问题。我不明白你做了什么,你能告诉我吗?
    <div id="register-box">
<?php
  require 'connection.php';
  if (!empty($_POST)) {

        $var_name = mysql_real_escape_string(<?php echo htmlspecialchars($_POST["name"]); ?>);
        //-- same used for post ------------
        header('Location: http://samgatha.org/login.php');
      }
      else {
      echo "Please enter details to continue <br>";
    }
  }
 ?>

Welcome to samgatha registrations. <br>
Please fill out the following form to participate in samgatha.
 <form action=<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?> method="post">

  <div class="reg-box-in">
  <label class="i2" id="ii1" for="enthu_name">Name : </label>
  <input class="i1" type="text" name="enthu_name" id="enthu_name"> <br>
  </div>

  <div class="reg-box-in">
  <label class="i2" id="ii2" for="enthu_email">E-mail Address : </label>
  <input class="i1" type="text" name="enthu_email" id="enthu_email"> <br>
  </div>

  <div class="reg-box-in">
  <label class="i2" id="ii3" for="enthu_contact">Phone No : +91</label>
  <input class="i1" type="text" name="enthu_contact" id="enthu_contact"> <br>
  </div>

  <div class="reg-box-in">
  <label class="i2" id="ii4" for="college_name">Institute : </label>
  <input class="i1" type="text" name="college_name" id="college_name"> <br>
  </div>

  <div class="reg-box-in">
  <label class="i2" id="ii5" for="branch">Discipline : </label>
  <input class="i1" type="text" name="branch" id="branch"> <br>
  </div>

  <div class="reg-box-in">
  <label class="i2" id="ii6" for="password">Password : </label>
  <input class="i1" type="text" name="pass" id="pass" maxlength="30"> <br>
  </div>

  <div class="reg-box-in">
  <button type="submit" name="register">Register</button> <br>

</form>     
</div>

</div>