doudaochu1699 2012-05-12 12:04
浏览 43
已采纳

在PHP中处理基本表单时出错

The problem goes as follows:

File 1 which has the name of: Lesson 17_Forms - Simple Form.php
and File 2 which has the name of: Lesson 17_Forms - Process.php

The contents of file 1 are as follows:

<html>
    <title>Lesson 17_Forms - Simple Form</title>
    <head>
        <center><h1>Lesson 17_Forms - Simple Form</h1></center>
    </head>

    <body>
    <form action= "Lesson 17_Forms - Process.php" method="post">
        Username: <input type="text" name="username" value="" />
        <br />
        Password: <input type="password" name="password" value="" />
        <br />
        <input type="submit" name="submit" value="Submit" />
    </form>
    </body>
</html>

The contents of file 2:

<html>
    <title>Lesson 17_Forms - Process</title>
    <head>
        <center><h1>Lesson 17_Forms - Process</h1></center>
    </head>

    <body>
        <?php
            // Ultra-simple form processing
            // Just retrieve the value and return it to the browser

            $username = $_POST['username'];
            $password = $_POST['password'];

            echo "{$username}: {$password}";
        ?>
    </body>
</html>

Both files are in the same directory, when i am trying to process the form by clicking the submit button, i am receiving the following error:

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404

localhost Sat 12 May 2012 02:40:39 PM EEST Apache/2.2.21 (Unix) DAV/2 mod_ssl/2.2.21 OpenSSL/1.0.0c PHP/5.3.8 mod_apreq2-20090110/2.7.1 mod_perl/2.0.5 Perl/v5.10.1

Any suggestions are greatly appreciated.

  • 写回答

3条回答 默认 最新

  • dosrmo0442 2012-05-12 12:14
    关注

    No spaces are allowed in url -> change the names to simple_form.php and process.php.

    or if you want to keep spaces in name then replace all spaces by '%20' whenever you use it as a url.

    Or the best option is to use urlencode -> it automatically replaces all non-allowed characters by their web acceptable placeholders.

    <form action=<?php echo '"'.urlencode("Lesson 17_Forms - Process.php").'"'; ?> method="post">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 怎么让数码管亮的同时让led执行流水灯代码
  • ¥20 SAP HANA SQL Script 。如何判断字段值包含某个字符串
  • ¥85 cmd批处理参数如果含有双引号,该如何传入?
  • ¥15 fx2n系列plc的自控成型机模拟
  • ¥15 时间序列LSTM模型归回预测代码问题
  • ¥50 使用CUDA如何高效的做并行化处理,是否可以多个分段同时进行匹配计算处理?目前数据传输速度有些慢,如何提高速度,使用gdrcopy是否可行?请给出具体意见。
  • ¥15 基于STM32,电机驱动模块为L298N,四路运放电磁传感器,三轮智能小车电磁组电磁循迹(两个电机,一个万向轮),如何通过环岛的原理及完整代码
  • ¥20 机器学习或深度学习问题?困扰了我一个世纪,晚来天欲雪,能饮一杯无?
  • ¥15 c语言数据结构高铁订票系统
  • ¥15 关于wkernell.PDB加载的问题,如何解决?(语言-c#|开发工具-vscode)