Jump to content

passing a variable in my chat script


A2xA

Recommended Posts

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

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.

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; ?>" />

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.