blurredvision
Lifer
I'm currently modifying a script that came with XAMPP that allows users to enter data into a table. Originally, the script allows any website visitors to enter data, as well as delete any data they see fit. Since I only have a select few who ever visit my site, I wasn't worried about the open nature of access to the data. After I found that the data was being deleted randomly en masse, I finally figured out that spiders were crawling my site and basically deleting the data simply by following the link.
So, I've integrated my main site with my SMF forum install. Now, the plan is that when someone goes to the page with this data table, it will check to make sure they are logged in to the forums before they can post or delete anything, effectively solving my problem.
However, I'm looking for a prompt that tells someone they need to be logged in before they can delete something. Currently, if you are logged in and try to delete something, a prompt will ask if you're sure, issuing an 'OK' or 'Cancel', and you proceed from there. When not logged in, I want a single prompt that says something to the effect of 'You must be logged in to do that!' with a single 'OK' button.
My current code (with different URL's pertaining to my site, of course) is as follows:
if (isset($_SESSION['user_id'])) {
echo "<td class=tabval><a onclick=\"return confirm('".$TEXT['cds-sure']."');\" href=cds.php?action=del&id=".$row['id']."><span class=red>[".$TEXT['cds-button1']."]</span></a></td>";
} else {
echo "<td class=tabval><a onclick=\"return confirm('".$TEXT['cds-restrict']."');\" href=cds.php\"\"><span class=red>[".$TEXT['cds-button1']."]</span></a></td>";
}
As the code is, if you are not logged in, you will be prompted with a confirmation box, at which point I'd like to have just a single 'OK' box instead of the 'OK' or 'Cancel'. Can I change the "return confirm" with something else to achieve this? I've briefly googled, but couldn't find anything. I like asking you guys anyway, since I always seem to learn something extra. 🙂
Thanks.
So, I've integrated my main site with my SMF forum install. Now, the plan is that when someone goes to the page with this data table, it will check to make sure they are logged in to the forums before they can post or delete anything, effectively solving my problem.
However, I'm looking for a prompt that tells someone they need to be logged in before they can delete something. Currently, if you are logged in and try to delete something, a prompt will ask if you're sure, issuing an 'OK' or 'Cancel', and you proceed from there. When not logged in, I want a single prompt that says something to the effect of 'You must be logged in to do that!' with a single 'OK' button.
My current code (with different URL's pertaining to my site, of course) is as follows:
if (isset($_SESSION['user_id'])) {
echo "<td class=tabval><a onclick=\"return confirm('".$TEXT['cds-sure']."');\" href=cds.php?action=del&id=".$row['id']."><span class=red>[".$TEXT['cds-button1']."]</span></a></td>";
} else {
echo "<td class=tabval><a onclick=\"return confirm('".$TEXT['cds-restrict']."');\" href=cds.php\"\"><span class=red>[".$TEXT['cds-button1']."]</span></a></td>";
}
As the code is, if you are not logged in, you will be prompted with a confirmation box, at which point I'd like to have just a single 'OK' box instead of the 'OK' or 'Cancel'. Can I change the "return confirm" with something else to achieve this? I've briefly googled, but couldn't find anything. I like asking you guys anyway, since I always seem to learn something extra. 🙂
Thanks.