Reputation: 1303
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>";
}
}
}
Upvotes: 2
Views: 130
Reputation: 47776
You can use header
but you must make sure not to send any output before, or otherwise use output buffering. Also, calling header
doesn't actually end the script, so it's a good thing to use an exit
if you want to stop there.
header('Location: edit.php?article_name=1');
exit;
Upvotes: 2