just-j Posted July 8, 2006 Share Posted July 8, 2006 ok i just got into PHP scripting and downloaded wamp server, which is mysql, php, and apache server all in one nifty installation. my problem is i make on file:test1.html....<FORM ACTION="test2.php" method="post">Type name here:<input type="text" name="name"><br><input type=submit value="Login"><br></FORM>....then other filetest2.php<?echo $name;?>and when i test it in the web browser it goes to the php page but it just dosent echo anything.. ive been trying to figure this out for 2 days now... HELP!!!! Quote Link to comment https://forums.phpfreaks.com/topic/14031-html-forms-and-php-calling-the-variable-solved/ Share on other sites More sharing options...
toplay Posted July 8, 2006 Share Posted July 8, 2006 Read up on PHP basics so you don't get frustrated.Change this:echo $name;to this:echo $_POST['name'];See:http://us2.php.net/manual/en/reserved.variables.php Quote Link to comment https://forums.phpfreaks.com/topic/14031-html-forms-and-php-calling-the-variable-solved/#findComment-54811 Share on other sites More sharing options...
kenrbnsn Posted July 8, 2006 Share Posted July 8, 2006 You are probably using a book that assumes that the register_globals option is enabled. This was the default up until about 3 years ago when it was found that enabling register_globals can cause security problems. The default was changed to disabled and now to get the values from forms and URLs, you need to reference the appropriate superglobal array: $_POST for forms using the method="post" and $_GET for forms using method="get" and for variables on the URL. See http://www.php.net/register_globalsIn your case you need to use:[code]<?phpecho $_POST['name'];?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/14031-html-forms-and-php-calling-the-variable-solved/#findComment-54812 Share on other sites More sharing options...
just-j Posted July 8, 2006 Author Share Posted July 8, 2006 i tried the $_post and still cant figure it out.. still getting a blank page when it goes to the php page. this is what i have in the .php page as of now.[code]<html><head><title>Untitled Document</title></head><body><?echo $_POST['name'];?></body></html>[/code]i even tried to set the post name to a var. and then echoing it and still nothing is output to the browser. Quote Link to comment https://forums.phpfreaks.com/topic/14031-html-forms-and-php-calling-the-variable-solved/#findComment-54824 Share on other sites More sharing options...
Kurt Posted July 8, 2006 Share Posted July 8, 2006 Maybe its echoing nothing because your host doesnt support php? Quote Link to comment https://forums.phpfreaks.com/topic/14031-html-forms-and-php-calling-the-variable-solved/#findComment-54826 Share on other sites More sharing options...
kenrbnsn Posted July 8, 2006 Share Posted July 8, 2006 You are using short tags "<?", your host may not have short tags enabled, try using "<?php" instead.Ken Quote Link to comment https://forums.phpfreaks.com/topic/14031-html-forms-and-php-calling-the-variable-solved/#findComment-54827 Share on other sites More sharing options...
toplay Posted July 8, 2006 Share Posted July 8, 2006 Yes, but then he would see the code and not just a blank page.Change your test2.php page to:[code]<?PHPecho 'Name: ', isSet($_POST['name']) ? $_POST['name'] : 'Not set' ;?>[/code]Make sure the test2.php is in the same directory as your html form.Create this in a separate file and run it to see what your php settings are and it will tell you if your server and PHP are setup right:[code]<?PHPphpinfo();?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14031-html-forms-and-php-calling-the-variable-solved/#findComment-54828 Share on other sites More sharing options...
toplay Posted July 8, 2006 Share Posted July 8, 2006 [quote author=Kurt link=topic=99878.msg393612#msg393612 date=1152376227]Maybe its echoing nothing because your host doesnt support php?[/quote]Read his/her post again carefully. You'll notice that it's a local installation. Quote Link to comment https://forums.phpfreaks.com/topic/14031-html-forms-and-php-calling-the-variable-solved/#findComment-54829 Share on other sites More sharing options...
Kurt Posted July 8, 2006 Share Posted July 8, 2006 [quote author=toplay link=topic=99878.msg393616#msg393616 date=1152376481][quote author=Kurt link=topic=99878.msg393612#msg393612 date=1152376227]Maybe its echoing nothing because your host doesnt support php?[/quote]Read his/her post again carefully. You'll notice that it's a local installation.[/quote]D'oh, :PMaybe there were problems with his download or something? Or like kenrbnsn said, it could be that the server doesn't allow short style tags. Quote Link to comment https://forums.phpfreaks.com/topic/14031-html-forms-and-php-calling-the-variable-solved/#findComment-54832 Share on other sites More sharing options...
just-j Posted July 8, 2006 Author Share Posted July 8, 2006 man i love these forums!! every one is so quick to reply. it was the short tag <? problem changed it to <?php and works perfect.. im back in learning business.. thanks everyone. Quote Link to comment https://forums.phpfreaks.com/topic/14031-html-forms-and-php-calling-the-variable-solved/#findComment-54834 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.