<?php
    if($_GET) {
    $nama = $_POST['nama'];
    $email = $_POST['email'];
    $telp = $_POST['telp'];
    $berat = $_POST['berat'];
    $jumlah = $_POST['jumlah'];
    $tanggal = $_POST['tanggal'];
    $alamat = $_POST['alamat'];
     
    $error = array();
    if(empty($nama)){
    $error['nama'] = 'NAMA tidak boleh kosong';
    }
    if(empty($email)){
    $error['email'] = 'EMAIL tidak boleh kosong';
    }
    if(empty($telp)){
    $error['telp'] = 'No.TELP tidak boleh kosong';
    }
    if(empty($berat)){
    $error['berat'] = 'BERAT BARANG tidak boleh kosong';
    }
    else if ($berat < 5 == $jumlah = 5){
    $error['berat'] ='BERAT BARANG tidak sesuai';
    }
    if(empty($jumlah)){
    $error['jumlah'] = 'JUMLAH BARANG tidak boleh kosong';
    }
    else if ($berat > 5 == $jumlah >= 1){
    $error['jumlah'] ='JUMLAH BARANG tidak sesuai';
    }
    if(empty($tanggal)){
    $error['tanggal'] = 'TANGGAL tidak boleh kosong';
    }
    if(empty($alamat)){
    $error['alamat'] = 'ALAMAT tidak boleh kosong';
    }
    if(empty($error)){
    //prosess data
    }
    }
    ?><form name="PickUp" method="post" action="phptest2.php">
    <table width="75%" border="1" align="center">
    <tr>
    <td width="25%">NAMA</td>
    <td width="50%"><div style="color:red;">
    <input name="nama" id="nama" type="text" size="33" value="<?php echo isset($_POST['nama']) ? $_POST['nama'] : '';?>"/>
    <?php echo isset($error['nama']) ? $error['nama'] : '';?></div>
    </td>
    </tr>
    <tr>
    <td width="15%">EMAIL</td>
    <td width="35%"><div style="color:red;">
    <input name="email" id="email" type="text" size="33" value="<?php echo isset($_POST['email']) ? $_POST['email'] : '';?>"/>
    <?php echo isset($error['email']) ? $error['email'] : '';?></div>
    </td>
    </tr>
    <tr>
    <td width="15%">TELP</td>
    <td width="35%"><div style="color:red;">
    <input name="telp" id="telp" type="text" size="33" value="<?php echo isset($_POST['telp']) ? $_POST['telp'] : '';?>"/>
    <?php echo isset($error['telp']) ? $error['telp'] : '';?></div>
    </td>
    </tr>
    <tr>
    <td width="15%">BERAT BARANG</td>
    <td width="35%"><div style="color:red;">
    <input name="berat" id="berat" type="text" size="33" value="<?php echo isset($_POST['berat']) ? $_POST['berat'] : '';?>"/>
    <?php echo isset($error['berat']) ? $error['berat'] : '';?></div>
    </td>
    </tr> <tr>
    <td width="15%">JUMLAH BARANG</td>
    <td width="35%"><div style="color:red;">
    <input name="jumlah" id="jumlah" type="text" size="33" value="<?php echo isset($_POST['jumlah']) ? $_POST['jumlah'] : '';?>"/>
    <?php echo isset($error['jumlah']) ? $error['jumlah'] : '';?></div>
    </td>
    </tr>
    <tr>
    <td width="15%">PEMESANAN</td>
    <td width="35%"><div style="color:red;">
    <input name="tanggal" id="tanggal" type="text" size="33" value="<?php echo isset($_POST['tanggal']) ? $_POST['tanggal'] : '';?>"/>
    <?php echo isset($error['tanggal']) ? $error['tanggal'] : '';?></div>
    </td>
    </tr>
    <tr>
    <td width="15%" valign="top">ALAMAT</td>
    <td width="35%"><div style="color:red;">
    <textarea name="alamat" cols="25" rows="5" id="alamat" type="text" value="<?php echo isset($_POST['alamat']) ? $_POST['alamat'] : '';?>"></textarea>
    <?php echo isset($error['alamat']) ? $error['alamat'] : '';?></div>
    </td>
    </tr>
    <tr>
    <td width="15%"> </td>
    <td width="35%">
    <input name="submit" id="submit" type="Submit" value="PESAN" />
    <input name="button" id="button" type="button" value="BATAL" onclick=self.history.back()>
    </td>
    </tr>
    </table>
    </form><?php
    if($_POST) {
    $nama = $_POST['nama'];
    $email = $_POST['email'];
    $telp = $_POST['telp'];
    $berat = $_POST['berat'];
    $jumlah = $_POST['jumlah'];
    $tanggal = $_POST['tanggal'];
    $alamat = $_POST['alamat'];
 
    $error = array();
    if(empty($nama)){
    $error['nama'] = 'NAMA tidak boleh kosong';
    }
    if(empty($email)){
    $error['email'] = 'EMAIL tidak boleh kosong';
    }
    if(empty($telp)){
    $error['telp'] = 'No.TELP tidak boleh kosong';
    }
    if(empty($berat)){
    $error['berat'] = 'BERAT BARANG tidak boleh kosong';
    }
    else if ($berat < 5 == $jumlah = 5){
    $error['berat'] ='BERAT BARANG tidak sesuai';
    }
    if(empty($jumlah)){
    $error['jumlah'] = 'JUMLAH BARANG tidak boleh kosong';
    }
    else if ($berat > 5 == $jumlah >= 1){
    $error['jumlah'] ='JUMLAH BARANG tidak sesuai';
    }
    if(empty($tanggal)){
    $error['tanggal'] = 'TANGGAL tidak boleh kosong';
    }
    if(empty($alamat)){
    $error['alamat'] = 'ALAMAT tidak boleh kosong';
    }
    if(empty($error)){
    //prosess data
    }
    }
    ?><?php
include "phptest2.php"; //tidak usah jadikan dua file
?>
<form name="PickUp" method="post" action=""> <!-- hilangan nilai diattribute action="" -->
    <table width="75%" border="1" align="center">
    <tr>
    <td width="25%">NAMA</td>
    <td width="50%"><div style="color:red;">
    <input name="nama" id="nama" type="text" size="33" value="<?php echo isset($_POST['nama']) ? $_POST['nama'] : '';?>"/>
    <?php echo isset($error['nama']) ? $error['nama'] : '';?></div>
    </td>
    </tr>
    <tr>
    <td width="15%">EMAIL</td>
    <td width="35%"><div style="color:red;">
    <input name="email" id="email" type="text" size="33" value="<?php echo isset($_POST['email']) ? $_POST['email'] : '';?>"/>
    <?php echo isset($error['email']) ? $error['email'] : '';?></div>
    </td>
    </tr>
    <tr>
    <td width="15%">TELP</td>
    <td width="35%"><div style="color:red;">
    <input name="telp" id="telp" type="text" size="33" value="<?php echo isset($_POST['telp']) ? $_POST['telp'] : '';?>"/>
    <?php echo isset($error['telp']) ? $error['telp'] : '';?></div>
    </td>
    </tr>
    <tr>
    <td width="15%">BERAT BARANG</td>
    <td width="35%"><div style="color:red;">
    <input name="berat" id="berat" type="text" size="33" value="<?php echo isset($_POST['berat']) ? $_POST['berat'] : '';?>"/>
    <?php echo isset($error['berat']) ? $error['berat'] : '';?></div>
    </td>
    </tr> <tr>
    <td width="15%">JUMLAH BARANG</td>
    <td width="35%"><div style="color:red;">
    <input name="jumlah" id="jumlah" type="text" size="33" value="<?php echo isset($_POST['jumlah']) ? $_POST['jumlah'] : '';?>"/>
    <?php echo isset($error['jumlah']) ? $error['jumlah'] : '';?></div>
    </td>
    </tr>
    <tr>
    <td width="15%">PEMESANAN</td>
    <td width="35%"><div style="color:red;">
    <input name="tanggal" id="tanggal" type="text" size="33" value="<?php echo isset($_POST['tanggal']) ? $_POST['tanggal'] : '';?>"/>
    <?php echo isset($error['tanggal']) ? $error['tanggal'] : '';?></div>
    </td>
    </tr>
    <tr>
    <td width="15%" valign="top">ALAMAT</td>
    <td width="35%"><div style="color:red;">
    <textarea name="alamat" cols="25" rows="5" id="alamat" type="text" value="<?php echo isset($_POST['alamat']) ? $_POST['alamat'] : '';?>"></textarea>
    <?php echo isset($error['alamat']) ? $error['alamat'] : '';?></div>
    </td>
    </tr>
    <tr>
    <td width="15%"> </td>
    <td width="35%">
    <input name="submit" id="submit" type="Submit" value="PESAN" />
    <input name="button" id="button" type="button" value="BATAL" onclick=self.history.back()>
    </td>
    </tr>
    </table>
    </form>untuk kirim email bisa pake cara di http://www.myphptutorials.com/tutorials/22/tutorial-php-mengirim-email-dengan-php dan http://www.myphptutorials.com/tutorials/24/membuat-contact-form                 if(empty($berat)){
$error['berat'] = 'BERAT BARANG tidak boleh kosong';
}
else if ($berat < 5 == $jumlah = 5){
$error['berat'] ='BERAT BARANG tidak sesuai';
}
if(empty($jumlah)){
$error['jumlah'] = 'JUMLAH BARANG tidak boleh kosong';
}
else if ($berat > 5 == $jumlah >= 1){
$error['jumlah'] ='JUMLAH BARANG tidak sesuai';
}maksud nya jika berat kurang dari 5 jumlah ny minimal harus 5 / lebih dari 5