Pop up alert
Moderator: General Moderators
Pop up alert
Hi all,
I need the PHP code for the following scenario and this is the logic:
If user_session = username
and financealert == 'yes'
pop up an alert.
Your help is much needed.
Regards.
I need the PHP code for the following scenario and this is the logic:
If user_session = username
and financealert == 'yes'
pop up an alert.
Your help is much needed.
Regards.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Pop up alert
What does you code currently look like? It doesn't help all that much if the code is fed to you like binary soup because you won't understand how it works and what the premise behind it is 
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Pop up alert
The following is my code:
<?php
session_start();
$_SESSION['$username'];
require_once("admin/db.php");
$result = mysql_query("SELECT financealert, username FROM users WHERE financealert='yes'") or die(mysql_error());
if($user_session == $username && $financealert == 'yes') {
?>
<script type="text/javascript">
windows.alert('ATTENTION');
</script>
<?php
}
?>
The alert is not showing anyway.
<?php
session_start();
$_SESSION['$username'];
require_once("admin/db.php");
$result = mysql_query("SELECT financealert, username FROM users WHERE financealert='yes'") or die(mysql_error());
if($user_session == $username && $financealert == 'yes') {
?>
<script type="text/javascript">
windows.alert('ATTENTION');
</script>
<?php
}
?>
The alert is not showing anyway.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Pop up alert
The problem seems to lie in the logic of the script
Nowhere in the script is any of the variables ($user_session, $username, $financealert) defined, so your script executes but when it comes to the decision making it has nothing to check against and the alert is not displayed.
Code: Select all
<?php if($user_session == $username && $financealert == 'yes') ?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Pop up alert
Hi all,
I have got this code and it does not really look at the database, it just pops up with the alert when i log onto the system. Can anyone help me out and tell me what i am not doing right?
<?php
session_start();
$username = $_SESSION['username'];
require_once("admin/db.php");
$result = mysql_query("SELECT financealert FROM users WHERE financealert='Yes'") or die(mysql_error());
$sendAlert = mysql_result($result,0,'financealert');
if($_SESSION['username'] == $username && $sendAlert == 'Yes')
{
echo"<script>alert('gh');</script>";
}
?>
Need your help.
Regards.
I have got this code and it does not really look at the database, it just pops up with the alert when i log onto the system. Can anyone help me out and tell me what i am not doing right?
<?php
session_start();
$username = $_SESSION['username'];
require_once("admin/db.php");
$result = mysql_query("SELECT financealert FROM users WHERE financealert='Yes'") or die(mysql_error());
$sendAlert = mysql_result($result,0,'financealert');
if($_SESSION['username'] == $username && $sendAlert == 'Yes')
{
echo"<script>alert('gh');</script>";
}
?>
Need your help.
Regards.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Pop up alert
Code: Select all
<?php $_SESSION['username'] == $username && $sendAlert == 'Yes' ?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Pop up alert
Hi,
I wanted the pop up to appear only when the user that is logged in has been assigned 'yes' on the financealert field. The issue now is that the pop up keeps coming up even if the 'yes' has not been assign to that particular user.
Regards.
I wanted the pop up to appear only when the user that is logged in has been assigned 'yes' on the financealert field. The issue now is that the pop up keeps coming up even if the 'yes' has not been assign to that particular user.
Regards.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Pop up alert
Code: Select all
<?php $result = mysql_query("SELECT financealert FROM users WHERE financealert='Yes'") or die(mysql_error()); ?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering