Solved

JAVASCRIPT/PHP -- A way to display a alert then process a header("Location:..")?

Posted on 2010-09-23
2
398 Views
Last Modified: 2012-06-21
The script I am working on is rather complicated but I do know it processes after clicking save,  The thing is, it normally scans for issues and changes and edits them, However, I want it to display an error, and then it would head back to the original page. Something like, for example, in php/javascript:

echo "<script>alert('mailto: href links cannot be a personal email address. Please contact us for additional info');</script>";
header("Location: http://linkhere.com");


What is ending up happening is the header is processed and the alert never gets displayed. Is there a way to HALT continuation of the script until I hit OK easily?
0
Comment
Question by:Valleriani
2 Comments
 
LVL 10

Accepted Solution

by:
bugada earned 500 total points
ID: 33743042
Why are you using header?
Normally your are not allowed call header() after an echo

Change your code as follows

echo "<script>alert('mailto: href links cannot be a personal email address. Please contact us for additional info');document.location.href='http://linkhere.com';</script>";

0
 
LVL 7

Author Closing Comment

by:Valleriani
ID: 33743312
Ahh okay, thanks for explaining that!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Ahax pagination 9 34
Generate PDF from MySQL using PHP 3 26
Review of the nodejs code 1 19
I'm a Human captcha checkbox 13 23
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question