Domanda

Ho creato una forma che funziona bene, ma quando ho messo in una tabella che pensa sempre la forma è incompleto - c'è un modo posso metterlo in una tabella (in modo che sembra piacevole!) Senza questo problema ?

----- Il mio HTML ------

<h2 class="green">Interested in making life easier?</h2>

<form method="post" action="sendemail.php">

<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />

Name:  
<input type="text" name="visitor" size="25" />
<br />

Address:<input type="text" name="visitoradd" size="25" />
<br />

City:<input type="text" name="visitorcity" size="15" />
<br />

Postcode:<input type="text" name="visitorpost" size="15" />
<br />

Email:<input type="text" name="visitormail" size="25" />
<br />

Telephone Number:<input type="text" name="visitortel" size="25" />
<br />


Bookkeeping/Payroll:<select name="bp" size="1">
<option value=" Bookkeeping">Bookkeeping </option>
<option value=" Payroll ">Payroll</option>
</select>
<br />

Number of transactions: <input type="text" name="transcations" size="15" />
<br />

Number of employees:<input type="text" name="employees" size="15" />
<br />

Payroll weekly/monthly:<select name="pmw" size="1">
<option value=" Weekly">Weekly</option>
<option value=" Monthly">Monthly</option>
</select>
<br />

<br />
<INPUT TYPE="image" SRC="images/btnSubmit.png" ALT="Submit Form">
<br />
</form>

----- Il mio PHP -----

<?php

$visitor = $_POST['visitor'];
$visitoradd = $_POST['visitoradd'];
$visitorcity= $_POST['visitorcity'];
$visitorpost= $_POST['visitorpost'];
$visitormail = $_POST['visitormail'];
$visitortel = $_POST['visitortel'];
$bp = $_POST['bp'];
$transcations = $_POST['transcations'];
$employees = $_POST['employees'];
$pmw = $_POST['pmw'];


if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Please enter valid e-mail.</h2>\n";
$badinput = "<h2>Click the back button to retry.</h2>\n";
echo $badinput;
die ("Thank you.");
}

if(empty($visitor) || empty($visitormail)  || empty($visitorcity) || empty($visitorpost) || empty($visitoradd)   || empty($visitortel) || empty($bp) || empty($transcations)  || empty($employees) || empty($pmw) || empty($pmw)) 
{
echo "<h2>Please fill in all fields, click the back button to retry</h2>\n";
die ("Thank you.");
}

$message = "
Name: $visitor\n
Address: $visitoradd\n
City: $visitorcity\n
Post Code: $visitorpost\n
Email: $visitormail\n
Phone Number: $visitortel\n
Bookkeeping/Payroll: $bp\n
Number of Transactions: $transcations\n
Number Of Employees: $employees\n
Payroll Weekly/Monthly: $pmw\n"
;

$subject = "Payment Details";

mail("contact@email.com",$subject,$message,$visitormail);

?>

<p align="center">
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />

<br />
<a href="home.php">Click here to Finish</a>
</p> 
È stato utile?

Soluzione

<h2 class="green">Interested in making life easier?</h2>
<form method="post" action="sendemail.php">
    <?php
    $ipi = getenv("REMOTE_ADDR");
    $httprefi = getenv ("HTTP_REFERER");
    $httpagenti = getenv ("HTTP_USER_AGENT");
    ?>
    <input type="hidden" name="ip" value="<?php echo $ipi ?>" />
    <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
    <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
    <table>
        <tr>
            <td><label for="visitor">Name:</label></td>
            <td><input type="text" name="visitor" size="25" /></td>
        </tr>
        <tr>
            <td><label for="visitoradd">Address:</label></td>
            <td><input type="text" name="visitoradd" size="25" /></td>
        </tr>
        <tr>
            <td><label for="visitorcity">City:</label></td>
            <td><input type="text" name="visitorcity" size="15" /></td>
        </tr>
        <tr>
            <td><label for="visitorpost">Postcode:</label></td>
            <td><input type="text" name="visitorpost" size="15" /></td>
        </tr>
        <tr>
            <td><label for="visitormail">E-mail:</label></td>
            <td><input type="text" name="visitormail" size="25" /></td>
        </tr>
        <tr>
            <td><label for="visitortel">Telephone Number:</label></td>
            <td><input type="text" name="visitortel" size="25" /></td>
        </tr>
        <tr>
            <td><label for="bp">Bookkeeping/Payroll:</label></td>
            <td>
                <select name="bp" size="1">
                    <option value=" Bookkeeping">Bookkeeping </option>
                    <option value=" Payroll ">Payroll</option>
                </select>
            </td>
        </tr>
        <tr>
            <td><label for="transcations">Number of transactions:</label></td>
            <td><input type="text" name="transcations" size="15" /></td>
        </tr>
        <tr>
            <td><label for="employees">Number of employees:</label></td>
            <td><input type="text" name="employees" size="15" /></td>
        </tr>
        <tr>
            <td><label for="pmw">Payroll weekly/monthly:</label></td>
            <td>
            <select name="pmw" size="1">
                <option value=" Weekly">Weekly</option>
                <option value=" Monthly">Monthly</option>
            </select>
            </td>
        </tr>
    </table>
    <br />
    <INPUT TYPE="image" SRC="images/btnSubmit.png" ALT="Submit Form">
    <br />
</form>

Altri suggerimenti

Inserire i tag di modulo al di fuori del tavolo in questo modo:

<form>
  <TABLE>
  <TR>
    <TD>Name</TD>
    <TD><input type="text" name="visitor" size="25" /></TD>
  </TR>
  <TR>
    <TD>Address</TD>
    <TD><input type="text" name="address" size="25" /></TD>
  </TR>
  </TABLE>
</form>

Se si ha bisogno di specificare larghezza, altezza, ecc .. poi usare i CSS.

Ecco un tutorial su di esso: http://www.w3schools.com/css/

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top