Help - Search - Members - Calendar
Full Version: In Php Doesnt Work "isset"
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
madeinukraine
My web-site cant work correcly:


...
<form action=\"registration.php?registrate\" method=\"post\" target=\"_self\">
...
if (isset($registrate))
{
...mytext...
}


But when i click button it doesnt wont to load mytext(((

What wrong?????
Ed
You're trying to use register_globals, which is a now deprecated feature:
http://php.net/manual/en/security.globals.php

You should and always should use the superglobal counter parts, so your form is is passing a GET parameter, so:

CODE
if(isset($_GET['registrate']))
{
... body
}


If you were to want to get say an input field from a form with a method of post, it would simply be:

CODE
$_POST['thenameofthefield']
NDBoost
correct me if im wrong (i havent read much about PHP5) but couldnt you set the superglobal to a var to make it easier to handle later on?

IE:
CODE
$registrate = $_GET['registrate'];

if(isset($registrate))
{
... body
}
Ed
QUOTE(NDBoost @ Sep 4 2009, 04:15 PM) *
correct me if im wrong (i havent read much about PHP5) but couldnt you set the superglobal to a var to make it easier to handle later on?

IE:
CODE
$registrate = $_GET['registrate'];

if(isset($registrate))
{
... body
}


You can, but there's little point. Unless you're directly altering the value of $_GET['registrate'], there's no real reason, it is just one more variable the php internal table has to keep track of.
madeinukraine
so i must rewrite all text?

Can i use my text that i allready write in this server?
Ed
QUOTE(madeinukraine @ Sep 4 2009, 04:38 PM) *
so i must rewrite all text?

Can i use my text that i allready write in this server?


You should rewrite it for portability, a lot of servers have register_globals off, those who have it on are behind the times.
madeinukraine
how to write "<form....>"????
Ed
QUOTE(madeinukraine @ Sep 4 2009, 04:43 PM) *
how to write "<form....>"????


That remains the same, it's just the php you need to change, so any POST elements are $_POST['nameoffield'] and any GET elements are $_GET['nameoffield'], there's also a $_REQUEST which is either.

http://php.net/manual/en/language.variables.superglobals.php
madeinukraine
English - is foreign language for me... sorry but i ts to hurt blush.gif
Can you write little example by form with (only first line)???

i found some examples in russian languages but it doesnt work(((
Ed
CODE
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
   if(isset($_POST['name']))
   {
        echo 'The name you have entered is: ', htmlspecialchars($_POST['name, ENT_QUOTES), "<br>\n";
   }
}
?>


The form:

CODE
<form action="" method="post">
<input type="text" name="name">
<input type="submit">
</form>


Very simple example.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.