Jump to content

trouble with easy code


luxeon

Recommended Posts

<html>
<body>
<form name="form" action="index.php" method="post">
<input name="x" type="text">
<input name="y" type="submit" value="oK">
</form>
<?php
if (!empty($_POST)) {
    if (isset($_POST['x'])) {
        print $_POST['x'];
    }
    if (isset($_POST['y'])) {
        print $_POST['y'];
    }
} else {
    print 'tralala';
}
?>
</body>
</html>

I've modified your code slightly, see below.  The code is "working" how I would expect it to, it depends what you want it to do ...  You can see the below script running on my server at: 

 

http://www.computer-monitors.org.uk/test-simple.php

 

Rgds

 

<html>
<body>


<?php
$x=$_POST['x'];
if(isset($_POST['y'])) 
{
echo $x;
}
else {echo "tralala";} 
?>



<form name="form" action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
<input name="x" type="text">
<input name="y" type="submit" value="ok">
</form>



</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.