Execut 1 of many scripts
Posted: Tue Nov 18, 2008 11:14 am
If someone clicks on link for a page that contains more then one script, like below, how can you make sure it only runs the script being called??
Right now I have links setup on left nav as:
<a class="sm_textlightblue" href="scripts.php?admin_util=update_grade=1">Upgrade</a>
<a href="scripts.php?admin_util=add_chapter">Add a Chapter</a>
and it's suppose to run the second script you see below, however, when you click on it "Add a chapter", the first and second script are executed (below).
How can I make it more specific so it only runs the script the link is calling??? Please help!
scripts.php
//first script
//first script
//Beginning of enter/update queries for various options
if ($update_grade = 1){
mysql_query("UPDATE students SET re_status_id_fk = 3 WHERE re_grade_id_fk = 12");
echo "<p> Congratulations, the 12th graders have been marked as graduated successfully!</p>";
}else {
echo "<p>We aplogize for the incovenience but there was an error in marking the 12th graders as graduates. Please run the query again. If you continue to receive this error contact your website administrator.</p>";
mysql_close();
include ('templates/footer.inc');
ob_end_flush();
exit();
}
if ($update_grade = 1){
mysql_query("UPDATE students SET re_grade_id_fk = re_grade_id_fk+1 WHERE re_grade_id_fk < 12");
echo "<p>The grade for all REBEL members have been updated.</p>";
}else {
echo "<p>There was an error in updating the grades. Please run the query again. If you continue to receive this error contact your website administrator.</p>";
mysql_close();
include ('templates/footer.inc');
ob_end_flush();
exit();
}
//second script
//If entering a new chapter
if (isset($_POST['enter_chapter'])){
$query = "INSERT INTO chapter (ch_option) VALUES ('{$_POST['inputbox']}')";
$result = @mysql_query($query);
if($result){
echo "<p>{$_POST['inputbox']} has been added as a new chapter!!!</p>";
}else {
echo "<p>Uh oh, this isn't supposed to happen! Please try again. Stupid error 6.</p><p>".mysql_error() ."</p>";
}
mysql_close();
include ('templates/footer.inc');
ob_end_flush();
exit();
}
Right now I have links setup on left nav as:
<a class="sm_textlightblue" href="scripts.php?admin_util=update_grade=1">Upgrade</a>
<a href="scripts.php?admin_util=add_chapter">Add a Chapter</a>
and it's suppose to run the second script you see below, however, when you click on it "Add a chapter", the first and second script are executed (below).
How can I make it more specific so it only runs the script the link is calling??? Please help!
scripts.php
//first script
//first script
//Beginning of enter/update queries for various options
if ($update_grade = 1){
mysql_query("UPDATE students SET re_status_id_fk = 3 WHERE re_grade_id_fk = 12");
echo "<p> Congratulations, the 12th graders have been marked as graduated successfully!</p>";
}else {
echo "<p>We aplogize for the incovenience but there was an error in marking the 12th graders as graduates. Please run the query again. If you continue to receive this error contact your website administrator.</p>";
mysql_close();
include ('templates/footer.inc');
ob_end_flush();
exit();
}
if ($update_grade = 1){
mysql_query("UPDATE students SET re_grade_id_fk = re_grade_id_fk+1 WHERE re_grade_id_fk < 12");
echo "<p>The grade for all REBEL members have been updated.</p>";
}else {
echo "<p>There was an error in updating the grades. Please run the query again. If you continue to receive this error contact your website administrator.</p>";
mysql_close();
include ('templates/footer.inc');
ob_end_flush();
exit();
}
//second script
//If entering a new chapter
if (isset($_POST['enter_chapter'])){
$query = "INSERT INTO chapter (ch_option) VALUES ('{$_POST['inputbox']}')";
$result = @mysql_query($query);
if($result){
echo "<p>{$_POST['inputbox']} has been added as a new chapter!!!</p>";
}else {
echo "<p>Uh oh, this isn't supposed to happen! Please try again. Stupid error 6.</p><p>".mysql_error() ."</p>";
}
mysql_close();
include ('templates/footer.inc');
ob_end_flush();
exit();
}