problem with $_SERVER['POST']

anilson1

New Member
Messages
45
Reaction score
0
Points
0
Can anyone tell me what's wrong with it?
my code doesn't work, before I even press any button it activates the value of button 3. check it.

------------------------------------

<html>
<head>
<title>VOG - test</title>
<style>
.buttonchenger {background-color:red;color:white}
a {text-decoration:none;color:blue}
a:hover {color:red}
body {font-family:Tahoma;color:red;font-size:9}
</style
</head>
<body >
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table border="0" width="100%">
<tr><td><input class="buttonchenger" type="button" value="Checkup Winners" name="check"/></td></tr>
<tr><td><input class="buttonchenger" type="button" value="Create DB print" name="create"/></td></tr>
<tr><td><input class="buttonchenger" type="button" value="Update DB" name="update"/></td></tr>
</table>
<?php
if(isset($_POST['check']))
{echo "test1";}
else
{ if(isset($_POST['create']))
{echo "test2";}
else
{checkValuesIntoDB1();}
}

function checkValuesIntoDB1()
{
echo " this is another test";
}
?>

</form>
</body>
</html>


---------------------------------

that was the full code.
how can I get values from pressing the buttons?
 

tnl2k7

Banned
Messages
3,131
Reaction score
0
Points
0
We don't provide script support in Free Hosting, this forum is for ACCOUNT and HOSTING issues.

* Moved to Programming Help *
 

natsuki

New Member
Messages
112
Reaction score
0
Points
0
Code:
<tr><td><input class="buttonchenger" type="[color=red]button[/color]" value="Checkup Winners" name="check"/></td></tr>
<tr><td><input class="buttonchenger" type="[color=red]button[/color]" value="Create DB print" name="create"/></td></tr>
<tr><td><input class="buttonchenger" type="[color=red]button[/color]" value="Update DB" name="update"/></td></tr>
you should have used type="submit" instead

and it's really a hard time reading through code with mangled braces >_<
PHP:
<?php
if (isset($_POST['check']))
{
    echo 'test1';
}
else
{
    if (isset($_POST['create']))
    {
        echo 'test2';
    }
    elseif (isset($_POST['update']))
    {
        checkValuesIntoDB1();
    }
}

function checkValuesIntoDB1()
{
    echo ' this is another test';
}
?>
looks better
 
Last edited:
Top