/    Sign up×
Community /Pin to ProfileBookmark

Something does not work

Ok, so I learn php now, and so I did this :

I created a PHP file asdqwezxc.php with the following html code :

[CODE]<form action = “http://localhost/justatest.php” method=”get”>
HDD: <input type=”text” name=”HDD”/><br>
CDROM: <input type=”text” name=”CDROM”/><br>
<input type=”submit”/>[/CODE]

Then I created a file justatest.php with this code :

[CODE] <?
echo(“<p>HDD is $HDD</p>”);
echo(“<p>CDROM is $CDROM</p>”);
?>[/CODE]

In the book I read about php, it says that PHP will created variables $HDD & $CDROM. But when I load justatest.php clicking Submit button, it see only
HDD is
CDROM is
And nothing happens.
Why? :rolleyes:

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@the_treeJun 30.2006 — Because register_globals has been switched off for security reasons since I-don't-know-when. You'll find the variables you want in the [B]$_GET[/B] array.[code=php]$HDD = $_GET['HDD'];
$CDROM = $_GET['CDROM'];

echo "<p>HDD is $HDD</p>n";
echo "<p>CD-ROM is $CDROM</p>";
[/code]
or[code=php]echo "<p>HDD is {$_GET['HDD']}</p>n";
echo "<p>CD-ROM is {$_GET['CDROM']}</p>";[/code]
or[code=php]echo '<p>HDD is '.$_GET['HDD']."</p>n";
echo '<p>CD-ROM is '.$_GET['CDROM'].'</p>';[/code]
Copy linkTweet thisAlerts:
@timmahJun 30.2006 — just a FYI- that will switch to $_POST[blah] if you use the post method.
Copy linkTweet thisAlerts:
@Maverick-XLauthorJun 30.2006 — Thanks guys, you really helped me out.

[URL=http://img518.imageshack.us/img518/3483/sucess5ui.jpg]Success[/URL]

By the way, could this register_globals thingy be found in php.ini?
Copy linkTweet thisAlerts:
@NogDogJun 30.2006 — Yes, it's set in php.ini. Current best practices are to leave it "off", and access your form values from the $_POST or $_GET array (depending on which method the calling form uses). This will ensure that your scripts are portable as they will work regardless of the register_globals setting, and it will make your code more robust, secure, and maintainable.
Copy linkTweet thisAlerts:
@Maverick-XLauthorJun 30.2006 — Yes, it's set in php.ini. Current best practices are to leave it "off", and access your form values from the $_POST or $_GET array (depending on which method the calling form uses). This will ensure that your scripts are portable as they will work regardless of the register_globals setting, and it will make your code more robust, secure, and maintainable.[/QUOTE]
Thanks, I will keep this in mind, because I am really new to PHP.
×

Success!

Help @Maverick-XL spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...