Hi,

I am trying to get this to work but I think the first php include just
overrides all. I am sure there is a better way to go about this, but i need to stick with this format for the time being. Thanks,
Chuck

<script language="JavaScript">
	if (confirm("Include PHP file somefile.php?"))
	{ </script>

	<?php
		include("somefile.php");
	?>

	<script language="JavaScript">
}
else
{
	</script>

	<?php
		include("someotherfile.php");
	?>

	<script language="JavaScript">
}
</script>

    What exactly are you trying to achieve here?

    You got a client side scripting language telling a server side scripting language what to do is what i see. This is not possible to do.

      PHP is executed on the server before anything is sent to the browser

      Javascript is executed on the client side after everything is sent to the browser.

      Here is how you would have to accomplish this:

      <?php
      if(!array_key_exists('inc',$_GET)) {
      ?>
      <html>
      <body>
      <script>
      if(confirm('Include file: somefile.php'))
          document.location='thisfile.php?inc=somefile.php';
      else
          document.location='thisfile.php?inc=someotherfile.php';
      </script>
      die();
      <?php
      } //end if
      
      include($_GET['inc']);
      ?>

      but be forwarned that if you do this hackers can use this to execute all kinds of code on your server.

        Write a Reply...