Results 1 to 6 of 6

Thread: "submitting stuff never works!" -shaunyboy

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    "submitting stuff never works!" -shaunyboy

    this was originally posted by shaunyboy.. when i tried to reply it said it was an invalid thread, so, i'll just repost it all..

    ok, i'm just learnign php, and am kinda stuck. I am doign abotu submitting values, then an output being displayed, and it never works! i know that my code is right, as i am copying it out a book, or using examples off the internet!

    both files are in my localhost directory on my pc, and other php pages which dont involve submitting stuff work fine!

    All i get when i click the submit botton is a blank page!

    here is an example of some code:


    HTML PAGE:


    Code:
    <html><head> <title> String Manipulation</title> </head>
    <body>
    <form action="strings.php" method="post">
    <b>Enter some text here:</b><br/>
    <textarea name="txt" rows="3" cols="45"></textarea><br/>
    <input type="radio" name="fcn" value="strlen">
    Find the text length
    <input type="radio" name="fcn" value="strrev">
    Reverse the text<br/>
    <input type="radio" name="fcn" value="strtoupper">
    Chaneg to uppercase
    <input type="radio" name="fcn" value="strtolower">
    Chaneg to lowercase<br/>
    <input type="radio" name="fcn" value="ucwords">
    Make the first letters uppercase<hr/>
    <input type="submit" value="Manipulate">
    </form>
    </bosy>
    </html>

    PHP RESULTS PAGE:


    PHP Code:
    <html><head> <title>Results</title> </head> 
    <body> 

    <?php echo( $fcn($txt) ); ?> 

    </body> 
    </html>

    please help
    Like Archer? Check out some Sterling Archer quotes.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    and here's my original reply:

    where did those variables come from? did you define the variables $fcn or $txt at all?

    try this, it should work:
    PHP Code:
    <html><head> <title>Results</title> </head> 
    <body> 

    <?php echo $_POST['fcn']; ?>

    </body> 
    </html>
    by the way, you should correct your "</bosy>" to "<body>"
    Like Archer? Check out some Sterling Archer quotes.

  3. #3
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    Hey, i just tried your source and it works perfectly alright on my machine.

    In your HTML Page please change the form method from "post" to "get", (<form action="strings.php" method="get">)just for testing, this way you can see what variables are passed on to your php page!

    It should look something like this then:

    http://localhost/strings.php?txt=some+text&fcn=ucwords

    Please post your results for further assistance.

    where did those variables come from? did you define the variables $fcn or $txt at all?
    Take alook at his HTML Page, fcn is the name of the radio button that will be passed on txt is the name of the textarea that will be passed on! Nothing wrong with his source. Except the <bosy> thing


    Stephan
    Last edited by Sgt-Peppa; Dec 28th, 2003 at 04:37 AM.
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    I did see that, but you should be using $_POST and $_GET..
    Like Archer? Check out some Sterling Archer quotes.

  5. #5
    Addicted Member
    Join Date
    Oct 2003
    Location
    england
    Posts
    161
    yep, i deleted it because i read the sticky at the top and worked it out myself. thanks for the help anyway, using get is quite useful....

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    There's a register_globals option in the PHP configuration. If it's set to 1 the contents of _POST and _GET (and others) are made available as global variables. This is a security hazard though, so since version 4.1 (I think) register_globals defaults to 0 and you have to use the arrays.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width