Click to See Complete Forum and Search --> : Help!
Is it possible to have a textbox and a submit button that when the user puts info in it and hits the submit button it sends the contents of the textbox to an iframe on the same page so its basicly posting the contents of the textbox to another page that is veiwed through the iframe on the same page. Please help.
Yes, it's possible. I haven't done it (yet) with an IFrame, but I have done it with frames. I'll post the code in a few minutes. I've got to go get something done...
Here's an example: http://geocities.com/god_loves_07/frame3.html
I would need it so it would post it to an html page because that is what the iframe would be and would it also be possible for it to like save it to the html page in the iframe so it would stay there and the user could post multipul things there like a list one after another and when someone else comes to the page they would see it to because it would have written it to the html iframe.
dabush
03-25-2003, 09:53 PM
hmm. i named and id'ed an iframe in a new html document. document.getElementById('iframename') returned null. and, its also not included in the frames array. i dont think its possible. in Jona's example, they are writing to a separate frame, not an iframe.
I will work on this on another computer. Please wait. I will most likely have some kind of solution by tomorrow, even if it is that it cannot be done, I will have an answer of some kind.
I'll wait to see your response. :D
Here is how I'd do this:
<html>
<head>
<script language="javascript" type="text/javascript">
function testing(frm)
{
val = frm.mytext.value;
frm.mytext.value = "";
top.myiframe.document.getElementById("mydiv").innerHTML += val+"<br>";
}
</script>
</head>
<body>
<iframe name="myiframe" src="iframe.htm"></iframe><br>
<form name="myform" onsubmit="testing(this); return false;">
<input type="text" name="mytext">
<input type="submit" value="submit">
</form>
</body>
</html>
And your the code for iframe.htm
<html>
<head>
</head>
<body>
<div id="mydiv"></div>
</body>
</html>
This won't of course save what people type in for other to see...that will require server side scripting.
O.k. say I was on this page and 'bob' was on this same page at the same time. If I entered somthing and hit submit would 'bob' be able to see it too? If he wouldn't see it using the script you suggested is there any ways you can do this so 'bob' could see my message? I dont neccicarily need to save the info to the iframe just as long as other people will be able to see it when there on the page at the same time so that means that only people who were there when i typed it would see the message.
I would also accept ansers from anybody else!
As I said, you will need to use server side code. You will need to save to a file, and force a refresh every so often, to keep the page up to date. I believe that users will notice a "flash" so to speak, every time the browser refreshes.
Nedals
03-26-2003, 10:33 AM
If I entered somthing and hit submit would 'bob' be able to see it too? If he wouldn't see it using the script you suggested is there any ways you can do this so 'bob' could see my message?What you are describing here is a 'chat room' using an iframe and, as 'pyro' stated, you will need a server-side script. If you are up to it there are several free scripts offered around the Net.
Could this be possible to do in php and I would also want it to clear the ifram file every so often. Does anybody have any suggestions?
Yes, it would be possible in PHP, but as I stated, users will notice a "flash" everytime the screen is refreshed (and, you'd have to do this quite often [once every one or two seconds] to keep the information current). Thus, building a chat program isn't going to be an easy task... ;)
Could you set it so the iframe refreshes for everybody on that same page at the same time only when somebody presses submit with text in the field so a user would put in text and hit submit and the iframe would refresh for everybody at the same time when he hits submit?
I will also take anybody elses response. Thankz. :D
Nedals
03-26-2003, 02:15 PM
I've thought about adding a simple chat capability to my site. Here's my initial thinking. It's not working yet but might be something you could work on. If there is a reasonable amount of interest, I can post periodic updates as I build this. I will be using CGI/Perl. I don't know PHP. (but someday I'll learn it.)
http://www.fulspec.com/test/simplechat.html
If the interest is there, I will start a new thread in the CGI forum. 'A simple chat script'
Scriptage
03-26-2003, 02:32 PM
Java is the best language to use for chat rooms.
If you use Server side programming you will get flashes as pyro said when the page is refreshed (unless you use server push which is only supported by netscape). With Java there are no flashes. There are plenty of free java chat applets out there....try javaboutique.com or search on google.
Regards
Nedals-
It sounds like what you are making is a shoutbox, as it basically is just to leave comments. Is this correct? Anyway, I had thought about making a PHP chat, but when I saw the irritation of the screen refreshes, I decided to just go pick up a Java chat.
As Scriptage said, Java is really the ideal language to write chat programs in...
Stupid me... I forgot that IFrames could be accessed the same way frames are...
AdamBrill
03-26-2003, 05:54 PM
mjdimick - Try taking a look at http://www.code4ever.com/chat. It is a bit primitive, but considering that I put it together in a couple hours it's not too bad. ;) Would something along those lines work for you?
It seems that the page refreshes a bunch and then after you type about two messages the top fram disapears and sending messages stop working for some reason.
AdamBrill
03-26-2003, 06:22 PM
That was probably because I was in the middle of modifying it... :D Sorry... :p I'll leave it alone for a while now so you can go check it out... ;) It will refresh itself since that is how it works... Let me know what you think. :)
Does it use just java script or what does it use and also is it possible to use iframes with this script instead of frames?
Nedals
03-26-2003, 06:25 PM
pyro..
It sounds like what you are making is a shoutbox, as it basically is just to leave comments
I dunno! Is that what you call it :)
I think of it as a simple chat without the auto refresh. This will hopfully get rid of annoying flashing. I propose to leave the last 10 posts (or there abouts) and, yes, you would just leave comments. But isn't that what a chat script does?
AdamBrill,
I took a quick look at your page and, without someone to chat with, it's a little difficult to see how it feels. I did not like the refresh (timeout), which is what I propose to eliminate using the manual refresh.
Anyway, I can always use the practice. :D
I liked your idea but i only can use php and mysql with my web server and you said you were gonna use cgi and can someone anser my question above?
Nedals
03-26-2003, 06:37 PM
mjdimick,
If you're asking about adams script. It could be modified to use iframes and it uses PHP. Maybe you could get adam to post his PHP script so I can steal it. :D
It seems as if adam has left the forum I went to the main page and it said hes not logged in.
I love your script nedals its exactaly what I was looking for I hope you get it to work soon. :D
Nedals
03-26-2003, 07:21 PM
If your provider allows PHP and mySQL, I'm supprised that they don't also allow CGI/Perl.
my hosting is a free host so I guess thats not bad for free but yeah only php,mysql unfouturnatly.
AdamBrill
03-26-2003, 10:21 PM
Originally posted by mjdimick
It seems as if adam has left the forum I went to the main page and it said hes not logged in. Adam is back! :D LOL Check it out now... It's getting better... ;) Now you can use smilies!!! :p It says the time, too. It is Eastern Time, just so you know. As for stealing the code, I don't think it counts as stealing if I give it too you... :rolleyes: :p But, here it is... LOL ;)
AdamBrill
03-26-2003, 10:22 PM
Oh, by the way, you have to CHMod topPage.htm to have writing access, but beside that it should work just to upload it. ;)
Cool thanks alot I'll try this as soon as possible and I'll get back to you to let you know how it is. Thanks again. :D
I want to put the page that the messages get posted to in a iframe so its more compact and can go on other pages and not need its own. Do you know how to make it so its in an iframe?
Does anybody have an anser for the question above? Thankz for any help. :D
I almost have it but I want help still.
please look at this thred and give me some help. Thankz. :D
AdamBrill
03-27-2003, 04:44 PM
nedals - I beat you making a Perl version of it. :p LOL You can check it out here: www.code4ever.com/CGIchat. If you want the source, just let me know... :D
Nedals
03-27-2003, 07:42 PM
Was there a race? I missed it. LOL. Actually I had a Perl version of mine done last night but didn't post it. I still haven't because when I did some texting on the early version on IE5.0 (at work) it would not refresh the iframe. I got it all working on IE6 (at home) and I didn't go in today, so didn't get a chance to test the latest version. (What a bunch of... :D).
Sure I'd like to see the code. I also want to get a good look at your PHP code that I've already downloaded. Would you like mine (Perl that is!).
A little later....
I looked at your PHP code and I understand this
$filename="topPage.htm"; :)
As to the rest, I have no idea how it all works? There just doesn't seem to be enough code. :confused:
Ah well! Time to learn a little PHP, if that's all it takes.
Nedals
03-28-2003, 01:58 AM
Finally, the finish line. Isn't it? :)
Got to the way I wanted it in IE6. It may do strange things in IE5. I'll test tomorrow.
www.fulspec.com/test/simplechat.html
Hey nedals I love your script it is exactally what I wanted so is it just javascript or did you use another language like cgi,php to make it work and could you post a link so I could download this script. Thankz. :D
Nedals
03-28-2003, 05:20 PM
Script is CGI/Perl which you said you can't use! And I don't know PHP, YET!!. Maybe some time in the future I'll write a PHP version and contact you by PM.
Well if you could give me the files needed i bet I could find somebody who could convert your cgi and perl to php so could you possibly give me the files. You can also contact me by yahoo! messenger and my handle is 'mjdimick'. Thankz. :D
Nedals
03-28-2003, 07:42 PM
Good luck! :)
AdamBrill
03-29-2003, 10:32 AM
nedals - Sorry I wasn't on here for a while, but my internet went down and left me hanging. :rolleyes: Anyway, here is my chat(since you asked for it). There is only one thing, I must warn you that I am not a pro at perl so the coding might not be the best. :D You'll probably take one look and burst out laughing... :p
Nedals
03-29-2003, 06:48 PM
Code looks fine with a couple of exception.
Dump all the form read stuff and use CGI.pm
use strict; # All variables declared with 'my'. Scope of variable is limited to block in which declared.
use CGI;
my $q = new CGI; # Jeffmott does this a different way
# Then all you need is
my $user = $q->param('theName');
my $message = $q->param('send');
Thanks for the look-see and did you know this is a javascript forum?? :D
AdamBrill
03-29-2003, 10:49 PM
Thanks for the better way of doing it... The book that I had only told me how to do it like that. :mad: It makes me mad to think of how long it took me to get it to work like that when it was so easy... Oh well. ;) Thanks for telling me. :D It doesn't supprise me, though, since it is one of the only things I have ever made in Perl. ;) Cheers!
Hey Nedals,
Hello nedals could you post a new atachment with the updated chat files so I could get them because I noticed you updated your chat files. Thanks. :D
Nedals,
Did you ever figure out how to make this chat work with just php?
I would also accept answers from anybody else who thinks they can help me. Thanks. :D
Well I see you have it calling a cgi script but I also see the script calling a php script so I can't figure out if you figured out how to make it work with php. Sorry about the many post in a row but no one has replyed for like two days now. Well if you see this please let me know what is going on with the script and also I still need you to post the updated chat files please. Thanks alot. :D
I see what you did but I still need the files please I left a message on your chat page. Please post updated files so I can download them. Thanks. :D
Nedals
04-07-2003, 06:37 PM
Thanks to AdamBrill, I was able to adapt his PHP script to work with the 'simple chat', remember this is my first PHP script so there may be some problems. One thing that is not being done is file locking during update (because I don't how in PHP ), which may cause probems.
Thank you so much. I have it working but not on my site yet. I was also wundering if it was possible to impliment a smile face thing so the user could post smiles with their message. Kinda like Yahoo!. I know it is possible to just insert the link to the image in the textbox and then hit submit but is it possible to have it so they type colon and bracket and it shows a smile face like you can in yahoo. If you know could you post a script that would allow me to do this? Thanks alot for your help. This forum also uses the same idea like you type what the smile face looks like and it shows that smile. :D
Nedals
04-07-2003, 07:32 PM
Michael Dimick
mjdimick@yahoo.com
http://dandy.coolfreepages.com/
Web Developer
I don't know how to do it in PHP (yet!) but here's how I would go about it. You're a web developer so you will want to learn! :)
First you will need the 'smilies' images and the 'char-combos' you want to use. Now you need to replace (PHP method) the 'char-combos' with an image tag <img src=sml1.gif> in each new post.
AdamBrill's PHP post shows the technique. (end of page 2 of this thread)
And that should do it.
If you get in trouble, post the code you have developed so far.
Well I guess I could give it a try but it might take me a while. Also if anybody else wants to give me some help about my question above I will gladly accept anwsers from anybody. :)
Here's how you are going to want to do it. This is assumbing that $chattext is the text that is being submitted to the chat:
$chattext = str_replace (array(":)",":-)"),"<img src=\"images/icon_happy.gif\" border=0>",$chattext);
Notice how I used an array. This is so you can check for mulitple smilies at once. ie, :p, :P, :-p, and :-P all with one replace.
So how would I impliment this on the page. Would I have to then convert the chat page to php?
I haven't looked at AdamBrill's code, but I'm sure the page is submitting the text to the .php page. The text will then get put in some variable. You will do the str_replace on that. So, you only need to edit the main chat engine script.
Nedals
04-07-2003, 08:05 PM
Hey, mjdimick.. We're doing all this for you. :D
In my code you will see this line..
$message = $_POST['message'];
Insert pyro's code in after it (modified as shown)
$message = str_replace (array(":)",":-)"),"<img src=\"images/icon_happy.gif\" border=0>",$message);
pyro...
Correct me if I'm wrong, but your code will replace any of the char-sets shown with the same smilie.
EDIT: How did you keep the smilie from appearing in your post?
mjdimick..
look a AdamBrill's code to see how to add other smilies.
Actually I'm talking about 'nedals' chat not 'AdamBrills'. :D
Are you talking about the php file or one of the html files? I think I found what your talking about in the php file but I wanted to be sure. :D
Originally posted by nedals
pyro...
Correct me if I'm wrong, but your code will replace any of the char-sets shown with the same smilie.
EDIT: How did you keep the smilie from appearing in your post?Ok, first of all, yes, it will replace all of them with the same smilie. This is useful in situation such as :p, :P, :-p, and :-P where you would want them all to equal a tounge smilie. If you don't use an array, you will need 4 str_replace statments.
Second, in Options (right underneath the text area you type your replies in) there is an option to disable smilies...
Originally posted by mjdimick
Actually I'm talking about 'nedals' chat not 'AdamBrills'.Either way, the same applies...
Nedals
04-07-2003, 08:17 PM
Are you talking about the php file or one of the html files? I think I found what your talking about in the php file but I wanted to be sure.
The PHP file.
Thanks pyro :)
Can you do something like this...
$chattext = str_replace (array(":)",":-)"),"img1,img2",$chattext);
Could you possibly make this work on your site so I could see if it works because 1.My server is down and can't upload 2.I tryed it on my computer and when I type :)+Message it delets all the messages on the chat.
I just noticed that it actually toattally screws up the whole thing when I put that piece of code in. So could you give it a go?
Nedals
04-07-2003, 08:33 PM
http://www.fulspec.com/test/chatterbox.html
only ;) works
And I havn't had my tea yet. Later!!
Originally posted by nedals
Can you do something like this...
$chattext = str_replace (array(":)",":-)"),"img1,img2",$chattext); Well, you can with preg_replace, using regular expressions. Take a look at this page: http://www.php.net/manual/en/function.preg-replace.php
Please post your files again so I can see what I did Wrong. Please post all including images. :D
Nedals
04-07-2003, 09:34 PM
Pyro..
Took a look at that page and it looks perfect. Thanks. Do you understand the meaning of this...
....the keys are processed in the order they appear in the array. This is not necessarily the same as the numerical index order.
In the example they give, the replacement array is acted on in reverse. I can see how the problem is solved and how the function works, but this is wierd!! :)
mjdimick..
To get the images, do what I did. right click the smilies on this board and save-as. As to the script, post the section of code you used that messed up the messages, and let's go through what you did. You are never going to learn by having people on the board solve your problems entirely.
Let me get the script and then I'll post it so just wait a bit! :D
Here is my php file. I know there is somthing wrong here.
<?PHP
$filename="chatter.html";
$fp=file($filename);
$x=0;
$data="";
while($fp[$x]){ $data .= $fp[$x]; $x++; }
// If messages exists, Limit the total number to 10.
if ($data) {
$dataSplit = split("<!--chatter-->",$data);
$msgSplit = split('<hr>',$dataSplit[1]); // Split into seperate messages
if (count($msgSplit) > 10) { $msgSplit = array_pop($msgSplit); }
}
// Get the textarea message, user and date and insert at the beginning of the array .
$date = date("g:ia, F j, Y"); // 5:16pm, March 10, 2001
$username = $_POST['username'];
$chattext = str_replace (array(":)",":-)"),"img1,img2",$chattext);
array_unshift ($msgSplit,"\n<b>".$username."</b> - ".$date."<br>".$message."\n");
$dataSplit[1] = join("<hr>",$msgSplit);
// Write back to the file with new messages
if (is_writable($filename)) {
if (!$fp = fopen($filename,"w")) { echo "Cannot open file ($filename)"; exit; }
fwrite($fp,$dataSplit[0]."<!--chatter-->");
fwrite($fp,$dataSplit[1]."<!--chatter-->");
fwrite($fp,$dataSplit[2]);
fclose($fp);
} else { echo "The $filename is not writable"; exit; }
// Refresh the message page (in iframe).
header("location:http://www.fulspec.com/test/chatter.html");
exit;
?>
Thanks for your help. I would also like it if you could click on the smiles on the page and they would automaticly be inserted into the textbox where you type. Kinda like how this forum does it. Thanks. :D
I will also accept answers from any body else who thinks they know how to help me. Thanks. :D
AdamBrill
04-08-2003, 07:16 AM
Here, try this:
<?PHP
$filename="chatter.html";
$fp=file($filename);
$x=0;
$data="";
while($fp[$x]){ $data .= $fp[$x]; $x++; }
// If messages exists, Limit the total number to 10.
if ($data) {
$dataSplit = split("<!--chatter-->",$data);
$msgSplit = split('<hr>',$dataSplit[1]); // Split into seperate messages
if (count($msgSplit) > 10) { $msgSplit = array_pop($msgSplit); }
}
// Get the textarea message, user and date and insert at the beginning of the array .
$date = date("g:ia, F j, Y"); // 5:16pm, March 10, 2001
$username = $_POST['username'];
$chattext = str_replace (array(":-)"),"<img src=\"images/smilies/smile.gif\">",$chattext);
array_unshift ($msgSplit,"\n<b>".$username."</b> - ".$date."<br>".$message."\n");
$dataSplit[1] = join("<hr>",$msgSplit);
// Write back to the file with new messages
if (is_writable($filename)) {
if (!$fp = fopen($filename,"w")) { echo "Cannot open file ($filename)"; exit; }
fwrite($fp,$dataSplit[0]."<!--chatter-->");
fwrite($fp,$dataSplit[1]."<!--chatter-->");
fwrite($fp,$dataSplit[2]);
fclose($fp);
} else { echo "The $filename is not writable"; exit; }
// Refresh the message page (in iframe).
header("location:http://www.fulspec.com/test/chatter.html");
exit;
?>You had the replace parts in the wrong order... ;) I think it should work now...
AdamBrill
04-08-2003, 07:36 AM
Another note about it... You are doing it to $chattext, but $chattext isn't even a variable in there. You have to do it to the variable with the text they are adding... :)
Here is my updated script:
<?PHP
$filename="chatter.html";
$fp=file($filename);
$x=0;
$data="";
while($fp[$x]){ $data .= $fp[$x]; $x++; }
// If messages exists, Limit the total number to 10.
if ($data) {
$dataSplit = split("<!--chatter-->",$data);
$msgSplit = split('<hr>',$dataSplit[1]); // Split into seperate messages
if (count($msgSplit) > 10) { $msgSplit = array_pop($msgSplit); }
}
// Get the textarea message, user and date and insert at the beginning of the array .
$date = date("g:ia, F j, Y"); // 5:16pm, March 10, 2001
$username = $_POST['username'];
$message = str_replace (array(":-)"),"<img src=\"img1.gif\">",$message);
array_unshift ($msgSplit,"\n<b>".$username."</b> - ".$date."<br>".$message."\n");
$dataSplit[1] = join("<hr>",$msgSplit);
// Write back to the file with new messages
if (is_writable($filename)) {
if (!$fp = fopen($filename,"w")) { echo "Cannot open file ($filename)"; exit; }
fwrite($fp,$dataSplit[0]."<!--chatter-->");
fwrite($fp,$dataSplit[1]."<!--chatter-->");
fwrite($fp,$dataSplit[2]);
fclose($fp);
} else { echo "The $filename is not writable"; exit; }
// Refresh the message page (in iframe).
header("location:<a href="chatter.html" target="_blank">chatter.html</a>");
exit;
?>
It now displays this message in the iframe when I type somehting and hit send:
Parse error: parse error, unexpected T_STRING in C:\Program Files\Abyss Web Server\htdocs\chat\chatpost.php on line 28
So I need some help here. Thanks. :D
Hey Nedals,
I also found what I think is a bug. Its the date/time stamp on your chat page whenever you post a message it post the time with it but I don't know if its your script or what but I see that it puts the same date for every post and not the date they where posted. For example if todays date was 04/08/03 it would display that date for all post but the time peice is working it post the correct time. Thought you should know. :D
So any help would be greatly appriciated. Thanks. :D
AdamBrill
04-08-2003, 10:58 AM
Change the header to this:
header("location:chatter.html");
then it should work... :D
Now it shows this in the iframe when I type somthing and hit send:
Notice: Undefined offset: 20 in C:\Program Files\Abyss Web Server\htdocs\chat\chatpost.php on line 6
Notice: Undefined variable: message in C:\Program Files\Abyss Web Server\htdocs\chat\chatpost.php on line 16
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Abyss Web Server\htdocs\chat\chatpost.php:6) in C:\Program Files\Abyss Web Server\htdocs\chat\chatpost.php on line 28
Wierd! :eek:
Well pyro tryed helping me over Yahoo! messenger but we still could not figure it out so I'll wait for nedals response. :D
Originally posted by mjdimick
Well pyro tryed helping me over Yahoo! messenger but we still could not figure it out The reason that I "couldn't" help is because I didn't want to do it for you. I only want to help you figure it out yourself... ;)
Yeah I hear ya!
Well I think nedals is on now so maybe he can help me out now. :)
This is my current state of my php file:
<?PHP
$filename="chatter.html";
$fp=file($filename);
$x=0;
$data="";
while($fp[$x]){ $data .= $fp[$x]; $x++; }
// If messages exists, Limit the total number to 10.
if ($data) {
$dataSplit = split("<!--chatter-->",$data);
$msgSplit = split('<hr>',$dataSplit[1]); // Split into seperate messages
if (count($msgSplit) > 10) { $msgSplit = array_pop($msgSplit); }
}
// Get the textarea message, user and date and insert at the beginning of the array .
$date = date("g:ia, F j, Y"); // 5:16pm, March 10, 2001
$username = $_POST['username'];
$message = $_POST['message'];
$message = str_replace (array(": )",":- )"),"<img src=\"smilie.gif\" border=0>",$message);
array_unshift ($msgSplit,"\n<b>".$username."</b> - ".$date."<br>".$message."\n");
$dataSplit[1] = join("<hr>",$msgSplit);
// Write back to the file with new messages
if (is_writable($filename)) {
if (!$fp = fopen($filename,"w")) { echo "Cannot open file ($filename)"; exit; }
fwrite($fp,$dataSplit[0]."<!--chatter-->");
fwrite($fp,$dataSplit[1]."<!--chatter-->");
fwrite($fp,$dataSplit[2]);
fclose($fp);
} else { echo "The $filename is not writable"; exit; }
// Refresh the message page (in iframe).
header("location:chatter.html");
exit;
?>
So you can see where I messed up at.
Nedals
04-08-2003, 01:29 PM
The problem lies in this line of code...
$message = str_replace (array(": )",":- )"),"<img src=\"smilie.gif\" border=0>",$message);
Let's start simple and get a working smilie. Use this line instead of the one above. ( NO ADDED SPACES! )
$message = str_replace(":)","<img src=\"smilie.gif\">", $message);
You understand that this ":)" is replaced by "<img src=\"smilie.gif\">" in the $message string and you know why the \ is there?
Your image name is "smilie.gif" and is in the same directory as you php script. Right?
If I'm being overly simplistic, please say so.
I did what you said and this is the error it displays in the iframe when I try to send a message:
Notice: Undefined offset: 28 in C:\Program Files\Abyss Web Server\htdocs\chat\chatpost.php on line 6
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Abyss Web Server\htdocs\chat\chatpost.php:6) in C:\Program Files\Abyss Web Server\htdocs\chat\chatpost.php on line 29
Its somthing about the header already being sent or somthing. :confused:
Nedals
04-08-2003, 02:01 PM
You got me!
Your code looks fine and, not being proficient in PHP, I really can't help. You said you had it working without the smilies! I suggest you go back to that version, make sure it's working and then add back in the smilie code.
I agree with nedals... You should just start over with nedals code and add in the smilies. Second, if you are still having problems, the "cannot send header" error means that the script is trying to echo text to the screen (probably either the 'cannot open file' or 'file is not writeable' message) Try commenting out the header redirect and run the script and see which one...
Nedals
04-08-2003, 02:25 PM
I also found what I think is a bug. Its the date/time stamp on your chat page whenever you post a message it post the time with it but I don't know if its your script or what but I see that it puts the same date for every post and not the date they where posted. For example if todays date was 04/08/03 it would display that date for all post but the time peice is working it post the correct time.
I've reset the messages and it seems to work correctly for me. Could I ask that a couple of people leave a message to make sure the old dates don't change. :)
http://www.fulspec.com/test/chatterbox.html
I just left a message and the dates/times still look okay... ;)
I went back to the origional version and It's not working either. :(
Nedals
04-08-2003, 03:51 PM
Did you change directories, edit the HTML files, or some such?
My suggestion!...
Delete everthing you have on this script, (all HTML and PHP) and go back to page 4 of this post, download the zip, and set it up as you did before. You should then have a working script, as before, and we can modify from there.
Don't loose heart...
Programming is 1/3 planning, 1/3 coding, and 1/3 debugging
Hey nedals... You may also want to point out to mjdimick which file needs to be chmoded... I'm sure at least one of them do...
Nedals
04-08-2003, 04:16 PM
Good thought!
Pyro, since I have you close by. You had mentioned earlier that the error messages that mjdimick was getting may be caused by trying to echo the error messages. I was looking at my code and I do not send any header data prior to the error message echo. Is there a cleaver way to handle that problem, like creating a subroutine of some sort. Any help appreciated.
I was thinking... even you, the moderator, is participating in this NON-JAVASCRIPT thread. LOL
mjdimick,
The 'chatter.html' file need to be writeable, CHMOD 766
I think I found out whats wrong. The script is linking to your server instead of mine. Also I noticed it works fine when i type in my username and then type a message but then when I try to type another message it some how links back to my file which then clears all the fields and the messages i typed disapear all except the ones that were in the file when you gave it to me. So it looks like there is a linking problem so some of the time it writes to your file and other times it just goes to my file and dosn't write anything.
Nedals
04-08-2003, 04:26 PM
You will find this line in the chatter.html page
<form name="msgfrm" action="http://www.fulspec.com/test/chatpost.php" method="post">
......change it to your page (something like this)
<form name="msgfrm" action="chatpost.php" method="post">
AND the last line of the .PHP script
header("location:http://www.fulspec.com/test/chatter.html");
......change to
header("location:chatter.html");
Originally posted by nedals
You had mentioned earlier that the error messages that mjdimick was getting may be caused by trying to echo the error messages. I was looking at my code and I do not send any header data prior to the error message echo.I'm guessing that he was getting the error message because one of the two echo statements were firing. Either the file cannot be opened, or the file was not writeable. This would normally have just echoed your error message to the screen, but the header redirect later on was firing off an error instead.
Originally posted by nedals
I was thinking... even you, the moderator, is participating in this NON-JAVASCRIPT thread. LOLThat's because we don't have a PHP section. Trust me... I've been trying to get it added. ;)
Originally posted by nedals
......change to
header("location:chatter.html");If I can be picky...
When using a header("Location:") you should use the full address like this: header("Location:http://www.yourdomain.com/yourdir/yourfile.ext"); :p
EDIT: I have heard of the absolute URI not working, while relative does. Not sure why, but that's not how the specs say to do is: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30
I get this error when I make those changes nedals:
Notice: Undefined offset: 20 in C:\Program Files\Abyss Web Server\htdocs\chat\chatpost.php on line 6
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Abyss Web Server\htdocs\chat\chatpost.php:6) in C:\Program Files\Abyss Web Server\htdocs\chat\chatpost.php on line 28
I think its the same from the one before. Ohh man this is so frusterating.
Of course 'Nedals' could always just post his php file so I could compair mine and his so I could see what was wrong. :D
Nedals
04-08-2003, 05:34 PM
Here's the original version with a couple of changes (taking out links back to my site). It should work for you unchanged.
EDIT:
If I can be picky...
When using a header("Location:") you should use the full address like this: header("Location:http://www.yourdomain.com/yourdir/yourfile.ext"); Any time :)
The reason I took it out was that the script is being run locally (not posted)
My files match yours that you posted but still I see the same error.
Originally posted by nedals
The 'chatter.html' file need to be writeable, CHMOD 766 Did you do that?
Nedals
04-08-2003, 06:25 PM
My files match yours that you posted but still I see the same error.
Did you compare the files OR did you, as suggested, delete ALL your files and start again. I can't tell you the number of times I've compared files only to find, after a couple of hours of debugging, some stupid mistake that I missed. If you're SURE there are no differences, I would take a step back and check some VERY BASIC, hello world, PHP script.
I deleted all files and replaced them with the ones you posted.
Nedals
04-08-2003, 08:42 PM
Hmmmm!
You've reach the limit of my PHP knowledge. The only thing I can suggest it to comment out lines of code ( // ) and add echo statements until you get some return. Then uncomment line by line looking for the offending code.
I got it working on my account on your server at:
http://kd7pyo.infinitypages.com/chatter/chatterbox.html
It was because my free server does not support the method the chat room uses.
----------------------------------------------------------------------
Hey nedals is there a way to make it so the messages display down from the top instead of from the bottom up so it works more like a chat room. Also I would like the smiles to be on my chatterbox.html page and when you click on one it automaticly inserts the : ) in the text field. Kinda like this forum does it. Thank you so much for your help so far. :D
Nedals
04-09-2003, 01:11 AM
How did you get it working. I didn't understand the server issue. EDIT: Forget that. I just re-read your post
Hey nedals is there a way to make it so the messages display down from the top instead of from the bottom up so it works more like a chat room.They already do! :confused:
Also I would like the smiles to be on my chatterbox.html page and when you click on one it automaticly inserts the : ) in the text field. Kinda like this forum does it.I think it's time to close out this thread.
Why don't you have a go at that yourself and start a new thread (with some posted code) if you get in trouble. Here's a tip to get you started. The HTML and the javscript code is all here on this board. (Use right click and look around) ;)
Thank you to everyone who helped me get this far. Now I just have to figure out the smilies part. Thank you guys so much. :D