url - Php Redirect to a new page from an if statement -
this question has answer here:
- php parse/syntax errors; , how solve them? 11 answers
please professional programmers in house, wrong code?
i error whenever try run it.
parse error: syntax error, unexpected ';' in c:\xampp\htdocs\a\go.php on line 8
the php code:
<?php $term=$_post['term']; $level=$_post['level']; if ( $term = 'first'; $level='js1'; ) { header("location: result.php"); exit(); } elseif ( $term = 'first'; $level='js2'; ) { header("location: result2.php"); exit(); } else { $error = "entry invalid"; } ?>
check if condition. if , else if conditions must not contain semicolons. if using 2 comparisons must use && or || in between them. if using = in if , elseif statement return true.
<?php $term=$_post['term']; $level=$_post['level']; if ($term == 'first' && $level=='js1') { header("location: result.php"); exit(); } else if ($term == 'first' && $level='js2') { header("location: result2.php"); exit(); } else { $error = "entry invalid"; } ?>
Comments
Post a Comment