Form problem

Discussion in 'PHP' started by Mrans, Sep 28, 2007.

  1. #1
    hey guys
    i have a problem with this code
    this code dont runnig, why?
    <?php
    
    if ($_POST['_submit_check']) {
          print "Hello, ";
          print $_POST['my_name'];
    } else {
          print <<<_HTML_
      <form method="post" action="$_SERVER[PHP_SELF]" >
      Your name: <input type="text" name="my_name" />
      <br />
      <input type="submit" value="Say Hello" />
      <input type="hidden" name="_submit_check" value="1" />
      </form>
      _HTML_;
    }
    
    ?>
    PHP:

     
    Mrans, Sep 28, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    _HTML_; <- This has to go at the very left, without spaces in front of it.
     
    nico_swd, Sep 28, 2007 IP
  3. hemlata

    hemlata Peon

    Messages:
    18
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hello, why dont you try simple html display in php instead of using heredoc syntax. like
    if ($_POST['_submit_check']) {
          print "Hello, ";
          print $_POST['my_name'];
    } else {
          print '<form method="post" action="$_SERVER[PHP_SELF]" >
      Your name: <input type="text" name="my_name" />
      <br />
      <input type="submit" value="Say Hello" />
      <input type="hidden" name="_submit_check" value="1" />
      </form>';
    Code (markup):
    Regards,
     
    hemlata, Sep 28, 2007 IP
  4. Mrans

    Mrans Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    whats your mean?
    _HTML_space; ?
     
    Mrans, Sep 28, 2007 IP
  5. Mrans

    Mrans Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    this code does not work :(
     
    Mrans, Sep 28, 2007 IP
  6. Mrans

    Mrans Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    this code show form well but after sending it show Object not found!
     
    Mrans, Sep 28, 2007 IP
  7. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #7
    In front.

    space_HTML_;


    Because the $_SERVER variable is between single quotes.
    
    if ($_POST['_submit_check']) {
          print "Hello, ";
          print $_POST['my_name'];
    } else {
          print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" >
      Your name: <input type="text" name="my_name" />
      <br />
      <input type="submit" value="Say Hello" />
      <input type="hidden" name="_submit_check" value="1" />
      </form>';
    
    PHP:
     
    nico_swd, Sep 28, 2007 IP
  8. Mrans

    Mrans Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Oh thats right
    thank you dear friend:)
     
    Mrans, Sep 28, 2007 IP