我知道有很多人试图回答这个问题,但我不得不问,因为我已经尝试了所有提议的解决方案,但没有一个能为我工作。每当我尝试测试PHP代码时,它都会显示错误'Can not POST /contact.php'。
PredicateLayout ll = (PredicateLayout)view.findViewById(R.id.layout);
Button btn = new Button(getContext());
btn.setText("Button1");
btn.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
Button btn1 = new Button(getContext());
btn1.setText("Button2");
btn1.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
Button btn2 = new Button(getContext());
btn2.setText("Button3");
btn2.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
Button btn3 = new Button(getContext());
btn3.setText("Button4");
btn3.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
Button btn4 = new Button(getContext());
btn4.setText("Button5");
btn4.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
ll.addView(btn);
ll.addView(btn1);
ll.addView(btn2);
ll.addView(btn3);
ll.addView(btn4);
现在是PHP代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="HandheldFriendly" content="true">
</head>
<body>
<form action="contact.php" method="post">
<div class="container-fluid contact-form">
<div class="row centered content">
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 b1">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 b1">
<input class="contact-info name" type="text" placeholder="Name" name="yourname" />
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 b1">
<input class="contact-info email" type="text" placeholder="Email" name="email" />
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 b1">
<input class="contact-info number" type="text" placeholder="Contact number" name="comments" />
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 b1">
<input class="contact-info subject" type="text" placeholder="Subject" name="subject" />
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 b2">
<textarea class="contact-message" name="comments" placeholder="Message" rows="10" cols="40"></textarea>
<p class="how">How did you find out about 9haus?
<select name="how">
<option class="select" value=""> -- Please select -- </option>
<option>Google search</option>
<option>From a friend</option>
<option>Link from a website</option>
<option>9haus Publications</option>
<option>Other</option>
</select>
</p>
</div>
</div>
<div class="container-fluid contact-f">
<div class="row centered">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 b">
<p><input class="send" type="submit" name="submit" value="Send"></p>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</body>
</html>
关于我可能做错什么的任何想法?
答案 0 :(得分:0)
只需检查您的PHP代码&#34; contact.php&#34;文件,似乎你的if / else条件语句会出现语法错误。即
if(isset($_POST['submit'] && $human == '15')
else if(isset($_POST['submit'] && $human != '15')
尝试评论这两个语句,之后您就可以POST到contact.php
文件了。
注意:这里我唯一的目的是帮助您找到根本原因。然后,您需要修复这些条件语句。
希望它有所帮助。