$_POST[] not working in php

后端 未结 1 833
后悔当初
后悔当初 2021-01-29 15:59

I\'ve started learning PHP. Managed to setup things.

I\'m using php version 5.3.13.

I\'m trying to post some info to a html form and receive it in a php file.

相关标签:
1条回答
  • 2021-01-29 16:19

    Here is a super simple example, I suggest you begin to look for example tutorials @ your favorite search engine, or buy a book.

    Edit: Do you even have PHP installed? you mention inetpub which is a IIS path.

    <?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>
    
    0 讨论(0)
提交回复
热议问题