I am creating a citation form where user will enter the information of a journal(name, title, pages, date etc) and after submitting the form, all input values get saved in php variables and create reference. Now I want to add a function that after submitting the form, user can select which reference style he/she wants. On selecting an option the result should be changed.
<select name="refer" type="text" class="form-control input" >
<option value="1">APA</option>
<option value="2">Harvard</option>
</select>
My PHP code is as follows
if(isset($_POST['submit'])){
$fname= $_POST['fname'];
$mname= $_POST['mname'];
$lname= $_POST['lname'];
$title= $_POST['title'];
$journal= $_POST['journal'];
$page= $_POST['page'];
$volume= $_POST['volume'];
$month= $_POST['month'];
$year= $_POST['year'];
$issue= $_POST['issue'];
$refer= $_POST['refer'];
switch($refer){
case '1': echo "<h4>". ucfirst($lname). ','. ucfirst($fname[0]) .'. (' . $year . '). ' . $title. '. '. $journal. ', '. $volume .'('. $issue .'), '.$page ."</h4>" ;
break;
case '2': echo "<h4>". ucfirst($lname). ','. ucfirst($fname[0]) .'. ' . $year . '. ' . $title. '. '. $journal. ', '. $volume .'('. $issue .'), p.'.$page ."</h4>" ;
break;
}
}
But this switch is not working because it is inside isset($_POST['submit']) statement and won't work without submit button click and also I can't put it outside isset($_POST['submit']) statement.