提交按钮在wordpress页面中不起作用


Submit button not working in wordpress page

我正在尝试创建一个年龄计算器,它在wordpress中不起作用?http://www.naukridigest.com/age-calculator/当按下"提交"时,它会发出错误消息:"找不到您请求的页面。"

<html>
<body>
<div style="padding-left:10px;width:575px; height:350px;background-color:yellow;">
<p>Age Calculator</p>
<form action="" method="post">
<table style="border: 1px solid black;border-collapse: collapse;">
    <tr>
    <td style="border: 1px solid black;">Date of Birth:</td>
    <td style="border: 1px solid black;">  
<?php
	$date = 1;
	echo "Date: ";
	echo '<select name="day">';
  for ($date = 1; $date<=31;$date= $date + 1)
  {
	  echo '<option value="'.$date.'">'.$date.'</option>';
  }
	echo "</select>";
  $month = 1;
  echo "Month: ";
  echo '<select name="month">';
  while ($month<=12)
  {
	  echo '<option value="'.$month.'">'.$month.'</option>';
	  $month = $month + 1;
  }
  echo "</select>";
  $currentyear = date ("Y");
  $i = $currentyear;
  echo "Year: ";
  echo '<select name ="year">';
  for ($i = $currentyear;$i>=1950; $i = $i-1)
  {
	  echo '<option value="'.$i.'">'.$i.'</option>';
  }
  echo '</select>'
  ?>
  <input name="submit" type="submit" value="Submit" />
</td></tr>
  <tr>
    <td style="border: 1px solid black;">Age:</td>
    <td style="border: 1px solid black;"><input style="width: 300px;" name="age" type="text"
	value="	<?php
	  if (isset($_POST['submit'])) {
		$day= $_POST["day"];
		$month= $_POST["month"];
		$year= $_POST["year"];
		//echo $name." your date (dd/mm/yyyy) of birth is "."$day"."/"."$month"."/"."$year"."</br>";
	$dob = $year."-".$month."-".$day;
	$birthdate = strtotime($dob);
	//echo "current time".date('y-m-d')."</br>";
	//echo "The time is " . date("h:i:sa")."</br>";
	$DateOfBirth = strtotime($dob);
	$current_time = time();
	global $age_years;
	$age_years = date('Y',$current_time) - date('Y',$DateOfBirth);
	$age_months = date('m',$current_time) - date('m',$DateOfBirth);
	$age_days = date('d',$current_time) - date('d',$DateOfBirth);
	if ($age_days<0) {
		$days_in_month = date('t',$current_time);
		$age_months--;
		$age_days= $days_in_month+$age_days;
	}
	if ($age_months<0) {
		$age_years--;
		$age_months = 12+$age_months;
	}
	echo $age_years." years, ".$age_months." months, ".$age_days." days";  
	  }
?>"/></td>
  </tr>
  <tr>
    <td style="border: 1px solid black;">Age in Years:</td>
    <td style="border: 1px solid black;"><input style="width: 300px;" name="age" type="text"
	value="	<?php
	  if (isset($_POST['submit'])) {
		$day= $_POST["day"];
		$month= $_POST["month"];
		$year= $_POST["year"];
		//echo $name." your date (dd/mm/yyyy) of birth is "."$day"."/"."$month"."/"."$year"."</br>";
	$dob = $year."-".$month."-".$day;
	$birthdate = strtotime($dob);
	//echo "current time".date('y-m-d')."</br>";
	//echo "The time is " . date("h:i:sa")."</br>";
	$DateOfBirth = strtotime($dob);
	$current_time = time();
	global $age_years;
	$age_years = date('Y',$current_time) - date('Y',$DateOfBirth);
	$age_months = date('m',$current_time) - date('m',$DateOfBirth);
	$age_days = date('d',$current_time) - date('d',$DateOfBirth);
	if ($age_days<0) {
		$days_in_month = date('t',$current_time);
		$age_months--;
		$age_days= $days_in_month+$age_days;
	}
	if ($age_months<0) {
		$age_years--;
		$age_months = 12+$age_months;
	}
	echo $age_years." years";  
	  }
?>"/></td>
  </tr>
  <tr>
    <td style="width:120px; border: 1px solid black;">Age in Months:</td>
    <td style="border: 1px solid black;"><input style="width: 300px;" name="age" type="text"
	value="	<?php
	  if (isset($_POST['submit'])) {
		$day= $_POST["day"];
		$month= $_POST["month"];
		$year= $_POST["year"];
		//echo $name." your date (dd/mm/yyyy) of birth is "."$day"."/"."$month"."/"."$year"."</br>";
	$dob = $year."-".$month."-".$day;
	$birthdate = strtotime($dob);
	//echo "current time".date('y-m-d')."</br>";
	//echo "The time is " . date("h:i:sa")."</br>";
	$DateOfBirth = strtotime($dob);
	$current_time = time();
	global $age_years;
	$age_years = date('Y',$current_time) - date('Y',$DateOfBirth);
	$age_months = date('m',$current_time) - date('m',$DateOfBirth);
	$age_days = date('d',$current_time) - date('d',$DateOfBirth);
	if ($age_days<0) {
		$days_in_month = date('t',$current_time);
		$age_months--;
		$age_days= $days_in_month+$age_days;
	}
	if ($age_months<0) {
		$age_years--;
		$age_months = 12+$age_months;
	}
	echo $age_months." months";  
	  }
?>"/></td>
  </tr>
  <tr>
    <td style="border: 1px solid black;">Age in Days:</td>
    <td style="border: 1px solid black;"><input style="width: 300px;" name="age" type="text"
	value="	<?php
	  if (isset($_POST['submit'])) {
		$day= $_POST["day"];
		$month= $_POST["month"];
		$year= $_POST["year"];
		//echo $name." your date (dd/mm/yyyy) of birth is "."$day"."/"."$month"."/"."$year"."</br>";
	$dob = $year."-".$month."-".$day;
	$birthdate = strtotime($dob);
	//echo "current time".date('y-m-d')."</br>";
	//echo "The time is " . date("h:i:sa")."</br>";
	$DateOfBirth = strtotime($dob);
	$current_time = time();
	global $age_years;
	$age_years = date('Y',$current_time) - date('Y',$DateOfBirth);
	$age_months = date('m',$current_time) - date('m',$DateOfBirth);
	$age_days = date('d',$current_time) - date('d',$DateOfBirth);
	if ($age_days<0) {
		$days_in_month = date('t',$current_time);
		$age_months--;
		$age_days= $days_in_month+$age_days;
	}
	if ($age_months<0) {
		$age_years--;
		$age_months = 12+$age_months;
	}
	echo $age_days." days";  
	  }
?>"/></td>
  </tr>
</table>
</form>
</div>
</body>
</html>

您正在php中创建此页面,因此不需要在表单中定义您的动作属性,因此您可以从form标记中删除action属性。但您需要处理所有选定的下拉答案,因此您可以使用$_POST来获取所有选定的值。

<form action="" method="post" action="http://www.naukridigest.com/age-calculator/">

我在那个form中看到两个action。删除第一个,这样就剩下:<form method="post" action="http://www.naukridigest.com/age-calculator/">

但是,如果没有提供任何进一步的代码(或者为此提供了任何代码;我不得不自己去追踪它),我真的无法帮助解决可能出现的任何其他问题。