You are on page 1of 8

FormHandling.

html

<html>
<form action ="proses.php" method="POST">
Nama <input type ="text" name="nama"><br>
Telpon <input type ="text" name="telpon"><br>
Kelamin <input type = "radio" name="kelamin" value="pria">Pria
        <input type = "radio" name="kelamin" value="wanita">Wanita<br>
Deskripsi diri : <textarea name="deskripsi" cols="100%" rows="10"></textarea><br
>
<input type="submit"value="Kirim">
</form>
</html>

Proses.php

<?php
$nama = $_POST['nama'];
$telpon = $_POST['telpon'];
$kelamin = $_POST['kelamin'];
$deskripsi = $_POST['deskripsi'];

echo $nama."<br>", $telpon."<br>", $kelamin."<br>", $deskripsi."<br>";
?>
HandlingUpload.html

<html>
    <form action="upload.php" method="POST" enctype="multipart/form-data">
    Gambar <input type="file" name="gambar">
            <input type="submit"value="Simpan">
        </form>
</html>

Upload.php

<?php
$file = $_FILES['gambar']['tmp_name'];
$tujuan = $_FILES['gambar']['name'];
move_uploaded_file($file,$tujuan);
echo"File Telah Diupload";
?>
Validasi.html

<!DOCTYPE html>
    <head>
       <title>Cara Membuat Validasi Data</title>
    </head>
    <body>
       <form action="valmail.php" method="POST">
           <fieldset>
               <legend>Cara Membuat Validasi Data dengan HTML-PHP</legend>
                <p>Website : <input type="text" name="web"/></p>
                <p>E-Mail : <input type="text" name="email"/></p>
                <p><input type="submit" value="Proses Data"></p>
            </fieldset>
       </form>
        
    </body>
</html>

Valmail.php

<?php
$email =$_POST['email'];
echo"data_input : ".$email."<br>";
if(!filter_var($email,FILTER_VALIDATE_EMAIL)){
    echo "format email anda masih salah";
}
else {
    echo "format email sudah benar";
}
echo "<br>";
echo "<br>";
$website =$_POST['web'];
echo "data input : ".$website."<br/>";
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-
z0-9+&@#\/%=~_|]/i",$website)){
    echo "format website masih salah";
}
else {
    echo "format url website sudah benar";
}
?>
TUGAS

Registrasi.html

<html>
    <hl>Form Registrasi</hl>
    <hr>
    <form action="proses_registrasi.php" method="POST" enctype="multipart/form-
data">
    Nama     : <input type="text" name="nama"><br>
    Foto     : <input type="file" name="foto"><br>
    Alamat   : <input type="text" name="alamat"><br>
    Kelamin  : <input type="radio" name="kelamin" value="Pria">Pria
               <input type="radio" name="kelamin" value="Wanita">Wanita<br>
    Umur     : <input type="text" name="umur"><br>
    Email    : <input type="text" name="email"><br>
    Website  : <input type="text" name="web"><br>
    Username : <input type="text" name="username"><br>
    Password : <input type="text" name="password"><br>
    Retype Password : <input type="text" name="ulangi"><br>
                    <input type="submit" value="Registrasi">
    </form>
</html>

Proses_registrasi.php

<?php
$nama = $_POST['nama'];
$file = $_FILES['foto']['tmp_name'];
$tujuan = $_FILES['foto']['name'];
move_uploaded_file($file,$tujuan);
$alamat = $_POST['alamat'];
$kelamin = $_POST['kelamin'];
$umur = $_POST['umur'];
$email =$_POST['email'];
$website =$_POST['web'];
$username =$_POST['username'];
$password =$_POST['password'];
$retype =$_POST['ulangi'];

echo $nama."<br>", $file." telah di upload <br>", $alamat."<br>", $kelamin."<br>
", $umur."<br>";
echo"data_input : ".$email."<br>";
if(!filter_var($email,FILTER_VALIDATE_EMAIL)){
    echo "format email anda masih salah";
}
else {
    echo "format email sudah benar";
}
echo "data input : ".$website."<br/>";
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-
z0-9+&@#\/%=~_|]/i",$website)){
    echo "format website masih salah";
}
else {
    echo "format url website sudah benar";
}
echo $username."<br>", $password."<br>", $retype."<br>";
?>

You might also like