Jump to content

(XOR) HELP!


kaitokid41

Recommended Posts

I have this main program calculating the hamming code of an 8-bit value (assuming all inputs are 1's and 0's) but i'm stuck in outputting its check bits...

 

<head>
<title>Hamming Code Calculator</title>
</head>

<body bgcolor="white">

<form action="getvalues.php" method="get">

<table width="800" border="1" STYLE="background-color:#CF3">
  <tr>
    <td><input type="text" name="d8" size=1></td>
    <td><input type="text" name="d7" size=1></td>
    <td><input type="text" name="d6" size=1></td>
    <td><input type="text" name="d5" size=1></td>
    <td><input type="text" name="d4" size=1></td>
    <td><input type="text" name="d3" size=1></td>
    <td><input type="text" name="d2" size=1></td>
    <td><input type="text" name="d1" size=1></td>
  </tr>
</table>

<input type="submit" value="Calculate">
</form>

</body>
</html>

and the file to be accessed is this...

 

</head>

<body>

<?php

$d1=$_GET["d1"];
$d2=$_GET["d2"];
$d3=$_GET["d3"];
$d4=$_GET["d4"];
$d5=$_GET["d5"];
$d6=$_GET["d6"];
$d7=$_GET["d7"];
$d8=$_GET["d8"];

$c1 = $d1 ^ $d2 ^ $d4 ^ $d5 ^ $d7;
$c2 = $d1 ^ $d3 ^ $d4 ^ $d6 ^ $d7;
$c4 = $d2 ^ $d3 ^ $d4 ^ $d8;
$c8 = $d5 ^ $d6 ^ $d7 ^ $d8;
?>

<table width="400" border="2" height="100">
  <tr>
    <td><?php echo "_"; ?></td>
    <td><?php echo $d7; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo $d5; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo $d4; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo $d2; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo $d1; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
  </tr>
  <tr>
    <td><?php echo "_"; ?></td>
    <td><?php echo $d7; ?></td>
    <td><?php echo $d6; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo $d4; ?></td>
    <td><?php echo $d3; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo " "; ?></td>
    <td><?php echo $d1; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
  </tr>
  <tr>
    <td><?php echo $d8; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo $d4; ?></td>
    <td><?php echo $d3; ?></td>
    <td><?php echo $d2; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
  </tr>
  <tr>
    <td><?php echo $d8; ?></td>
    <td><?php echo $d7; ?></td>
    <td><?php echo $d6; ?></td>
    <td><?php echo $d5; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
    <td><?php echo "_"; ?></td>
  </tr>
</table>

<?php

echo $c1;
echo $c2;
echo $c4;
echo $c8;

?>


</body>
</html>

...and for some reason, i can't see the output of $c4 and $c8. is there anything wrong with my code? :( advance thank you for those who'll help!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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