html - Print php output in pop window on submitting the form

796

I would like to print the output of PHP in a pop window after the submission of html form. Below is sample of my code.

<?php
 if(isset($_POST['button1']))
 {
    if("condition match")
    {
       echo "output1";
    }
    else
    {
       echo "output2";
    }
 } 
?>
<form class='n-form' action='#' method='post'>
 <div> 
  <button type='submit' name="button1" class='button'>Submit</button>
    <a href="../home.php" class="button">Cancel</a>
</div>
</form>

It should be able to print the echo output in the pop window based on the if condition.

Looking forward to hear.

849

Answer

Solution:

There is no popout windows in php you have to do it in javascript

<?php
if(!empty($_POST))
{
    $text = (isset($_POST['button1'])) ? "output1" : "output2";
    echo '<script>alert("' . $text . '")</script>';
}
?>

People are also looking for solutions to the problem: php - How to get notification when a new text is added to a file?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.