Log in

View Full Version : Submit to write on a page



Demonicman
03-04-2007, 12:49 PM
here is a submition form i made and i know there is a lot of errors with the submit.php because i am brand new to this kind of stuff, but no it does not work, so i need someone smart to please help me fix it

this is the form


<form method="post" action="submit.php">
<font color="#00ff00">Game Name: </font><input type="text" name="title"><p>
<font color="#00ff00">Game URL: </font><input type="text" name="URL"><p>
<font color="#00ff00">Banner URL (height-68 width-520 EXACT): </font><input type="text" name="banner">
<p>
<font color="#00ff00">Game Information (Tell about your game): </font><input type="text" name="siteinfo"><p>
<input type="submit" name="submit" value="Submit Game">
<input type="reset" value="Reset Form" name="reset">
</form>


here is submit.php (wrong wrong wrong)
please help me with the mistakes i made


<?php


//find all the posted info and files

$title =$_POST['title'];
$URL =$_POST['URL'];
$banner =$_POST['banner'];
$siteinfo =$_POST['siteinfo'];
$valuefile = "value.txt";
$gamefile = "games.php";
$cho = $_POST['submit'];

//get ready for file changing
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
while($info = mysql_fetch_array( $check )) {

if(isset($cho)) {
if($info['points'] <= 79){
die('You do not have enough points yet! Go back to <a href="topgames.php">Top Games</a>');
};

$fh = fopen($valuefile, 'r');
/* Write game */
$gamestuff = "
<tr>
<td bgcolor=\"black\">
<center>
<font color=red>
<br>
<h2>
".$title."
</h2>
</font>
</center>
</td>
</tr>
<tr>
<td bgcolor=\"black\">
<center>
<h2>
<font color=\"#00ff00\"><a href=\"
".$URL."
\">
<img src=\"
".$banner."
\" border=\"0\">
</a>
</font>
</h2>
</center>
<?php $savefile = \"save"
.$valuefile['1'].
".txt\";
$contentsave = file_get_contents($savefile);
$file = explode(\"|\",$contentsave); ?>
<center>
<font color=\"00ff00\">
#1 - Awesome: <?php echo $file['1']; ?>
<br>
#2 - Ok: <?php echo $file['2']; ?>
<br>
#3 - Terrible: <?php echo $file['3']; ?>
<br>
</font>
</center> <center>
<form action=\"vote.php"
.$valuefile['1'].
"\" method=\"post\">
<font color=\"00ff00\">
#1 - Vote that the game is Awesome: <input type=\"radio\" name=\"choice\" value=\"1\"><br>
#2 - Vote that the game is Ok: <input type=\"radio\" name=\"choice\" value=\"2\">
<br>
#3 - Vote that the game is Terrible: <input type=\"radio\" name=\"choice\" value=\"3\">
<br>
</font>
<input type=\"submit\" value=\"Vote\" name=\"Vote\">
</form>
</center>
<center>
<table width=\"50&#37;\" height=\"100\" cellpadding=7>
<tr>
<td bgcolor=\"#330000\">
<font color=\"00ff00\">"
.$siteinfo.
"</font></td></tr>\r\n";
$handip = fopen($gamefile,"a+");
fwrite($handip, $gamestuff);
fclose($handip);
fclose($valuefile);

//change the value in valuefile
$valuething = fopen($valuefile, "a+");
fwrite($valuething, ++);
fclose($valuething);

/* Change the points to subtract 20 */
$newpoints = $info['points'];
echo "<p>Points before you submitted = " . ($newpoints-80) . "<br>";
echo "Your points after you submitted = " . $newpoints ."<br>";
echo "Submittion complete! <a href=\"topgames.php\">View</a>";

mysql_query("UPDATE users SET points='$newpoints' WHERE points='{$info['points']}'") or die(mysql_error());

}
}
?>

any help is greatly appreciated

Demonicman
03-04-2007, 02:33 PM
i forgot to mention that valuefile.php consists of a 0

Demonicman
03-04-2007, 04:35 PM
help... please? really im at a block until i get help with this

boxxertrumps
03-04-2007, 04:41 PM
You just gave us you SQL username and password...

You should edit that out before someone malicios sees it.

Demonicman
03-04-2007, 04:49 PM
thanks i was so frustrated i completely forgot (hope noone saw it)

Demonicman
03-04-2007, 06:39 PM
for those of you that looked at it and went "wtf" and went elsewhere i will break down what i want to happen

i have a file (topgames.php)

in it there is an include that includes (games.php)

what i want submit.php to do is write a new table on games.php so that i do not have to do it manually

what (value.txt) is, is a file with just 1 number in it and once the form has been submited i want that number to go up by 1 (which is why in $gamestuff i have $valuefile['1'] (i dont think thats right))

and i want this only possible to be submitted if $info['points'] is greater than or equal to 80