A2xA Posted September 19, 2008 Share Posted September 19, 2008 In the script I have two files the hub.php file and the chat.php file. The hub.php file has the form and style where the chat.php has the code. In the chat.php file it creates a text file. I need the variable from the hub.php page passed to the chat.php page for the name of it. In the hub.php page I've got.. <?php $hubid = $_GET['hubid']; //Some Code ?> <script language="JavaScript" type="text/javascript" src="./chat.php?hubid=<?=$hubid?>"> </script> In the second chat.php page I've got.. <?php $hubid = $_GET['hubid']; $hubid2 = $hubid; // Path to the text files holding the chat window content $fn = $hubid2.txt; ?> This is not working and I was wondering how to pass the variable. If someone could help I would greatly appreciate it. Link to comment https://forums.phpfreaks.com/topic/125016-passing-a-variable-in-my-chat-script/ Share on other sites More sharing options...
JasonLewis Posted September 20, 2008 Share Posted September 20, 2008 Why are you trying to include a text/javascript file that is of a .php extension? Link to comment https://forums.phpfreaks.com/topic/125016-passing-a-variable-in-my-chat-script/#findComment-646072 Share on other sites More sharing options...
A2xA Posted September 20, 2008 Author Share Posted September 20, 2008 It's the chat.php page that has all of the javascript functions for the chat script. Here's the whole form that is sending info to the chat.php page. <div id="chat">Connecting...</div> <input id="message" type="text" size="53" maxlength="100" onkeyup="keyup(event);" /> <input type="button" value="Submit" onclick="chat_write();" /><br /> <script language="JavaScript" type="text/javascript" src="./chat.php?hubid=<?php echo $hubid ?>"> All i need in the chat.php page is the variable passed from this page. Link to comment https://forums.phpfreaks.com/topic/125016-passing-a-variable-in-my-chat-script/#findComment-646123 Share on other sites More sharing options...
xtopolis Posted September 20, 2008 Share Posted September 20, 2008 place it in a session variable? hub.php <?php session_start(); $_SESSION['hubid'] = $_GET['hubid']; //Some Code ?> chat.php <?php session_start(); $hubid = $_SESSION['hubid']; $hubid2 = $hubid; // Path to the text files holding the chat window content $fn = $hubid2.txt; ?> or you can post/get it in a hidden form <input type="hidden" value="<?php echo $hubid; ?>" /> Link to comment https://forums.phpfreaks.com/topic/125016-passing-a-variable-in-my-chat-script/#findComment-646132 Share on other sites More sharing options...
A2xA Posted September 20, 2008 Author Share Posted September 20, 2008 the session worked perfectly thanks a lot! Link to comment https://forums.phpfreaks.com/topic/125016-passing-a-variable-in-my-chat-script/#findComment-646171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.