Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 452015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:01:49+00:00 2026-05-12T22:01:49+00:00

Okay, so I have this partially working game, I know the solutions should be

  • 0

Okay, so I have this partially working game, I know the solutions should be simple in terms of game play,but for a noob nothing is ever simple, so here, I am requesting help, as a noob, what am I doing wrong, I think it’s the way I setup the check-boxes, but I need other eyes, thank you.

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" />
<table border="1" align="center" />
<?php
$fire = $_REQUEST["fire"];
$variable = $_REQUEST["variable"];
$step = $_REQUEST["step"];
$i = $_REQUEST["i"];
$j = $_REQUEST["j"];

if(isset($_POST['$i$j']))
{ 
echo 'checked';
}

//first there will be script that randomly generate 5 ships for both users

$step = $_POST['step'];
//4 steps of the game
if ($step > 3) 
{
    $step = 1;
} 
else 
{
    $step += 1;
}//end if
//step 1, first player 
if ($step == 1) 
{
    echo "Player 1";
 // Loop through the alphabet from a to j and stop before k on this for loop
    for ($i = a; $i < k; $i++)
 {
 // Print out the table with the letters from a to j using the variable $i
     echo "<tr><td width='20' align='right'>$i</td>";
  // Loop through the numbers for $j using numbers from 1 to less than 11 which is 10;
       for ($j = 1; $j < 11; $j++)
    {

    echo "<td><input type='submit' value='fire' name='$i$j'></td>";
       } 
    // end for loop
     echo "</tr>";
    } 
 // end for loop
    echo "<tr><td></td>";

 for ($j = 1; $j < 11; $j++)
 {

     echo "<td>$j</td>";
    }
    echo "</tr></table>";
    //step 2 result of first player fire
} 

else if($step == 2)
 {

    echo "Result 1";
        for ($i = a; $i < k; $i++)
  {

     echo "<tr><td width='20' align='right'>$i</td>";
       for ($j = 1; $j < 11; $j++){
      //<input type="checkbox" name="state[]" value="NE">
         echo "<td><input type='checkbox' type='submit' checked='checked' name='$i$j'></td>";
       } // end for loop
     echo "</tr>";
    } // end for loop
    echo "<tr><td></td>";
    for ($j = 1; $j < 11; $j++){
     echo "<td>$j</td>";
    }
    echo "</tr></table><br><input type='submit' name='' value='Player 2 Turn'>";
    //step 3 second player fireing
} else if($step == 3) {
    echo "Player 2";
    for ($i = a; $i < k; $i++){
     echo "<tr><td width='20' align='right'>$i</td>";
       for ($j = 1; $j < 11; $j++){
         echo "<td><input type='submit' value='fire' name='$i$j'></td>";
       } // end for loop
     echo "</tr>";
    } // end for loop
    echo "<tr><td></td>";
    for ($j = 1; $j < 11; $j++){
     echo "<td>$j</td>";
    }
    echo "</tr></table>";
    //step 4 result of second player fire
} else {
    echo "Result 2 ";
    for ($i = a; $i < k; $i++){
     echo "<tr><td width='20' align='right'>$i</td>";
       for ($j = 1; $j < 11; $j++){
         echo "<td><input type='checkbox' checked='checked' disabled='disabled' name='$i$j'></td>";
       } // end for loop
     echo "</tr>";
    } // end for loop
    echo "<tr><td></td>";
    for ($j = 1; $j < 11; $j++){
     echo "<td>$j</td>";
    }
    echo "</tr></table><br><input type='submit' name='' value='Player 1 Turn'>";
}//end if
for ($j = 1; $j < 11; $j++){
       if ($checked){
         echo "<td><input type='checkbox' checked='checked' name='variable'></td>";
        } else {
         echo "<td><input type='checkbox' name='variable'></td>";
        }
       }  

?>

<input type="hidden" name="step" value="<?php echo "$step"; ?>"
</form>
</center>
</html>  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:01:50+00:00Added an answer on May 12, 2026 at 10:01 pm

    A couple of things I see wrong:

    • echo "<td><input type='checkbox' type='submit' checked='checked' name='$i$j'></td>"; has two type attributes.
    • <input type="hidden" name="step" value="<?php echo "$step"; ?>" does not close the input tag.
    • Your not closing your table tag.

    Try running your page through an online html validation service or use the firefox validation addon to validate the page and fix the errors in your html.

    Another issue is that your not validating all your input from the user. ie. your $_REQUEST data. This can lead to Cross-site scripting and can be dangerous to users. Although this is only trivial in this example, user input validation is a good practice to get into in all situations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 258k
  • Answers 258k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer >>> right shifts and fills with 0 at the left… May 13, 2026 at 10:57 am
  • Editorial Team
    Editorial Team added an answer Seems like Gruber has revised his regular expression: \b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.])(?:[^\s()<>]+|\([^\s()<>]+\))+(?:\([^\s()<>]+\)|[^`!()\[\]{};:'".,<>?«»“”‘’\s])) Works… May 13, 2026 at 10:57 am
  • Editorial Team
    Editorial Team added an answer The dotted-decimal IPv4 address can be converted to an integer,… May 13, 2026 at 10:57 am

Related Questions

I'm trying to create my own error window for the project I am working
Hey all. Okay here is the situation. I would like to be able to
Essentially, what I want to do (in DirectX) is to take two partially-transparent images
I have a form served in non-UTF-8 (it’s actually in Windows-1251). People, of course,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.