Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created March 27, 2013 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpfiddle/5253162 to your computer and use it in GitHub Desktop.
Save phpfiddle/5253162 to your computer and use it in GitHub Desktop.
simple form state
<?php
$_POST['kelas'] = isset($_POST['kelas']) ? $_POST['kelas'] : 0; // this line removes notices (ignore this)
$_POST['tahun'] = isset($_POST['tahun']) ? $_POST['tahun'] : 0; // this line removes notices (ignore this)
?>
<form method='post'>
<select name='kelas'>
<option value=0>Pilih kelas</option>
<option value=1 <?php if($_POST['kelas']==1) echo 'selected' ?> >X-1</option>
<option value=2 <?php if($_POST['kelas']==2) echo 'selected' ?> >X-2</option>
<option value=3 <?php if($_POST['kelas']==3) echo 'selected' ?> >X-3</option>
</select>
<select name='tahun'>
<option value=0>Pilih tahun</option>
<option value=2012 <?php if($_POST['tahun']==2012) echo 'selected' ?> >2012/2013</option>
<option value=2011 <?php if($_POST['tahun']==2011) echo 'selected' ?> >2011/2012</option>
<option value=2010 <?php if($_POST['tahun']==2010) echo 'selected' ?> >2010/2011</option>
</select>
<input type='submit' name='submit' />
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment