Jump to content

Recommended Posts

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 file
test2.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!!!!
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_globals

In your case you need to use:
[code]
<?php
echo $_POST['name'];
?>
[/code]

Ken
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.
Yes, but then he would see the code and not just a blank page.

Change your test2.php page to:

[code]
<?PHP
echo '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]
<?PHP
phpinfo();
?>
[/code]
[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, :P
Maybe there were problems with his download or something? Or like kenrbnsn said, it could be that the server doesn't allow short style tags.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.