-
Dec 27th, 2003, 04:26 PM
#1
"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
-
Dec 27th, 2003, 04:26 PM
#2
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>"
-
Dec 28th, 2003, 04:32 AM
#3
Hyperactive Member
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
-
Dec 28th, 2003, 06:14 AM
#4
I did see that, but you should be using $_POST and $_GET..
-
Dec 28th, 2003, 07:59 AM
#5
Addicted Member
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....
-
Dec 28th, 2003, 10:57 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|