简体   繁体   中英

Why my Xampp Apache server cant open one PHP script?

I have been writing one HTML page i will let below this, and a PHP script i will post too. But when i use the HTML page to write information and submit it, i get the "The requested URL was not found on this server." message, i have all files into one folder on htdocs named "html", the html page is named "index" and the script is named "test", thank you so much for your time.

[HTML code]

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="/docs/4.0/assets/img/favicons/favicon.ico">

    <title>Signin Template for Bootstrap</title>

    <link rel="canonical" href="https://getbootstrap.com/docs/4.0/examples/sign-in/">

    <!-- Bootstrap core CSS -->
    <link href="../../dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="signin.css" rel="stylesheet">
  </head>

  <body class="text-center">
    <form method="post" action="next.php">
      <img class="mb-4" src="https://getbootstrap.com/docs/4.0/assets/brand/bootstrap-solid.svg" alt="" width="72" height="72">
      <h1 class="h3 mb-3" font-weight="normal"> Please sign in </h1>
      <label for="inputEmail" class="sr-only">Email address</label>
      <input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
      <label for="inputPassword" class="sr-only">Password</label>
      <input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
      <div class="checkbox mb-3">
        <label>
          <input type="checkbox" value="remember-me"> Remember me
        </label>
      </div>
        <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
        <p class="mt-5 mb-3 text-muted">&copy; 2017-2018</p>
    </form>
  </body>
</html>

PHP script

<?php

$handle = fopen("pruebapracticaHE.txt", "a"); 

foreach($_POST as $variable => $value) {

    fwrite($handle, $variable);

    fwrite($handle, "=");

    fwrite($handle, $value);

    fwrite($handle, "\r\n");
}

fwrite($handle, "\r\n");
fclose($handle);

exit
?>

You said that script name is test.php

but what i can see in your HTML code that you set action="next.php" in the form instead of action="test.php" the right code is:

<form method="post" action="test.php">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM