在PHP中对齐表单

How can I center align a form thatI created?

$form = <<<END
<form method='post' action=''>
      Adresa IP host : <input type='text' name='host'><br><br>
      <input type='submit' name='submit' value='Connect'>
</form>
END;

echo $form;

$t = new TELNET();
if (!empty($_POST)){
   $host = $_POST['host'];
   echo("CONNECT:".$t->Connect($host, $name, $pass)."<br>");
   echo("LOGIN:".(int)$t->LogIn());
   echo("<br>Status Interfete:<br>");
  $interfaces_status = ($t->GetOutputOf("show interface status"));
foreach ($interfaces_status as $value) {
    echo "$value <br>";

I want the form to be on the center of the page.

In css:

form {
    width: 800px;
    margin: auto;
}

You need to done this using css. Please put form in one div and apply css according to div class.

<div class="frmCntr">
<form method='post' action=''>
      Adresa IP host : <input type='text' name='host'><br><br>
      <input type='submit' name='submit' value='Connect'>
</form>
</div>

and then add css in your css file like this:

.frmCntr{
width:80%; margin:auto;
}

or

form {
    width:80%; margin:auto;
    }

You can use margin:auto.

<form method='post' action='' style='margin:auto'>

If you not set a width for your form, you have to do it to get margin working in this case.

<form method='post' action='' style='margin:auto; width:400px'>