|
-
Aug 1st, 2002, 10:20 AM
#1
Thread Starter
Hyperactive Member
PHP forms
I've posted a form to a php page which works, but for some reason on my PWS Win 98 machine it won't receive the posts. Normally on php you don't have to call the form do you, just put in the name of the form object name:
e.g. on my form:
<INPUT TYPE='TEXT' NAME='atextbox'>
on my posting to page.
<?php
echo "The information you posted was $atextbox<BR>\n";
?>
It keeps telling me that $atextbox is not defined!
ASP, PHP, VB, JavaScript, CSS, HTML, a little C and a little CGI.
Richard Whitehouse.
Join the Footie Predictions League
"Make it idiot proof and someone will make a better idiot."
-
Aug 1st, 2002, 11:33 AM
#2
Stuck in the 80s
If there's no information in the box, it won't set it as a variable. But if you are putting information in it, try accessing it like so:
PHP Code:
<?php
//if you use PHP 4.1.0 or higher:
echo "The information you posted was " . $_REQUEST['atextbox'] . "<BR>\n";
//earlier version than PHP 4.1.0:
echo "The information you posted was " . $HTTP_SERVER_VARS['atextbox'] . "<BR>\n";
?>
If it works the above way, it means that register_globals is off in the php ini.
-
Aug 1st, 2002, 11:40 AM
#3
Stuck in the 80s
Also, I believe if you are trying to access it in a function, you'll have to tag it as global like so:
PHP Code:
<?php
if(isset($submit)) {
parsedata();
} else {
showform();
}
function showform() {
//show our form
}
function parsedata() {
global $donkey;
//in order to print out $donkey, one of our forms
//variables, we have to tag it as global like above
echo $donkey;
}
?>
or you can do it:
PHP Code:
<?php
if(isset($_REQUEST['submit'])) {
parsedata();
} else {
showform();
}
function showform() {
//show our form
}
function parsedata() {
echo $_REQUEST['donkey'];
}
?>
As the variables in $_REQUEST are superglobals, they are accessable anywhere in the script. This is also the new PHP standard.
Let me know if any of this helps.
-
Aug 1st, 2002, 01:41 PM
#4
Frenzied Member
is it a warning message? you have to turn that off in the php.ini file. or you can define you variables.
-
Aug 2nd, 2002, 03:11 AM
#5
Thread Starter
Hyperactive Member
Cheers everyone I'll try your ideas tonight, and get back to you on monday to say if they work. but I'm sure they will work.
Thanks alot.
ASP, PHP, VB, JavaScript, CSS, HTML, a little C and a little CGI.
Richard Whitehouse.
Join the Footie Predictions League
"Make it idiot proof and someone will make a better idiot."
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
|