尝试在PHP中使用$\u GET

尝试在PHP中使用$\u GET,php,get,Php,Get,我在下面创建了这个简单的广播组,但在PHP中调用它时遇到了一些困难 <form id="form1" name="form1" method="get" action="pre_process.php"> <p> <input name="q" type="text" size="80"/> </p> <p> <input type="submit" id="search_butto

我在下面创建了这个简单的广播组,但在PHP中调用它时遇到了一些困难

<form id="form1" name="form1" method="get" action="pre_process.php">
    <p>
      <input name="q" type="text" size="80"/>
    </p>
    <p>
      <input type="submit" id="search_button" />
    </p>
    <p>
      <label>
        <input type="radio" name="SearchFormat" value="0" id="SearchFormat_0" />
        Agreggated</label>
      <br />
      <label>
        <input type="radio" name="SearchFormat" value="1" id="SearchFormat_1" />
        Non-Aggregated</label>
谁能告诉我我做错了什么


谢谢

复选框和单选按钮仅在您的$\u GET或$\u POST中可用,前提是它们已被选中 您需要使用类似“isset()”的内容:

要检查该值,请尝试此选项

if(isset($_GET['SearchFormat']) {
    //code......
}

只有选中复选框,复选框才会存在。使用单选按钮执行此操作的最佳方法是在默认情况下至少选中一个单选按钮

<input type="radio" name="SearchFormat" value="0" id="SearchFormat_0" checked="checked"/>


还可以使用isset()函数在php脚本中检查它。

只需在浏览器上查看,可能存在直接从文件夹运行代码的可能性。但是您必须使用localhost地址运行页面。 请看下面的代码。 这是第一个PHP文件:radio.PHP

    <html>
   <body>
   <form action="test1.php" method="get">
  <label>
 <input type="radio" name="SearchFormat" value="0"  />
Agreggated</label>  <br />

 <label>
<input type="radio" name="SearchFormat" value="1"  />
Non-Aggregated</label>
<input type="Submit" name="btn" value="SearchFormat" />

agreegated
非聚合

现在另一个PHP文件是:test1.PHP

 <?php   
 if($_GET['SearchFormat']==0)
   {
   echo "I ma checked";
   }
else  
   {
   echo "I am not checked";
   }
 ?>

必须通过在浏览器中编写localhost/radio.PHP来运行此PHP文件。 第二个php文件会在您单击SearchFormat按钮时自动运行


还有一件事,您必须将所有php页面保存在WAMP/XAMP文件夹中。

尝试使用var_dump($\u GET)来查看使用GET方法提交的所有内容表单标记的外观如何?我感觉你在使用POST方法。在这种情况下,您应该使用$\u POST['SearchFormat']访问该字段。如果您希望在
$\u GET
中找到值,请确保将表单的
方法
属性设置为
GET
谢谢您的帮助,所有人都排序好了!
    <html>
   <body>
   <form action="test1.php" method="get">
  <label>
 <input type="radio" name="SearchFormat" value="0"  />
Agreggated</label>  <br />

 <label>
<input type="radio" name="SearchFormat" value="1"  />
Non-Aggregated</label>
<input type="Submit" name="btn" value="SearchFormat" />
 <?php   
 if($_GET['SearchFormat']==0)
   {
   echo "I ma checked";
   }
else  
   {
   echo "I am not checked";
   }
 ?>