How can I add parameters to URL whit PHP. In javascript I use something like
document.URL = "?param1=sth".
I have a list of article whit checkbox that have value equals article id (from the database) and when user check 1 checkbox I want to redirect him to http://blablabla.com/edit?article_name=1(article id);
$checkbox = "<input type=\"checkbox\" name=\"article[]\" value=\"{$article["id"]}\"/>";
$checkbox are generate automatically depending on number of articles from the database.
if(isset($_POST['edit']) AND isset($_POST['article'])){
$articol = $_POST['article'];
if (is_array($articol)) {
$contor = 0;
foreach ($articol as $item) {
if(isset($item))
$contor ++;
}
if($contor == 1 ){
**redirect user to edit.php?article_name=1;**
}else {
echo "<script type='text/javascript'>";
echo "alert(\"You can't edit more than 1 article!\")";
echo "</script>";
}
}
}
You can use
headerbut you must make sure not to send any output before, or otherwise use output buffering. Also, callingheaderdoesn’t actually end the script, so it’s a good thing to use anexitif you want to stop there.