Re: javascript & php

From: Date: Mon, 28 Jul 2003 21:15:14 +0000
Subject: Re: javascript & php
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-157246@lists.php.net to get a copy of this message
$color = "<script><!-- document.write(screen.colorDepth) //--> </script>"; $query = mysql_query("select id from color where color = '$color' "); $a = mysql_num_rows($query); Actually, what you want to do is possible, but difficult.
If you are willing to tolerate a page refresh, you can use this code to implement this function: <html> //header <?php if (empty($_GET['color'])){ ?> <body onLoad="document.aform.color.value=screen.colorDepth; document.aform.submit(); return true;"> <form name=aform action=<?php echo $_SERVER['PHP_SELF']; ?> method=get> <input type=hidden name=color> </form> <?php exit(); } // if else{ $color = $_GET['color']; $query = mysql_query("select id from color where color = '$color' "); $a = mysql_num_rows($query); <?php <body> ?> } // else // rest of page I'm not sure that this particular script will work, but I think that this method is the best way to have javascript send things to php. Hope this helps, Grant

« previous php.general (#157246) next »