Display alert message and redirect the page
I have the following code. On failure i need to get the alert Already exists and redirect to te registration page. But on success i need to check the session and based on the role id i need to redirect the page but the alert and redirection is not happening in this case ... can you please tell where i am wrong
if ($referral_patient_id != NULL) {
echo "<script language='javascript'>
alert('Successfully Added');
if ($_SESSION['role_id'] != 6) {
echo 'window.location.href="../Laboratory_Home"';
} else {
echo 'window.location.href="../Billing_Home"';
} </script>";
} else {
echo "<script language='javascript'>
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
</script>";
}
javascript php codeigniter
add a comment |
I have the following code. On failure i need to get the alert Already exists and redirect to te registration page. But on success i need to check the session and based on the role id i need to redirect the page but the alert and redirection is not happening in this case ... can you please tell where i am wrong
if ($referral_patient_id != NULL) {
echo "<script language='javascript'>
alert('Successfully Added');
if ($_SESSION['role_id'] != 6) {
echo 'window.location.href="../Laboratory_Home"';
} else {
echo 'window.location.href="../Billing_Home"';
} </script>";
} else {
echo "<script language='javascript'>
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
</script>";
}
javascript php codeigniter
2
You've mixed up the PHP and JavaScript. Yourif ($_SESSION...
code is inside the previousecho
command still, so it will not be processed correctly.
– Kirk Beard
Nov 13 '18 at 7:37
add a comment |
I have the following code. On failure i need to get the alert Already exists and redirect to te registration page. But on success i need to check the session and based on the role id i need to redirect the page but the alert and redirection is not happening in this case ... can you please tell where i am wrong
if ($referral_patient_id != NULL) {
echo "<script language='javascript'>
alert('Successfully Added');
if ($_SESSION['role_id'] != 6) {
echo 'window.location.href="../Laboratory_Home"';
} else {
echo 'window.location.href="../Billing_Home"';
} </script>";
} else {
echo "<script language='javascript'>
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
</script>";
}
javascript php codeigniter
I have the following code. On failure i need to get the alert Already exists and redirect to te registration page. But on success i need to check the session and based on the role id i need to redirect the page but the alert and redirection is not happening in this case ... can you please tell where i am wrong
if ($referral_patient_id != NULL) {
echo "<script language='javascript'>
alert('Successfully Added');
if ($_SESSION['role_id'] != 6) {
echo 'window.location.href="../Laboratory_Home"';
} else {
echo 'window.location.href="../Billing_Home"';
} </script>";
} else {
echo "<script language='javascript'>
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
</script>";
}
javascript php codeigniter
javascript php codeigniter
edited Nov 13 '18 at 7:45
Krupesh Kotecha
2,05011134
2,05011134
asked Nov 13 '18 at 7:33
user5370838user5370838
4610
4610
2
You've mixed up the PHP and JavaScript. Yourif ($_SESSION...
code is inside the previousecho
command still, so it will not be processed correctly.
– Kirk Beard
Nov 13 '18 at 7:37
add a comment |
2
You've mixed up the PHP and JavaScript. Yourif ($_SESSION...
code is inside the previousecho
command still, so it will not be processed correctly.
– Kirk Beard
Nov 13 '18 at 7:37
2
2
You've mixed up the PHP and JavaScript. Your
if ($_SESSION...
code is inside the previous echo
command still, so it will not be processed correctly.– Kirk Beard
Nov 13 '18 at 7:37
You've mixed up the PHP and JavaScript. Your
if ($_SESSION...
code is inside the previous echo
command still, so it will not be processed correctly.– Kirk Beard
Nov 13 '18 at 7:37
add a comment |
3 Answers
3
active
oldest
votes
<?php if ($referral_patient_id != NULL) { ?>
<script type='javascript'>
alert('Successfully Added');
<?php if ($_SESSION['role_id'] != 6) { ?>
window.location.href="../Laboratory_Home";
<?php } else { ?>
window.location.href="../Billing_Home";
<?php } ?>
</script>
<?php }else { ?>
<script type='javascript'>
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
</script>
<?php } ?>
Try this one dude.
Yeah this is working
– user5370838
Nov 13 '18 at 9:14
Nice good job bro
– j3thamz
Nov 13 '18 at 9:24
add a comment |
Try this javascript code :
<script language='javascript'>
var referral_patient_id = '<?php echo $referral_patient_id; ?>';
if(referral_patient_id != null)
{
alert('Successfully Added');
var role_id = '<?php echo $_SESSION["role_id"]; ?>';
if (role_id != '6') {
window.location.href="../Laboratory_Home";
} else {
window.location.href="../Billing_Home";
}
}
else
{
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
}
</script>
add a comment |
You have mixed content. PHP and Javascript. Try this one
echo "<script language='javascript'>
alert('Successfully Added');
</script>";
if($_SESSION['role_id']!=6){
echo "<script language='javascript'>window.location.href='../Laboratory_Home'</script>";
} else {
echo "<script language='javascript'>window.location.href='../Billing_Home'</script>";
}
Or this one
echo "<script language='javascript'>
alert('Successfully Added');
if( ".$_SESSION['role_id']." !=6) {
window.location.href='../Laboratory_Home';
} else {
window.location.href='../Billing_Home';
}
</script>";
i am getting error "Message: syntax error, unexpected '.' "
– user5370838
Nov 13 '18 at 7:44
The if has to be PHP code not JavaScript
– Sebastian Speitel
Nov 13 '18 at 7:48
I updated the code...
– Simon
Nov 13 '18 at 7:59
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53275967%2fdisplay-alert-message-and-redirect-the-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
<?php if ($referral_patient_id != NULL) { ?>
<script type='javascript'>
alert('Successfully Added');
<?php if ($_SESSION['role_id'] != 6) { ?>
window.location.href="../Laboratory_Home";
<?php } else { ?>
window.location.href="../Billing_Home";
<?php } ?>
</script>
<?php }else { ?>
<script type='javascript'>
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
</script>
<?php } ?>
Try this one dude.
Yeah this is working
– user5370838
Nov 13 '18 at 9:14
Nice good job bro
– j3thamz
Nov 13 '18 at 9:24
add a comment |
<?php if ($referral_patient_id != NULL) { ?>
<script type='javascript'>
alert('Successfully Added');
<?php if ($_SESSION['role_id'] != 6) { ?>
window.location.href="../Laboratory_Home";
<?php } else { ?>
window.location.href="../Billing_Home";
<?php } ?>
</script>
<?php }else { ?>
<script type='javascript'>
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
</script>
<?php } ?>
Try this one dude.
Yeah this is working
– user5370838
Nov 13 '18 at 9:14
Nice good job bro
– j3thamz
Nov 13 '18 at 9:24
add a comment |
<?php if ($referral_patient_id != NULL) { ?>
<script type='javascript'>
alert('Successfully Added');
<?php if ($_SESSION['role_id'] != 6) { ?>
window.location.href="../Laboratory_Home";
<?php } else { ?>
window.location.href="../Billing_Home";
<?php } ?>
</script>
<?php }else { ?>
<script type='javascript'>
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
</script>
<?php } ?>
Try this one dude.
<?php if ($referral_patient_id != NULL) { ?>
<script type='javascript'>
alert('Successfully Added');
<?php if ($_SESSION['role_id'] != 6) { ?>
window.location.href="../Laboratory_Home";
<?php } else { ?>
window.location.href="../Billing_Home";
<?php } ?>
</script>
<?php }else { ?>
<script type='javascript'>
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
</script>
<?php } ?>
Try this one dude.
answered Nov 13 '18 at 8:01
j3thamzj3thamz
764
764
Yeah this is working
– user5370838
Nov 13 '18 at 9:14
Nice good job bro
– j3thamz
Nov 13 '18 at 9:24
add a comment |
Yeah this is working
– user5370838
Nov 13 '18 at 9:14
Nice good job bro
– j3thamz
Nov 13 '18 at 9:24
Yeah this is working
– user5370838
Nov 13 '18 at 9:14
Yeah this is working
– user5370838
Nov 13 '18 at 9:14
Nice good job bro
– j3thamz
Nov 13 '18 at 9:24
Nice good job bro
– j3thamz
Nov 13 '18 at 9:24
add a comment |
Try this javascript code :
<script language='javascript'>
var referral_patient_id = '<?php echo $referral_patient_id; ?>';
if(referral_patient_id != null)
{
alert('Successfully Added');
var role_id = '<?php echo $_SESSION["role_id"]; ?>';
if (role_id != '6') {
window.location.href="../Laboratory_Home";
} else {
window.location.href="../Billing_Home";
}
}
else
{
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
}
</script>
add a comment |
Try this javascript code :
<script language='javascript'>
var referral_patient_id = '<?php echo $referral_patient_id; ?>';
if(referral_patient_id != null)
{
alert('Successfully Added');
var role_id = '<?php echo $_SESSION["role_id"]; ?>';
if (role_id != '6') {
window.location.href="../Laboratory_Home";
} else {
window.location.href="../Billing_Home";
}
}
else
{
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
}
</script>
add a comment |
Try this javascript code :
<script language='javascript'>
var referral_patient_id = '<?php echo $referral_patient_id; ?>';
if(referral_patient_id != null)
{
alert('Successfully Added');
var role_id = '<?php echo $_SESSION["role_id"]; ?>';
if (role_id != '6') {
window.location.href="../Laboratory_Home";
} else {
window.location.href="../Billing_Home";
}
}
else
{
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
}
</script>
Try this javascript code :
<script language='javascript'>
var referral_patient_id = '<?php echo $referral_patient_id; ?>';
if(referral_patient_id != null)
{
alert('Successfully Added');
var role_id = '<?php echo $_SESSION["role_id"]; ?>';
if (role_id != '6') {
window.location.href="../Laboratory_Home";
} else {
window.location.href="../Billing_Home";
}
}
else
{
alert('Already Exists');
window.location.href = '../../LabAdd_Patients';
}
</script>
answered Nov 13 '18 at 7:53
Kinjal PathakKinjal Pathak
1045
1045
add a comment |
add a comment |
You have mixed content. PHP and Javascript. Try this one
echo "<script language='javascript'>
alert('Successfully Added');
</script>";
if($_SESSION['role_id']!=6){
echo "<script language='javascript'>window.location.href='../Laboratory_Home'</script>";
} else {
echo "<script language='javascript'>window.location.href='../Billing_Home'</script>";
}
Or this one
echo "<script language='javascript'>
alert('Successfully Added');
if( ".$_SESSION['role_id']." !=6) {
window.location.href='../Laboratory_Home';
} else {
window.location.href='../Billing_Home';
}
</script>";
i am getting error "Message: syntax error, unexpected '.' "
– user5370838
Nov 13 '18 at 7:44
The if has to be PHP code not JavaScript
– Sebastian Speitel
Nov 13 '18 at 7:48
I updated the code...
– Simon
Nov 13 '18 at 7:59
add a comment |
You have mixed content. PHP and Javascript. Try this one
echo "<script language='javascript'>
alert('Successfully Added');
</script>";
if($_SESSION['role_id']!=6){
echo "<script language='javascript'>window.location.href='../Laboratory_Home'</script>";
} else {
echo "<script language='javascript'>window.location.href='../Billing_Home'</script>";
}
Or this one
echo "<script language='javascript'>
alert('Successfully Added');
if( ".$_SESSION['role_id']." !=6) {
window.location.href='../Laboratory_Home';
} else {
window.location.href='../Billing_Home';
}
</script>";
i am getting error "Message: syntax error, unexpected '.' "
– user5370838
Nov 13 '18 at 7:44
The if has to be PHP code not JavaScript
– Sebastian Speitel
Nov 13 '18 at 7:48
I updated the code...
– Simon
Nov 13 '18 at 7:59
add a comment |
You have mixed content. PHP and Javascript. Try this one
echo "<script language='javascript'>
alert('Successfully Added');
</script>";
if($_SESSION['role_id']!=6){
echo "<script language='javascript'>window.location.href='../Laboratory_Home'</script>";
} else {
echo "<script language='javascript'>window.location.href='../Billing_Home'</script>";
}
Or this one
echo "<script language='javascript'>
alert('Successfully Added');
if( ".$_SESSION['role_id']." !=6) {
window.location.href='../Laboratory_Home';
} else {
window.location.href='../Billing_Home';
}
</script>";
You have mixed content. PHP and Javascript. Try this one
echo "<script language='javascript'>
alert('Successfully Added');
</script>";
if($_SESSION['role_id']!=6){
echo "<script language='javascript'>window.location.href='../Laboratory_Home'</script>";
} else {
echo "<script language='javascript'>window.location.href='../Billing_Home'</script>";
}
Or this one
echo "<script language='javascript'>
alert('Successfully Added');
if( ".$_SESSION['role_id']." !=6) {
window.location.href='../Laboratory_Home';
} else {
window.location.href='../Billing_Home';
}
</script>";
edited Nov 13 '18 at 7:56
answered Nov 13 '18 at 7:39
SimonSimon
566
566
i am getting error "Message: syntax error, unexpected '.' "
– user5370838
Nov 13 '18 at 7:44
The if has to be PHP code not JavaScript
– Sebastian Speitel
Nov 13 '18 at 7:48
I updated the code...
– Simon
Nov 13 '18 at 7:59
add a comment |
i am getting error "Message: syntax error, unexpected '.' "
– user5370838
Nov 13 '18 at 7:44
The if has to be PHP code not JavaScript
– Sebastian Speitel
Nov 13 '18 at 7:48
I updated the code...
– Simon
Nov 13 '18 at 7:59
i am getting error "Message: syntax error, unexpected '.' "
– user5370838
Nov 13 '18 at 7:44
i am getting error "Message: syntax error, unexpected '.' "
– user5370838
Nov 13 '18 at 7:44
The if has to be PHP code not JavaScript
– Sebastian Speitel
Nov 13 '18 at 7:48
The if has to be PHP code not JavaScript
– Sebastian Speitel
Nov 13 '18 at 7:48
I updated the code...
– Simon
Nov 13 '18 at 7:59
I updated the code...
– Simon
Nov 13 '18 at 7:59
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53275967%2fdisplay-alert-message-and-redirect-the-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
You've mixed up the PHP and JavaScript. Your
if ($_SESSION...
code is inside the previousecho
command still, so it will not be processed correctly.– Kirk Beard
Nov 13 '18 at 7:37