Page 1 of 2
beyonder's PHP thread o' FUN
Posted: Sun Mar 02, 2003 9:46 pm
by Twilkitri
We all know he was going to make this eventually, so I've made it for him since he was taking so long.
beyonder, how would I use PHP to let people book through the FE4SRP/ProjectTables page rather than having to email me?
Posted: Sun Mar 02, 2003 10:13 pm
by beyonder
<?php
if (isset($submit)){
//code to do on submit goes here!(nifty, eh?)
}
else{
echo '
<form method="post" action="thisverysamefile.php">
make a form, put it here.....
<input type="submit" name="submit" value="submit"></input>
</form>
';
}
?>
when the user clicks the submit button, the script gets called again, but since $submit is now set, executes the other section....which will be used to store the data they entered. when making the form, remember that the name of each field and it's value will be passed to the script when the person hits the submit button...this means that if you use name="hello" for a field, that will be accessable through use of $name in the script. there would then be two ways to store the data, one being files on the server, the other being the mySQL database on the server(for this method you need to ask me for a db account for your script to use)
http://www.php.net/manual/en/ref.filesystem.php <-- php filesystem functions
http://www.php.net/manual/en/ref.mysql.php <-- php mySQL functions
Posted: Sat Mar 08, 2003 7:00 am
by Twilkitri
OK now, I haven't really looked at that yet, this is a different topic.
You know how old browsers can't handle PNG outside of a page, and send it to MPE or some such program, right? Anyways, I didn't really want to make a tiny page for every PNG sheet that got put up, so I tried making a single dynamic page in php. But it won't work ><
Can you see any errors in this?
Code: Select all
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
header("Content-type: image/png");
$string = $_GET['pic'];
$add = "SHEETS/";
$add .= $string;
$im = imagecreatefrompng($add);
imagepng($im);
//imagedestroy($im);
?>
</body>
</html>
And here are the errors:
Code: Select all
Warning: Cannot add header information - headers already sent by (output started at c:\inetpub\wwwroot\darktwilkitri\FE4\PNGVIEW.PHP:6) in c:\inetpub\wwwroot\darktwilkitri\FE4\PNGVIEW.PHP on line 7
Fatal error: Call to undefined function: imagecreatefrompng() in c:\inetpub\wwwroot\darktwilkitri\FE4\PNGVIEW.PHP on line 1
Goes better on the net than in the cli... it just sits there if I try to run it in the cli...
Posted: Sat Mar 08, 2003 3:33 pm
by beyonder
if this script worked, it wold end up with some weird output.....the code for an image embedded into a html file if i'm thinking right......why can't you just echo an img tag to embed the picture into a very simple page
replace
$im = imagecreatefrompng($add);
imagepng($im);
//imagedestroy($im);
with
echo "<img src=\"" . $add . "\">";
adding attributes to the img tag as you wish.....and take out the header("Content-type: image/png"); line....this function can only be used if it is the absolute first thing in a file....no html before it, and if left in will make the browser think that what it's looking at is supposed to be *entirely* a png and kill itself.
and besides that, the php PNG functions are quite buggy(and for some reason the server seems to think that they don't exist....)
Posted: Tue Nov 04, 2003 10:24 pm
by Twilkitri
It's been too long since beyonder had any FUN in his PHP thread o' it!
Rightio.
http://www.thegreatbeyond.net/DarkTwilkitri/sts2.php
There you can see the brains... er, error which is similar to what I was talking to you about in chat the other day. Although I didn't get those messages because I don't have notices turned on, so it may be a different error just with the same effect.
Any ideas?
I'll just pust the code here too...
Code: Select all
<?php
$count = file_get_contents("STScount.txt");
$count++;
$countfile = fopen("STScount.txt", "wb");
fwrite($countfile, $count);
fclose($countfile);
print "This page has been viewed $count times since November 5, 2003.";
?>
Posted: Wed Nov 05, 2003 4:12 am
by beyonder
Well, since giving the user 'nobody' write access to everything on a server does not make much sense, if you upload a file, the ftp writes the file using the user 'thegreat', now this user can write to the file but 'nobody' cannot. 'nobody' is the user that the Apache process, and therefore the PHP parser runs on. There's really two solutions to this. They both involve chmod 777'ing *something*, in one case it's a directory in another it's a file. You have access to chmod files through the ftp. THe directory method would be to make a directory, chmod it and have the script create the file in it. The file method should be pretty obvious.
Posted: Wed Nov 05, 2003 4:13 am
by beyonder
Or, if you're feeling like the spawn of satan, a chmod 666 should also do the trick. ^.~
Posted: Thu Nov 06, 2003 12:29 am
by Twilkitri
Hooray!
Took me a while to figure out how to get ftp to tell your ftp to chmod, though. What sort of a name for a remote command command is 'quote' ?!?
Posted: Thu Nov 06, 2003 1:24 am
by beyonder
'quote' isn't a remote command. it's a local command. it tells your ftp client to send the command exactly as you type it.
Posted: Thu Nov 06, 2003 7:01 pm
by Twilkitri
That's what I said...
Posted: Sat Nov 08, 2003 12:57 am
by beyonder
no it's not...
Posted: Sat Nov 08, 2003 8:20 am
by Twilkitri
DarkTwilkitri wrote:Hooray!
Took me a while to figure out how to get ftp to tell your ftp to chmod, though. What sort of a name for a remote command command is 'quote' ?!?
Ergo, a command which runs remote commands.
Posted: Sat Jan 17, 2004 9:49 pm
by chromus
As opposed to asking for help with PHP, I want to see how people like the PHP version of some of my scripts. Check them out:
http://chromus.thegreatbeyond.net/dunge ... s_scripts/
I've even included source code!
Posted: Sun Jan 18, 2004 2:55 pm
by beyonder
o_o; your special html characters in the source are missing semicolons...so in mozilla they just show up as <, should be <
Posted: Sun Jan 18, 2004 7:16 pm
by chromus
Whoops. All fixed now, I hope. If anyone finds any more problems, let me know and I'll fix them.