ianco Posted March 25, 2010 Share Posted March 25, 2010 Hi all I have some javascript code in the head section of my page but i want it to have php variables, 2 from a form and the other which i create. so far the code i have is echo '<!-- window.location = "http://www.domain.org/folder/' . $_POST["jou"] . '/'; echo $arb; echo '/' . $_POST["num"] . '/index.sht" //-->'; which is include in and include script. The script reads $_POST["jou"] and $_POST["num"] but doesn't output $arb (which is created from num in the form) What do i need to do to it so that $arb is output? Thanks Ian Quote Link to comment https://forums.phpfreaks.com/topic/196529-php-in-the-head-section/ Share on other sites More sharing options...
sKunKbad Posted March 25, 2010 Share Posted March 25, 2010 What do you get when you var_dump( $arb) ? Quote Link to comment https://forums.phpfreaks.com/topic/196529-php-in-the-head-section/#findComment-1031871 Share on other sites More sharing options...
jmajeremy Posted March 25, 2010 Share Posted March 25, 2010 There's no obvious reason why it shouldn't work. Syntax is all correct. The only thing that it could be is when you set the variable. Are you sure it's not $_POST['arb']? And when it's sent from the form, are you sure it's being transmitted properly? Quote Link to comment https://forums.phpfreaks.com/topic/196529-php-in-the-head-section/#findComment-1031932 Share on other sites More sharing options...
ianco Posted March 26, 2010 Author Share Posted March 26, 2010 The rest of the php in the page is <!-- @[a-zA-Z0-9]{6} $arb = $_POST["arb"]; <?php $num = $_POST["num"]; $jou = $_POST["jou"]; if(preg_match("/^b[a-zA-Z0-9]{7}$/",$num)) { global $arb; $arb = "b9"; } else { global $arb; $arb = "c0"; } ?> --> var_dump doesnt do anything either (nothing that i want anyway) and nor does $_POST['arb'] Here is the form <form action="http://iancoates.uuuq.com/development/newy.php" method="post"> Journal: <input type="text" name="jou" /><br> Number: <input type="text" name="num" /><br> <input type="submit" /> </form> nothing unusual here ANy other suggestions? thanks Quote Link to comment https://forums.phpfreaks.com/topic/196529-php-in-the-head-section/#findComment-1032200 Share on other sites More sharing options...
ianco Posted March 26, 2010 Author Share Posted March 26, 2010 oops this code <?php $num = $_POST["num"]; $jou = $_POST["jou"]; if(preg_match("/^b[a-zA-Z0-9]{7}$/",$num)) { global $arb; $arb = "b9"; } else { global $arb; $arb = "c0"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/196529-php-in-the-head-section/#findComment-1032229 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.