如何像" index.php?type=abc"一样执行 PHP 文件



我创建了索引.php文件,并在abc.php中创建了表单,当我输入像"index.php/type=abc"这样的URL路径时,必须执行表单文件即abc.php文件。

我的索引.php文件是

<?php include_once('header.php')?>
    <div id="content">
        <div class="min-width">
            <ul id="navmenu">
                <li><a href="tel:+254 0725117848" ><div class="button">CALL IPAIDABRIBE </div></a></li>
                <li><a href="new.php" ><div class="button">new</div></a></li>
                <li><a href="what.php" ><div class="button">what new</div></a></li>
                <li><a href="how.php"><div class="button">how</div></a></li>
            </ul>
        </div>
    </div>
    <?php include_once('footer.php')?>

ABC.php代码是

<form action=" "  method="post" id="contact-mail-page">
<div><div class="dealer-page">
       <h2>Interested in becoming a dealer, retailer or a part of our affiliate program for Picture Keeper? Please type in your
 information below and then click submit. You will be contacted within 48 hours.</p><br/>
 </h2>
        </div>
<div class="review">
<div class="form-item" id="edit-name-wrapper">
 <label for="edit-name">Bussiness Name <span class="form-required" title="This field is required.">*</span></label><br />
 <input type="text" maxlength="255" name="name" id="edit-name" size="30" value="" class="form-text required input">
</div>
<div class="form-item" id="edit-name-wrapper">
 <label for="edit-name">Contact Name </label><br />
 <input type="text" maxlength="255" name="cname" id="edit-cname" size="30" value="" class="form-text required input">
</div>
<div class="form-item" id="edit-name-wrapper">
 <label for="edit-add">Address <span class="form-required" title="This field is required.">*</span></label><br />
 <input type="text" maxlength="255" name="add" id="add" size="200" value="" class="form-text required input">
</div>
<div class="form-item" id="edit-name-wrapper">
 <label for="add1">Address1 <span class="form-required" title="This field is required.">*</span></label><br />
 <input type="text" maxlength="255" name="add1" id="add1" size="200" value="" class="form-text required input">
</div><br/>
<input class="dealer-submit" type="submit" value="Submit">
</div></form>

现在,当我键入 url 路径时,例如"index.php?type=abc"。 必须执行此 abc.php 文件。我该怎么做?谁能帮我

你到底想要什么?如果要在 index.php?type=abc Url入时,重定向到所需的页面,请将此代码添加到 index.php 文件上方。

<?php
$SafePages= array("abc", "login", "signin", "logout");
if(isset($_GET['type']))
if (in_array($_GET['type'],$SafePages))
{
header("location:".$_GET['type'].".php");
}
else
{
 header('HTTP/1.0 404 Not Found');
    echo "<h1>404 Not Found</h1>";
    echo "The page that you have requested could not be found.";
    exit();
}

?>

怎么样:

<?php
if ($_REQUEST["type"] = "abc") {
    include ("abc.php");
}
?>

这将放在您的索引.php文件中,就在包含页脚的行上方。

像这样:

<!--HTML HERE-->
<?php
    if (in_array($_GET['type'], array('abc','more','etc'))){
        include ($_GET['type']. ".php");
    }
?>
<!-- MORE HTML HERE-->
<?php
   if (!empty($_GET)
   {
    if ($_GET["type"] = "abc") 
     {
       include ("abc.php");
     }
   }
?>

将此代码包含在索引中.php

最新更新