GetDotted Domains

Viewing Thread:
"PHP Help"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Fri 16/05/03 at 16:03
Regular
Posts: 787
I'm fiddling about with my site at the moment and I want to be able to get a few little things working using PHP.

All I want is a basic script that allows information that is submitted through a text box to appear on the site.

When I say basic I mean basic as in monkey_man's old chat scripts he used to have on his site.

Anybody know of any basic tutorials that could explain how to do this?

I've got a feint idea of what to do, just not how to do it!

Thanks.
Fri 16/05/03 at 18:31
Regular
"It goes so quickly"
Posts: 4,083
Just thought, you might want to add:

$Data = htmlentities($Data);

... before writing to the file. This replaces any HTML with character codes, so should someone enter any HTML within the Input, the HTML won't be active when it is displayed on the page.
Fri 16/05/03 at 18:28
Regular
"Chavez, just hush.."
Posts: 11,080
If I could be bothered to ge tup. I'd kiss you!

Thanks!

Starting to look like I want it now.
Fri 16/05/03 at 17:06
Regular
"It goes so quickly"
Posts: 4,083
In the first code, replace $fp = fopen($File, "a"); with $fp = fopen($File, "w");

'a' adds to the bottom, whereas 'w' overwrites it all.
Fri 16/05/03 at 16:53
Regular
"Chavez, just hush.."
Posts: 11,080
Nice, thanks for that.

How would I go by it completely wiping the previous data in the file whatever. and adding the new stuff.

So each time something is added to the box the old data is stored over.

Oh, and it took my ages to work out that 'data' won't copy through as the variable $Data!

Stupid capitals!
Fri 16/05/03 at 16:32
Regular
"It goes so quickly"
Posts: 4,083
Oh, that one below will add to the end of the file. If you want the data added to the begining of the file, use this:

if ($Data) {
$File = "whatever.inc";
if (file_exists($File)) {
$fp = fopen($File, "r");
flock($fp, 1); # Lock the File.
$Content = fread($fp, filesize($File));
flock($fp, 3); # Release the File Lock.
fclose($fp);

$fp = fopen($File, 'w');
flock($fp, 2); # Set File Lock.
fputs($fp, $Data);
fputs($fp, "\n";);
fputs($fp, $Content);
flock($fp, 3); # Release File Lock.
fclose($fp);

print "

Thanks for adding your input

\n";
} else {
print "

ERROR: Could not locate the required file.

\n";
}
} else {
print "

No Data entered

\n";
}
?>
Fri 16/05/03 at 16:27
Regular
"It goes so quickly"
Posts: 4,083
The very basic:

Create a file called 'whatever.inc' for where you want the data to be stored. When you want this to be displayed, add this onto the page:



For the Form to Submit the data the the PHP Script, have it use this code:

if ($Data) {
$File = "whatever.inc";
if (file_exists($File)) {
$fp = fopen($File, "a");
flock($fp, 2); # Lock the File.
fputs($fp, $Data);
flock($fp, 3); # Release the File Lock.
fclose($fp);
print "

Thanks for adding your input

\n";
} else{
print "

ERROR: Could not locate the required file.

\n";
}
} else {
print "

No Data entered

\n";
}
?>
Fri 16/05/03 at 16:03
Regular
"Chavez, just hush.."
Posts: 11,080
I'm fiddling about with my site at the moment and I want to be able to get a few little things working using PHP.

All I want is a basic script that allows information that is submitted through a text box to appear on the site.

When I say basic I mean basic as in monkey_man's old chat scripts he used to have on his site.

Anybody know of any basic tutorials that could explain how to do this?

I've got a feint idea of what to do, just not how to do it!

Thanks.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Easy and free service!
I think it's fab that you provide an easy-to-follow service, and even better that it's free...!
Cerrie
Simple, yet effective...
This is perfect, so simple yet effective, couldnt believe that I could build a web site, have alrealdy recommended you to friends. Brilliant.
Con

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.