[英]how to pass value to php thorough POST(Can i do this just with html and php)
<div id="navigation">
<ul>
<li><a href="?id=0")><em>Home</em></a></li>
<li><a href="?id=2")><em>Login</em></a></li>
<!-- <form method="POST" onclick="form.submit();"> -->
<select name="state">
<option value="Genre">Genre</option>
<option value="Crime and Drama">Crime and Drama</option>
<option value="Drama and Romance">Drama and Romance</option>
<option value="Sci-Fi">Sci-Fi</option>
<option value="Action">Action</option>
<option value="Adventure">Adventure</option>
<option value="Adventure/Fantasy">Adventure/Fantasy</option>
<option value="Action/Adventure/Fantasy">Action/Adventure/Fantasy</option>
<option value="Action/Sci-fi/Thriller">Action/Sci-fi/Thriller</option>
</select>
<!--<input type="submit" value="Submit" name="listsubmit" id="sub"> -->
<li><a href="?id=3")><input type="submit" value="submit" name="listsubmit"></a></li>
<li><a href="?id=1")><em>Contact us<em></a></li>
What i am trying to do here is take selection from dropdown menu and pass that value through $_POSt to my sql select statement and include that movies.php file in div content. 我在这里想要做的是从下拉菜单中进行选择,并将该值通过$ _POSt传递给我的sql select语句,并将该movie.php文件包含在div内容中。
but unfortunateky i am not finding a way to pass var to php file .doesn't know y my $post is not working .Please guide me how to submit my form what should i menntion in action field since it is my nav.php div navigation. 但是不幸的是我没有找到将var传递给php文件的方法。不知道y $ post无法正常工作。请指导我如何提交表格,因为它是我的nav.php div,因此我应该在操作字段中提及什么导航。 i select one option and pass that to movies.php which takes selected option and include that php in div content based on id value for example: this is my content.php
我选择一个选项,并将其传递给带有所选选项的movies.php,并根据id值将该php包含在div内容中,例如:这是我的content.php
<?php
$id= isset($_GET['id'])? $_GET['id'] :0;
if($id=="1"){
include 'Store.php' ;
}
else if($id=="2"){
include 'Login.php';
}
else if($id=="3"){
include 'movies.php';
}
Please advice! 请指教!
Use jQuery AJAX request. 使用jQuery AJAX请求。 You can pass values return content and show it.
您可以传递值返回内容并显示它。
Modify your select and form like this. 像这样修改您的选择和表单。
<form method="POST" action="?id=3">
<select name="state" onchange="this.form.submit();">
<option value="Genre">Genre</option>
<option value="Crime and Drama">Crime and Drama</option>
<option value="Drama and Romance">Drama and Romance</option>
<option value="Sci-Fi">Sci-Fi</option>
<option value="Action">Action</option>
<option value="Adventure">Adventure</option>
<option value="Adventure/Fantasy">Adventure/Fantasy</option>
<option value="Action/Adventure/Fantasy">Action/Adventure/Fantasy</option>
<option value="Action/Sci-fi/Thriller">Action/Sci-fi/Thriller</option>
</select>
</form>
Form action needs for sending GET variable id. 表单操作需要发送GET变量ID。 Inside movies.php now you can use $_POST['state']
现在在movies.php中,您可以使用$ _POST ['state']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.