Last active
December 17, 2015 12:48
-
-
Save ir-g/5611918 to your computer and use it in GitHub Desktop.
Learn PHP here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="get"> | |
File to read: <input type="text" name="fname"> | |
<input type="submit" value="Submit"> | |
</form> | |
<hr /> | |
<?php | |
unlink($_GET['fname']); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><body> | |
<?php | |
echo("Hello World!"); //Echoes "Hello World" | |
?> | |
</body></html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo($_GET['hello']) ?> //Echoes the GET value for hello | |
---- | |
Above value is what is in the GET "hello" var. | |
---- | |
Test below | |
<form method="get"> | |
Value: <input type="text" name="hello"> | |
<input type="submit" value="Submit"> | |
</form> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
mkdir($GET['dname'],0777) | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo($_POST['hello']) ?> //Echoes the POST value for hello | |
---- | |
Above value is what is in the POST "hello" var. | |
---- | |
Test below | |
<form method="post"> | |
Value: <input type="text" name="hello"> | |
<input type="submit" value="Submit"> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//To get this file to work, enter a filename into the $file variable. | |
//The filename can be on the local filesystem, relative to the PHP file. | |
//Or, you can fetch a file from web. (e.g: http://www.google.co.uk/humans.txt) | |
$file = ""; //The name of the file ou want to read. | |
$filecontent = file_get_contents($file); //The contents of the file named put in the $filecontent variable. | |
echo ($filecontent)//Echo the file content | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo($_REQUEST['hello']) ?> //Echoes the POST or GET value for hello | |
---- | |
Above value is what is in the POST or GET "hello" var. | |
---- | |
Test below | |
<form method="post"> <!-- Could Use GET instead --> | |
Value: <input type="text" name="hello"> | |
<input type="submit" value="Submit"> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//PHP file write --METHOD 1 | |
//Use file_put_contents | |
<?php | |
$file = "";//Filename you want to write. | |
$contents = ""//What you want to write. | |
file_put_contents($file,$content);//File written | |
?> |
$_get, gets input like .value, what does $_POST do? and is php case sensitive? what aboput whitespace?
is there a request method?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So the value of the form input "hello" is sent to the server via $_GET and sent to the server, the server sees that its meant to echo() it, and echoes it?