SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problemm geting data from the form

    I just started with PHP, and I get some wierd problemm.

    I have a form, I submit it, but no data is passed to $_POST['fieldname']
    I tried GET method and I am able to see the entred data in the adress bar, but no data is passed to $_GET['fieldname']
    I tried $_REQUEST['fieldname'] also I tried to turn register_global on but no help

    Here is my code:

    Code:
    #!/usr/bin/php
    <?echo "Content-Type: text/html;charset=ISO-8859-1\n\n";
    ?>
    <HTML>
    <BODY>
    <?php
    echo $method;
    echo $_POST['topic'];  # Nothing is printed out
    echo $_REQUEST["user"];  # Nothing is printed out
    echo $user;
    import_request_variables();
    ?>
    HELLO
    
    <FORM ACTION="forum.php" METHOD="POST">
    Topic name: <input type="text" name="topic" value="TOPIC"><br>
    User Name: <input type="text" name="user" value="user_name">
    <br>
    Your msg here:
    <Textarea name="msg" Rows=20 cols=60></Textarea>
    <br><input type=submit name=submit value=OK >
    </form>
    
    <?php
    echo $_POST['topic'];  #Nothing is printed out
    echo $_POST['user'];  #Nothing is printed out
    ?>
    </BODY>
    </HTML>
    Any solution?? I use FC5 with apache.

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1)Get rid of this:

    #!/usr/bin/php
    <?echo "Content-Type: text/html;charset=ISO-8859-1\n\n";
    ?>

    2) You have to submit a form before there will be values in the $_POST[] array. So when you load the page you posted in your browser, no form will have been submitted yet, so no values will be in the array.

    You need to set up two pages. The first page should be a file with a .htm extension, and it should contain your form. The action attribute of the form should be your second page, which will be a page with a .php extension and contain your php code and any html you want to use to display the php values. When you submit the first page, it will send the form values to your second page.

  3. #3
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) If I get rid of any of those lines, the apache will return error code 500 Internal Server Error, because it dont know how to interpret the code.

    2.) I dont think this is the cause I tried in many different ways to make it work, and no positive results.

    I think, that the problemm is in apache or php configuration but I dont know how to fix it, and I am not sure about it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •