-4

PHPの勉強を始めました。物事をセットアップすることができました。

私はphpバージョン5.3.13を使用しています。

いくつかの情報を html フォームに投稿し、それを php ファイルで受信しようとしています。

目的のために、私は $_Post 変数を使用しており、php ファイルでの出力は空白です。

以下はhtmlコードです。

<body>
        <form action="report.php" method="POST" >    
            <label for="firstname">First name:</label>
            <input type="text" id="firstname" name="firstname" /><br />
            <input type="submit" value="Report Abduction" name="submit" />
        </form>
</body>

そして以下はreport.phpコードです

<html>
<head>
<title></title>
</head>
<body>

<?php
     $name = $_POST['firstname'] ; 
         print($name);
?>
</body>
</html>

誰が私が欠けているものをアドバイスできますか?

ありがとう

4

1 に答える 1

2

これは非常に単純な例です。お気に入りの検索エンジンでチュートリアルの例を探すか、本を購入することをお勧めします。

編集:PHPもインストールされていますか?inetpubあなたはIISパスであると述べています。

<?php 
error_reporting(E_ALL);

if($_SERVER['REQUEST_METHOD']=='POST' && !empty($_POST['firstname'])){
    //Do something with posted data
    $out = htmlentities($_POST['firstname']).' has been abducted!';
}else{
    //Form has not been posted so show form
    $out = <<<FORM
<form action="" method="POST" >    
   <label for="firstname">First name:</label>
   <input type="text" id="firstname" name="firstname" /><br />
   <input type="submit" value="Report Abduction" name="submit" />
</form>
FORM;
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My first test Script</title>
</head>

<body>
<h1>My first test Script</h1>

<?php echo(isset($out))?$out:null; ?>

</body>
</html>
于 2012-06-06T07:05:07.420 に答える