Bing Bang
Bing Bang

Reputation: 534

How to create popup using only PHP?

Actually I figured out a way to do this: What follows isn't exactly working code, but it does convey my idea. I've implemented this idea and it does work. I think the drawback is for complex pages, because the entire page has to be reloaded every time a popup goes up or down. But, on the good side, NO MORE JAVA SCRIPTS!!! YAY!!! :)

<html>
<body class="classfile.css">
<div                                 <?//add background stuff here?>
<?php
if(isset($_POST["popupmode"]))
   echo ' style="opacity:0.15" '; //this will fade out any background stuff
 ?>
style="height:1000px;with:600"px>
<form method="post" action="thispage.php">
<input type="hidden" name="popupmode">
<input type="submit" value="bring up popup">
</form>
</div>

 <?php
 if(isset($_POST["popupmode"]))
  {
   echo '<div style="with:200px;height:200px;top:-800px;left:200px;border-style:raised">';
  echo '<form method="post" action="thispage.php">';
  echo '<input type="submit" value="bring down popup">';
  echo '</form></div>';
  }    
  ?>
  </body>
  </html>

Upvotes: 0

Views: 7823

Answers (1)

Fernando Cordeiro
Fernando Cordeiro

Reputation: 403

PHP Is Server Side. It is not very smart to reload the page to "Popup" something.

There are PURE-CSS Lightboxes, and you can use JavaScript or even your PHP solution as a FallBack, incase the broser is old. Still, it's not a very good idea. I would try a CSS Solution, since it can happen on the client.

Something like:

.popupBox {
    display:none;
}
.popup:hover .popupBox{
    display: block;
}

Or if you need clicks:

.popupBox {
    display:none;
}
.popupBox:target{
    display: block;
}

Upvotes: 1

Related Questions