I have tried to figure this out myself I am new to PHP and I know its easy but I am missing something. I am trying to create something that if someone click a Button have it pass a value called id from the button hyper link for example:
<a href="abc123.html?id=d">Click Here...</a>
Then have the page abc123.html load and at the top of the page run this script below which is to see if id = f then if it does run the javascript code if not don't run it.
<?php
$vid = $_GET["id"];
if ($vid != "f") {
echo "<script type=""text/javascript"">"
echo "if (screen.width<800)"
echo "{"
echo "window.location=""../mobile/default.html"""
echo "}"
echo "</script>"
}
?>
However I am getting an PHP Undefined variable error from the Get ID. I have tried to use isset and that doesn't seem to work. But I know the error is caused if the value of id is blank because the id value might not always be available only if the user clicks on the abc123.html link. Can someone please tell me what I am doing wrong?
I have researched answers here:
Undefined variable error in PHP
and here...
http://matthom.com/archive/2005/02/19/php-passing-variables-across-pages
and here...
<?php if (isset($_GET['id'])) $vid = $_GET['id']; if (isset($_GET['id']) != "f") { echo isset($_GET['id']); echo "<script type=\"text/javascript\">"; echo "if (screen.width<800)"; echo "{"; echo "window.location=\"../mobile/default.html\""; echo "}"; echo "</script>"; }; ?>
Any suggestions as to what I am doing wrong? Thanks! – Frank G. Jan 8 '13 at 20:11