Log in

View Full Version : djr33's php message board



benslayton
05-26-2006, 08:30 PM
Twey i'm having a problem with your message board.

Try it out...
http://gospelwebs.com/Documents/index.php

when it gets to sent.php it actualy shows the code?
Please help Anyone?:confused: :confused: :confused:

benslayton
05-26-2006, 08:31 PM
forgot to mention login info:

member1
password1

Twey
05-26-2006, 08:45 PM
Your server doesn't support PHP.

My message board? I've never written a message board.

benslayton
05-26-2006, 08:54 PM
my bad i mean the djr33.

If it doesn't support it then why does, add.php and index.php work?

benslayton
05-26-2006, 09:06 PM
Try the link again I found a free php host.

Twey
05-26-2006, 10:00 PM
Nope. Neither work, for me.

benslayton
05-26-2006, 10:12 PM
well, do you know a simple script then just to leave messages. That is not php.

benslayton
05-26-2006, 10:13 PM
maybe like a blog that only I select the users to post?

Twey
05-26-2006, 10:16 PM
You cannot store any sort of data between multiple clients without a server-side language.

benslayton
05-26-2006, 10:19 PM
I have a free one then what.

djr33
05-26-2006, 10:40 PM
Haha, my message board.... :D
I suppose... more of just comments, though.

You need to have a storage system for the data.

If you have a free site, wonderful. Enjoy. You get what you pay for, though, generally.

find a better one, or find, really, like $2 each month to pay for something.


You can use cookies without server side stuff, but that is only for one user.. you're pretty much stuck.

benslayton
05-26-2006, 10:43 PM
Ok I got it to work Here:
http://benslayton.110mb.com/index.php
But the comments aren't showing up.

djr33
05-26-2006, 10:48 PM
The php source was changed and the name of the text document now doesn't match the one being created.

OR there's an error in the php code because of some lack of functionality on your server. For example, there may be a restriction against modifying files with php.
One of my hosting accounts doesn't allow php to send emails. Weird, but up to the host, I suppose.

Since you can't view php source except through access to the server, I can't know what's wrong.

Not really sure what to say...


Would you duplicate all three files on your server and rename them ".phps" so the source can be viewed?
(index.php>index.phps)
But leave the originals too... so you can fix them when we figure out what's wrong.

benslayton
05-26-2006, 10:49 PM
The codes are directly copied and pasted from the original fourm.

benslayton
05-26-2006, 10:51 PM
Index.php

<html>
<head>
<title>Comment Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center">
<p><font size="+1">Comments Demo:</font></p>
<table width="80%" border="1" cellspacing="0" cellpadding="5">
<tr>
<td align="left">
<?php
if ($file = @file_get_contents("comments.phpdata")) {
echo $file."\n";
}
else {echo "Sorry, but no comments were found.";}
?>
</td>
</tr>
</table>
<p><a href="add.php">Add Comment</a></p>
</div>
</body>
</html>

Add.php

<html>
<head>
<title>Add Comment Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center">
<p><font size="+1">Add Comment Demo:</font></p>
<form name="form1" method="post" action="sent.php">
Name: <input name="name" type="text"> -- Email: <input name="email" type="text"><br>
<textarea name="comment" cols="60" rows="10"></textarea><br>
<input type="submit" value="submit"> - <input type="reset" value="reset">
</form>
<a href="index.php">Back</a>
</div>
</body>
</html>

sent.php

<?php
$filename = "comments.phpdata";
if ($name = stripslashes($_POST['comment'])) {
$comment = str_replace("<","&lt;",$comment); //security
$comment = str_replace(">", "&gt;", $comment); //security
if ($email = stripslashes($_POST['email'])) {
$email = str_replace("<","&lt;",$email); //security
$email = str_replace(">", "&gt;", $email); //security
$email = "<a href=\"mailto:".$email."\">".$email."</a>";
}
else {
$email = "(No Email supplied.)";
}
$name = stripslashes($_POST['name']);
$name = str_replace("<","&lt;",$name); //security
$name = str_replace(">", "&gt;", $name); //security
if (!$name) {
$name = "<i>Anonomous</i>";
}
$hr = "";
if (strlen(@file_get_contents($filename)) > 0) $hr = "\n<hr>";
$add = $hr."Posted by: <b>".$name."</b> -- ".$email."<br>".$comment;
$comments = @file_get_contents($filename).$add;
$file = @fopen($filename, "w+");
@fwrite($file, $comments);
@fclose($file);
$message = "Your comment was successfully added.<br>Redirecting to index.php";
}
else {
$message = "You either entered no data or it was entered incorrectly.<br>Redirecting to index.php";
}
?>
<html>
<head>
<title>Comment Added Demo</title>
<meta http-equiv="refresh" content="3;url=index.php">
</head>
<body>
<div align="center">
<p><font size="+1">Comment Added Demo:</font></p>
<?php echo $message; ?>
</div>
</body>
</html>

the free server I have used is specifically for php.

djr33
05-26-2006, 10:54 PM
No changes?

then there's a compatibility issue.

Hmm.... I'm not sure what's going wrong.

Make a new file, put it in that directory, called "test.php".
Add the following and upload:
<?php
echo php_version();
file_get_contents("index.php") or echo "problem with file_get_contents\n";
$file = fopen("index.php", "w+") or die("problem with fopen");
fclose($file);
echo "fopen ok";
?>

Just want to find what gives errors.. those are random guesses at problems... we'll see if they work. If they do, it's something else. It'll also check php version so we can see if there's an issue with a new/old version of php.

benslayton
05-26-2006, 10:57 PM
Here it is...test.php (http://benslayton.110mb.com/test.php)

It does nothing...

djr33
05-26-2006, 10:59 PM
er.... try this...


<?php
die("PHP WORKS");
?>
This host is screwed up.

(Paste everything in the code box, including the last line)

benslayton
05-26-2006, 11:03 PM
Ok done that.

It says "PHP Works".

djr33
05-26-2006, 11:04 PM
Umm.... no clue, then.

That just verifies that php functions, but the above code can't be blank... it would give errors if nothing else.

Try this:

<?php
phpinfo();
?>

EDIT: had php_info first... it's phpinfo... probably the same with phpversion above.

Try that code and also try:
<?php
echo phpversion();
file_get_contents("index.php") or echo "problem with file_get_contents\n";
$file = fopen("index.php", "w+") or die("problem with fopen");
fclose($file);
echo "fopen ok";
?>



by the way, gotta run... back later.

benslayton
05-26-2006, 11:06 PM
DOne that one It's blank.

http://benslayton.110mb.com/test.php

djr33
05-26-2006, 11:15 PM
Grr.

the phpinfo one?

the second one as well, I assume?


just do this then:
<?php
echo phpversion();
?>


If that doesn't work, then I have no clue what's going on.

Someone else may know.

Twey
05-26-2006, 11:29 PM
phpinfo() tends to get disabled even on paid hosts, for security reasons.
I think it's what you assumed originally: the host supports PHP, but just disables half the features.

benslayton
05-26-2006, 11:35 PM
Ok once agian.

It says "4.3.9"

http://benslayton.110mb.com/test.php

Do you know whats wrong?

Twey
05-26-2006, 11:40 PM
I stand by my earlier assessment.

benslayton
05-27-2006, 12:45 AM
what does that mean?

djr33
05-27-2006, 05:34 AM
php is enabled, but many of the features are disabled. The comment script won't work.

It is based on modifying a text file by adding the comments and getting the comments from that file. Both functions appear to be disabled as well as phpinfo which might tell us more... but... if it's disabled, it's disabled.

As such, you have one other option... a database. Unless they give you a database with the account (I really doubt a free host would, especially one with only half functional php), you can't save the data on the server.

Gotta find another way.

Actually, there are ways with php to log into an ftp account and modify/get files that way. However, I'd be surprised if that wasn't disabled as well.
If it isn't, you could log into your own account to modify stuff.... but... again, probably disasbled.

Really, you gotta choose either getting a real host or not doing some stuff... it's a choice, and there are no real ways around it.


EDIT: Note: 4.3.9 is the version, and that's just about what I'm using... maybe 4.3.7... can't remember. That means, obviously, that the versions aren't the issue... only a really new one (5+) or really old one (3-) would have huge differences like not doing the file commands, and i'm pretty sure even those use the commands. So.... yeah, just your host disabling for security. They don't want to give you access to their server aside from superfiscial access with simple commands like "echo" (display text), etc.

benslayton
05-27-2006, 06:18 AM
Ok I found a new free php host.

http://benslayton.awardspace.com/

it works, but how would I get the time anddate of the user's post.
*please see link.

djr33
05-27-2006, 09:55 PM
You do realize that the script is designed with basically no html to allow for easy integration with your design, right?
If nothing else, change the background and text color... there you go.

As for time and date.... that's fairly easy.

Just find this line:
$add = $hr."Posted by: <b>".$name."</b> -- ".$email."<br>".$comment;

And replace with:
$add = $hr."Posted by: <b>".$name."</b> -- ".$email." at ".time().date()."<br>".$comment;

That's gonna give you the code version of time/date, though.... just numbers representing a time.
I've never really understood the system.... look either up at php.net and it'll tell you what to use.... you put like "d:m:y" in the time() function and it'll show you that format.

Maybe Twey knows it well... I just haven't used it... confused me, and never interested me enough :p

I'll figure it out at some point, though.

benslayton
05-30-2006, 09:06 PM
the time is messing up. Take a look...
http://benslayton.awardspace.com/announce/index.php
post a message to. It does something funny...:)

djr33
05-31-2006, 12:49 AM
Yeah.... as I said... gotta look up date() or time() at php.net... i think date is the one you can customize with formatting.

that's a number of seconds since 1970.... so... it IS the time.. but just weird format.

Again, never had the need... so not sure what the "best" method of converting is.... but... there are just things you can put in the function.... look at php.net.

benslayton
06-01-2006, 04:07 PM
WYSIWYG Editor (http://www.dynamicdrive.com/dynamicindex16/openwysiwyg/index.htm)
Problematic page (http://benslayton.awardspace.com/encourage/index.php)
never mind about the time and date. looked at the site cant fiqure it out. But I added DD's WYSIWYG editor to it but that doesn't work.
----
Any Suggestions?:D

djr33
06-01-2006, 07:32 PM
Look at my thread at the top of the DD scripts forum. Some helpful hints about the wysiwyg editor there.

I'm not sure why it's not working... doesn't seme to fully load. Make sure the script is setup right.
When you submit, claims the data was entered incorrectly... not sure why. Can't really tell what's being sent on.

However, something to know is that I've disabled html on purpose in the posting options. You can reenable it by removing all of the lines with the comment "//security" at the end. Those disable html.



*Looking at the script you posted... not sure where this got changed.. maybe it was me in the first place... the line:
if ($name = stripslashes($_POST['comment'])) {
might need to be
if ($comments= stripslashes($_POST['comment'])) {
see if that helps.

jr_yeo
06-06-2006, 07:14 AM
Warning: Wrong parameter count for date() in /home/www/benslayton.awardspace.com/announce/sent.php on line 22

error message :)

djr33
06-06-2006, 09:28 PM
Hmm... the date() function wasn't set correctly. I can't view the source... I can look it up if you want, Ben. Just save a copy of your page as .txt, so I can view the source, or post it here.

mijabe
02-26-2007, 04:01 AM
I used the original code as well, and it didn't save the comments. I too am using awardspace. And when I tried the test.php I got this

Parse error: parse error, unexpected T_ECHO in /home/www/taftasb.awardspace.com/test.php on line 3

not sure what this means, seeing as how I'm just barely getting into php. hopefully you can help drj33 :) .

thetestingsite
02-26-2007, 04:12 AM
What this means:


Parse error: parse error, unexpected T_ECHO in /home/www/taftasb.awardspace.com/test.php on line 3

is that there is an error (perhaps a semicolon or bracket, or something else missing) on or around line 3 of your code. If you could post the code, I might be able to help.

mijabe
02-26-2007, 04:19 AM
By the way my site is @ http://taftasb.awardspace.com/page.php?id=4

mijabe
03-01-2007, 11:52 PM
The code in the page is:



<div align="center">
<h3>Bulletin Board:</h3><br>
<table width="80%" border="1" cellspacing="0" cellpadding="5">
<tr>
<td align="left">
<?php
if ($file = @file_get_contents("comments.phpdata")) {
echo $file."\n";
}
else {echo "Sorry, but no comments were found.";}
?>
</td>
</tr>
</table>
<p><a href="add.php">Post Bulletin</a></p>
</div>


with the other files comments.phpdata being


Posted by: <b>Mike</b> -- <a href="mailto:mozillamike@gmail.com">mozillamike@gmail.com</a><br>You can post anything you guys need here!
<hr>Posted by: <b>Mike</b> -- <a href="mailto:mozillamike@gmail.com">mozillamike@gmail.com</a><br>You can post anything here
<hr>Posted by: <b>thetestingsite</b> -- <a href="mailto:thetestingsite@mesquiteweb.com">thetestingsite@mesquiteweb.com</a><br>This is a test
<hr>Posted by: <b><i>Anonomous</i></b> -- (No Email supplied.)<br>tg
<hr>Posted by: <b>Mike</b> -- <a href="mailto:mozillamike@gmail.com">mozillamike@gmail.com</a><br>Post anything here.
<hr>Posted by: <b>Morissa&jenny...</b> -- (No Email supplied.)<br>we love asb!!! woot woot!!


with the add.php file:



<html>
<head>
<title>Add Comment Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center">
<p><font size="+1">Add Comment Demo:</font></p>
<form name="form1" method="post" action="sent.php">
Name: <input name="name" type="text"> -- Email: <input name="email" type="text"><br>
<textarea name="comment" cols="60" rows="10"></textarea><br>
<input type="submit" value="submit"> - <input type="reset" value="reset">
</form>
<a href="index.php">Back</a>
</div>
</body>
</html>


Evidentally people have used it to leave comments, my problem not is not the error, but that the comments do not appear on the page. I'm not sure what I'm doing wrong.

djr33
03-02-2007, 05:26 AM
Maybe it's a security setting.

Remove the @ from file_get_contents, and see if it gives an error.
the @ suppresses errors, so if there are no comments, nothing goes wrong.
But for testing purposes, it's good to know.

mijabe
03-04-2007, 06:02 PM
To my understanding, filegets' are a higher version of php, and possibly the server I'm using isn't updated for that. So my solution to the problem was to replace the fileget with a simple iframe, with the referenced source of comments.phpdata. It's working now @ here (http://taftasb.awardspace.com/page.php?id=4). Thanks for all your help!