Jump to content

passing the id= php variable on page load.


A2xA

Recommended Posts

I'm using a chat script I've made and the script has 2 seperate files the hub.php and the chat.php page.  The hub.php has the form and sends the info to the chat.php page where it adds to the chat. 

 

I need the hub.php to send a variable through javascript to the chat.php on page load and not on the form submit.

 

What I'm passing is the page id.. Example: http://mysite.com/hub.php?id=dkjhf3883

 

What could I add here?

 

I've got the id defined as $hubid in php.

 

<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"></script>

 

Thanks! if you need more of the script or don't understand feel free to ask.

Link to comment
Share on other sites

Is the chat.php file a PHP file that generates Javascript code?

 

You could try two things. Either

<script language="JavaScript" type="text/javascript" src="./chat.php?id=<?=$hubid?>"></script>

or something completely different, like an include. Like this (in place of the <script> line):

<script language="JavaScript" type="text/javascript">

<?php

include ("./chat.php?id=$hubid");

?>

</script>

 

Link to comment
Share on other sites

Yep.  Thanks a whole lot.

 

I tried those and on my chat.php page I put a

 

$hubid = $_GET['id'];

 

And the chat is generating a txt file so I'm putting this code

 

$fn = $hubid.txt;

 

It's just creating a .txt file.  I'm not sure how I grab the variable  :-\

 

 

Link to comment
Share on other sites

Guest
This topic is now 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.