Hi All,
I would like to know what's wrong with the following code and how to correct it. The result.php file is not showing any frames.
Acutally using frames is not my target,
On the otherhand, I appericiate the help from anybody who can suggest something else instead of using frames to let the result.php file show the same result I'm trying to reach with frames?


the code for the form file :

<html>
<head>
<title>Insert your weight and height</title>
</head>

<body>

<form action="result.php" method="post">
Your weight: <input type="text" name="weight" />
Your height: <input type="text" name="height" />
<input type="submit" />
<p>&nbsp;</p>
</form>

</body>

</html>


the code for file result.php :

<html>
<head>
<title>Result</title>
</head>
<body>

<?php

$wt=$POST["weight"];
$ht=$
POST["height"];

?>

<?php

if ($wt>=70 && $wt<85)
if ($ht>=170 && $ht<180)
{ $img="images/normal-weight.gif";
$cond="Your weight is within normal limits";
$lf="http://www.yahoo.com";}

if ($wt>=95 && $wt<110)
if ($ht>=160 && $ht<170)
{ $img="images/over-weight.gif";
$cond="You are over weight";
$lf="http://www.google.com";}

?>

<frameset rows="20%,80%" >
<frame src="upperframe.php" scrolling="no">
<frame src="<?php print "$lf" ?>" scrolling="auto" target="_self">
<noframes>
</noframes>
</frameset>

</body>
</html>


the code for the upperframe.php file:

<html>
<head>
<title>Upper frame</title>
</head>
<body>

<?php

echo "<img src=\"$img\">";
echo "<br>";
echo "$cond";

?>

</body>

</html>

    For starters, this is the wrong syntax for an IF statement:

    if ($wt>=70 && $wt<85)
    if ($ht>=170 && $ht<180)
    { $img="images/normal-weight.gif";

    I think you meant to write:

    if (($wt>=70 && $wt<85) or ($ht>=170 && $ht<180))
    { $img="images/normal-weight.gif";
    ...

    in other words, the correct syntax is:
    if (something) { do something }

    or

    if ((something) or (something else)) { do something }

    or maybe

    if (((something) or (something else) and (something) and (something else)) or (something)) { do something }

      Hi etully,
      thank you for your help, however this syntax was working fine for me without using the frameset.

      But the main problem is in the frameset part of the code.....
      Anybody can help me on this?

        What does this mean?

        if ($wt>=70 && $wt<85)
        if ($ht>=170 && $ht<180)
        { $img="images/normal-weight.gif";
        $cond="Your weight is within normal limits";
        $lf="http://www.yahoo.com";}

        What is it supposed to do?

        I think the frames are working perfectly... and your if statements are creating a situation where your variables have no values so it APPEARS as if the framesets aren't working - when, in fact, they work fine.

          Write a Reply...