Silahkan ketik koding ini lalu simpan dengan nama "save.php"
<html>
<form action="save.php" method="post">
<input type="text" name="Bram" placeholder="nama">
<input type="text" name="Ahmad" placeholder="alamat">
<br><input type="submit" value="simpan"></br>
</form>
<table>
<tr>
<td>Nama</td>
<td>Alamat</td>
</tr>
<?php
session_start();
if(isset($_POST['Bram'])){
$_SESSION['Bram'][$_SESSION['Dimas']][0]=$_POST['Bram'];
$_SESSION['Ahmad'][$_SESSION['Dimas']][1]=$_POST['Ahmad'];
$_SESSION['Dimas']++;
}
for($i=0;$i<$_SESSION['Dimas'];$i++){
echo "<tr><td>".$_SESSION['Bram'][$i][0]."</td>";
echo "<td>".$_SESSION['Ahmad'][$i][1]."</td></tr>";
}
?>
</table>
</html>
Setelah itu, buat koding baru lagi dengan nama "index.php"
<?php
session_start();
$_SESSION['Dimas']=0;
header("location;save.php")
?>
Outputnya
Kamis, 22 September 2016
Kamis, 15 September 2016
Koding PHP Biodata sederhana banget
Langsung saja gan...
Cara Pertama kek gini gan:
<?php
$nama1 = "Aldi <br>";
$nama2 = "Aji <br>";
$nama3 = "Andi <br>";
$nama4 = "Ubay <br>";
$nama5 = "Imam <br>";
$alamat1 = "Medan <br>";
$alamat2 = "Papua <br>";
$alamat3 = "Kalimantan <br>";
$alamat4 = "Lampung <br>";
$alamat5 = "Sumbawa <br>";
echo "Nama = ".$nama1;
echo ' ';
echo "Alamat = ".$alamat1;
echo "Nama = ".$nama2;
echo ' ';
echo "Alamat = ".$alamat2;
echo "Nama = ".$nama3;
echo ' ';
echo "Alamat = ".$alamat3;
echo "Nama = ".$nama4;
echo ' ';
echo "Alamat = ".$alamat4;
echo "Nama = ".$nama5;
echo ' ';
echo "Alamat = ".$alamat5;
?>
Outputnya :
Cara Kedua kek gini gan:
<?php
$nama[0]="Aldi";
$nama[1]="Aji";
$nama[2]="Andi";
$nama[3]="imam";
$nama[4]="ubay";
$alamat[0]="Medan";
$alamat[1]="Papua";
$alamat[2]="kalimantan";
$alamat[3]="Sumbawa";
$alamat[4]="Lampung";
for($i=0;$i<5;$i++){
echo("<br/>Nama = $nama[$i]");
echo("<br/>Alamat = $alamat[$i]<br/>");
}
?>
Outputnya:
Cara Pertama kek gini gan:
<?php
$nama1 = "Aldi <br>";
$nama2 = "Aji <br>";
$nama3 = "Andi <br>";
$nama4 = "Ubay <br>";
$nama5 = "Imam <br>";
$alamat1 = "Medan <br>";
$alamat2 = "Papua <br>";
$alamat3 = "Kalimantan <br>";
$alamat4 = "Lampung <br>";
$alamat5 = "Sumbawa <br>";
echo "Nama = ".$nama1;
echo ' ';
echo "Alamat = ".$alamat1;
echo "Nama = ".$nama2;
echo ' ';
echo "Alamat = ".$alamat2;
echo "Nama = ".$nama3;
echo ' ';
echo "Alamat = ".$alamat3;
echo "Nama = ".$nama4;
echo ' ';
echo "Alamat = ".$alamat4;
echo "Nama = ".$nama5;
echo ' ';
echo "Alamat = ".$alamat5;
?>
Outputnya :
<?php
$nama[0]="Aldi";
$nama[1]="Aji";
$nama[2]="Andi";
$nama[3]="imam";
$nama[4]="ubay";
$alamat[0]="Medan";
$alamat[1]="Papua";
$alamat[2]="kalimantan";
$alamat[3]="Sumbawa";
$alamat[4]="Lampung";
for($i=0;$i<5;$i++){
echo("<br/>Nama = $nama[$i]");
echo("<br/>Alamat = $alamat[$i]<br/>");
}
?>
Outputnya:
Cara ketiga begini:
<?php
$nama=array("Aji","Aldi","Imam","Andi");
$alamat=array("Papua","Medan","Sumbawa","Kalimantan");
for($i=0;$i<=3;$i++){
echo("<br/>Nama = $nama[$i]");
echo("<br/>Alamat = $alamat[$i]");
}
?>
Outputnya:
Langganan:
Postingan (Atom)