PDA

Click to See Complete Forum and Search --> : "submitting stuff never works!" -shaunyboy


kows
Dec 27th, 2003, 03:26 PM
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:


<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:


<html><head> <title>Results</title> </head>
<body>

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

</body>
</html>


please help

kows
Dec 27th, 2003, 03:26 PM
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:
<html><head> <title>Results</title> </head>
<body>

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

</body>
</html>

by the way, you should correct your "</bosy>" to "<body>"

Sgt-Peppa
Dec 28th, 2003, 03:32 AM
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 :D


Stephan

kows
Dec 28th, 2003, 05:14 AM
I did see that, but you should be using $_POST and $_GET..

shaunyboy
Dec 28th, 2003, 06:59 AM
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....

CornedBee
Dec 28th, 2003, 09:57 AM
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.