Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New Coder
    Join Date
    Jan 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry I'm going crazy, please help!

    Hi!

    I'm building my php scripts in one computer and i don't have any problem, but when I test the same programs in other (win xp ie) don't work at all, specially whe you do submit. I tried testing with this simple script:

    <?php
    if($_POST["test"]){
    print "test ok";
    print $testa;
    }
    ?>
    <HTML>
    <HEAD>
    </HEAD>
    <BODY>
    <form action="<?$_SERVER['PHP_SELF']?>" method="post" name="forma" enctype="multipart/form-data">
    <input type="submit" name="test" value="submit">
    <input type="text" name="texta" size="20">
    </form>
    </BODY>
    </HTML>

    When you submit the form, print "test ok", but no the value of $testa variable. I use this way to send data and always works. (wamp5)

    I checked the services wampapache and wampmysqld and both are working then i tried printing phpinfo() and it works too.

    the problem is, i guess, that the form in not sending data!
    Last edited by erickkz; 01-12-2006 at 05:33 PM.

  • #2
    Senior Coder
    Join Date
    Jul 2005
    Location
    UK
    Posts
    1,051
    Thanks
    6
    Thanked 13 Times in 13 Posts
    Could it be that the name of the input is 'texta' and you are trying to print 'testa'?

  • #3
    Regular Coder Masterslave's Avatar
    Join Date
    Dec 2005
    Posts
    287
    Thanks
    2
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php
    if($_POST["test"]){
    print 
    "test ok";
    print 
    $testa;
    }
    ?>
    Code:
     <input type="text" name="texta" size="20">
    It think you've made a typo...

  • #4
    New Coder
    Join Date
    Jan 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    oh! sorry, my mistake, but the real code is:

    <?php
    if($_POST["test"]){
    print "test ok";
    print $texta;
    }
    ?>
    <HTML>
    <HEAD>
    </HEAD>
    <BODY>
    <form action="<?$_SERVER['PHP_SELF']?>" method="post" name="forma" enctype="multipart/form-data">
    <input type="submit" name="test" value="submit">
    <input type="text" name="texta" size="20">
    </form>
    </BODY>
    </HTML>

    And how I said before, don't send data!

  • #5
    Senior Coder
    Join Date
    Jul 2005
    Location
    UK
    Posts
    1,051
    Thanks
    6
    Thanked 13 Times in 13 Posts
    Don't you need to assign the contents of the text field to a $var via $_POST before trying to print/echo it?

    PHP Code:
    $texta $_POST["texta"];
    print 
    $texta

  • #6
    New Coder
    Join Date
    Sep 2005
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I was also thinking that.

  • #7
    New Coder
    Join Date
    Jan 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Nice suggestion!

    Nice!

    But don't work either .

    Maybe is the php.ini configuration. Any<way, I think i give up!

    thanks people!

  • #8
    New Coder
    Join Date
    Jan 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry A last try!

    I'll give a last try editing php.in and the httpd.conf.

    But why the scripts run nice in my computer and the other not?
    that supposed is the same installation.

  • #9
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by Pennimus
    Don't you need to assign the contents of the text field to a $var via $_POST before trying to print/echo it?

    PHP Code:
    $texta $_POST["texta"];
    print 
    $texta
    No you don't.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #10
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If register_globals is off (which it is by default, and should stay that way), then you can only access POST variables by the $_POST superglobal array. Also, I wonder if the enctype="multipart/form-data" is malfunctioning in IE, as it's usually used in conjunction with a file upload field.
    "$question = ( to() ) ? be() : ~be();"

  • #11
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    It shouldn't as I used it in forms and it worked.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #12
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,096
    Thanks
    11
    Thanked 101 Times in 99 Posts
    You have the "texta" field AFTER the submit button , so it does not get sent, also if you are using the superglobals (as you should be) $_POST in one place then use it everywhere...

    PHP Code:
    <?php
    if($_POST["test"]){
    print 
    "test ok";
    print 
    $_POST['texta'];
    }
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #13
    Regular Coder
    Join Date
    Feb 2003
    Posts
    345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You should never rely in submit's names:
    Edited: Why? Explorer won't always send their values.
    PHP Code:
    <?php
    if (isset($_POST['test'])) {
      print 
    "test ok";
      if (isset(
    $_POST['texta'])) {
        
    $texta stripslashes($_POST['texta']);
        print 
    htmlentities($texta);
      }
    }
    ?>
    <HTML>
    <HEAD>
    </HEAD>
    <BODY>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="forma" enctype="multipart/form-data">
    <input type="text" name="texta" size="20">
    <input type="hidden" name="test" value="1">
    <input type="submit" value="submit">
    </form>
    </BODY>
    </HTML>
    Last edited by maltrecho; 01-13-2006 at 07:49 AM.

  • #14
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,096
    Thanks
    11
    Thanked 101 Times in 99 Posts
    You should never rely in submit's names:
    Edited: Why? Explorer won't always send their values.
    ?? yes it will if it is well formed

    the issue was the ordering of the inputs which your form corrects, adding the extra field however is redundant.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #15
    New Coder
    Join Date
    Jan 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile at last!!

    At last!

    finally, it was my php.ini configuration!

    thanks people!
    Your advices are very usefull to avoid further problems. I will change my poor programming style.
    Last edited by erickkz; 01-13-2006 at 04:19 PM.


  •  

    Posting Permissions

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