- Apr 25, 2015
- 1,845
- 2
- 2,199
- 327
enter.php
index.php
Make sure to have a dir "/entries" and chmod -R 777 entries/
Then we must edit the Apache config to find "/var/www/" and change AllowOverride to All.
The dice.gif is simply an animated image of dice, you can find any one!
Inside of /entries/ make sure to create .htaccess (nano .htaccess) and write Deny from all.
Now when you want to find all the results, you can simply cat ./entries/* to see all of them.
The code could probably be cleaned up!
Code:
<?php
if(isset($_POST['user']))
{
$user = htmlentities($_POST['user']);
$email = htmlentities($_POST['email']);
$feedback = htmlentities($_POST['feedback']);
$myFile = "./entries/".base64_encode($user).".txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $email."\n";
fwrite($fh, $stringData);
$stringData = $feedback."\n";
fwrite($fh, $stringData);
fclose($fh);
}
?>
<style>
body {
background-image: url("dice.gif");
background-color: #cccccc;
}
</style>
<div style="background-color: white;padding:10px;text-align:center;">
Your entry has been received, thank you <b><?php echo($user);?></b>!
<p>
<a href="https://r4p3.net">Return to the forum.</a>
</p>
</div>
<?php
if(isset($_POST['forumUser']))
{
echo "test";
}
?>
index.php
Code:
<?php
//Phstorm Flat-file Form
?>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/build/pure-min.css" integrity="sha384-oAOxQR6DkCoMliIh8yFnu25d7Eq/PHS21PClpwjOTeU2jRSq11vu66rf90/cZr47" crossorigin="anonymous">
<div style="padding:15px;">
<form method="post" action="enter.php" class="pure-form pure-form-aligned">
<fieldset>
<legend>Please enter to win a virtual dedicated server.</legend>
<br><br>
<?php
if(isset($_GET['forumUser'])&&isset($_GET['forumEmail']))
{
$forumEmail = htmlentities($_GET['forumEmail']);
$forumUser = htmlentities($_GET['forumUser']);
echo "Email:<br><input name=\"email\" type=\"email\" placeholder=".$forumEmail." value=".$forumEmail."><br><br>";
echo "Username:<br><input name=\"user\" type=\"text\" placeholder=".$forumUser." value=".$forumUser.">";
}else{
header("Refresh:0; url=https://r4p3.net");//If missing email or username, redirect
}
?>
<br><br>
What kind of competitions would you like to see in the future?<br>
<textarea name="feedback"></textarea>
<br><br>
<button type="submit" class="pure-button pure-button-primary">Roll the dice</button>
</fieldset>
</form>
</div>
Make sure to have a dir "/entries" and chmod -R 777 entries/
Then we must edit the Apache config to find "/var/www/" and change AllowOverride to All.
The dice.gif is simply an animated image of dice, you can find any one!
Inside of /entries/ make sure to create .htaccess (nano .htaccess) and write Deny from all.
Now when you want to find all the results, you can simply cat ./entries/* to see all of them.
The code could probably be cleaned up!
Last edited: