php pop up box after if statement?

I am doing some php to make an app and i need a window to pop up when i run my php if statement. At the minute, when i run the app, my if statement works, but goes to a new page to display the info from my if statement. How would i change my echo to have a box pop up with the message instead?

Hope that makes sense.

my if statement:

<?php

$status = $_POST['status'];

if($status == "")

echo "Please enter a status.";

else {

echo "Thanks.";

}


?>

again, just to clarify, i would like my echo statements to be a pop up message box instead, i tried to use alert but that threw errors, i have looked around but cant seem to find a php pop up box.

Answers


Using PHP and javascript, you can alert something like this:

<?php

    $status = $_POST['status'];

    if($status == "")

        $msg = "Please enter a status.";

    else {

        $msg = "Thanks.";

    }


?>
<script>
    alert('<? echo $msg; ?>');
</script>

PHP is more of a "server side" language that runs business logic. If you want a popup you will have to do it with javascript.

Perhaps something like the following:

<?php
$status = $_POST['status'];

if($status == "")

?>

<script>
alert("Please enter a status.");
</script>

<?php

else {

echo "Thanks.";

}

?>

Need Your Help

Thread in C++ in MacOS X

c++ multithreading osx std

I'm trying to run some code using threads in standard C++ (installed with XCode) in MacOS X Mavericks. But I'm getting some errors. Here's a minimal working example:

show row information in textview Android

android json listview textview

I have a listView in my fist screen that I show the information in each row from json , when I click on each item, I have another listView with new information and textview in the same page, I want...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.