beyonder's PHP thread o' FUN
beyonder's PHP thread o' FUN
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?
beyonder, how would I use PHP to let people book through the FE4SRP/ProjectTables page rather than having to email me?
~Twilkitri~
http://darktwilkitri.thegreatbeyond.net/ (is broken)
http://darktwilkitri.thegreatbeyond.net/ (is broken)
<?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
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
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?
And here are the errors:
Goes better on the net than in the cli... it just sits there if I try to run it in the cli...
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>
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~Twilkitri~
http://darktwilkitri.thegreatbeyond.net/ (is broken)
http://darktwilkitri.thegreatbeyond.net/ (is broken)
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....)
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....)
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...
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.";
?>
~Twilkitri~
http://darktwilkitri.thegreatbeyond.net/ (is broken)
http://darktwilkitri.thegreatbeyond.net/ (is broken)
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.
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' ?!?
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' ?!?
~Twilkitri~
http://darktwilkitri.thegreatbeyond.net/ (is broken)
http://darktwilkitri.thegreatbeyond.net/ (is broken)
Ergo, a command which runs remote commands.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' ?!?
~Twilkitri~
http://darktwilkitri.thegreatbeyond.net/ (is broken)
http://darktwilkitri.thegreatbeyond.net/ (is broken)
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!
http://chromus.thegreatbeyond.net/dunge ... s_scripts/
I've even included source code!


