This is a script for my webpage to add new cheats to my cheats section.
The problem is that when the php script writes to the html file the cheats that the user wants to is beeing on one line in the html file, but it is multiline when opens it. Also it is another problem when the php script writes to the html file it's cutting it off so its just about max350 - 400 characters long. It has an confirm screen and there it shows all cheats.
What have i done wrong??
Cold some body help me with making my script work??
Here is the hole script(if you want to try it you must make some folder namde:abc,def...):
<link rel="stylesheet" type="text/css" href="../style.css">
<style>
<!--
body { background-color: black; color: white; font-family: arial;}
-->
</style>
<?
if (!isset($game_name) || !isset($cheat)) submit_cheat();
elseif ($confirm == "yes" write_html($game_name,$nick,$email,$cheat);
else confirm($game_name,$nick,$email,$cheat);
function submit_cheat() {
?>
<form action="<? PHP_SELF ?>" method="POST">
Name of game<font color="red">*</font>:<br>
<input type="text" name="game_name" size="20"><br>
Your name/nickname:<br>
<input type="text" name="nick" size="20"><br>
Your E-Mail:<br>
<input type="text" name="email" size="20"><br>
Cheats you want to add<font color="red">*</font>:<br>
<textarea cols="70" rows="20" name="cheat" wrap="hard"></textarea><br>
<input type="submit" value="Submit cheats">
<input type="reset" value="Wipe out">
</form>
<hr>
<font color="red">* Must be filled out.</font>
<?
}
function confirm($game_name,$nick,$email,$cheat) {
$cheat = ereg_replace("\n", "<br>\n", $cheat);
if (empty($nick)) $nick = "Anonymous";
if (empty($email)) $email = "Anonymous";
?>
<center><h1>CONFIRM</h1></center>
Game name:<br>
<? echo $game_name ?><br><br>
Your name/nickname:<br>
<? echo $nick ?><br><br>
Your E-Mail:<br>
<? echo $email ?><br><br>
The cheats you want to add:<br>
<pre>
<? echo $cheat ?><br>
</pre>
<hr>
<center>Is this right? If not, hit the back button and fix it.<br>
If it is right click <a href="subnew.php?confirm=yes&game_name=<? echo $game_name ?>&nick=<? echo $nick ?>&email=<? echo $email ?>&cheat=<? echo $cheat ?>">HERE</a></center>
<?
}
function write_html($game_name,$nick,$email,$cheat){
$a = $game_name{0};
if ($a == "a" $folder = "abc";
if ($a == "b" $folder = "abc";
if ($a == "c" $folder = "abc";
if ($a == "d" $folder = "def";
if ($a == "e" $folder = "def";
if ($a == "f" $folder = "def";
if ($a == "g" $folder = "ghi";
if ($a == "h" $folder = "ghi";
if ($a == "i" $folder = "ghi";
if ($a == "j" $folder = "jkl";
if ($a == "k" $folder = "jkl";
if ($a == "l" $folder = "jkl";
if ($a == "m" $folder = "mno";
if ($a == "n" $folder = "mno";
if ($a == "o" $folder = "mno";
if ($a == "p" $folder = "pqr";
if ($a == "q" $folder = "pqr";
if ($a == "r" $folder = "pqr";
if ($a == "s" $folder = "stu";
if ($a == "t" $folder = "stu";
if ($a == "u" $folder = "stu";
if ($a == "v" $folder = "vwx";
if ($a == "w" $folder = "vwx";
if ($a == "x" $folder = "vwx";
if ($a == "y" $folder = "yz";
if ($a == "z" $folder = "yz";
if ($a == "A" $folder = "abc";
if ($a == "B" $folder = "abc";
if ($a == "C" $folder = "abc";
if ($a == "D" $folder = "def";
if ($a == "E" $folder = "def";
if ($a == "F" $folder = "def";
if ($a == "G" $folder = "ghi";
if ($a == "H" $folder = "ghi";
if ($a == "I" $folder = "ghi";
if ($a == "J" $folder = "jkl";
if ($a == "K" $folder = "jkl";
if ($a == "L" $folder = "jkl";
if ($a == "M" $folder = "mno";
if ($a == "N" $folder = "mno";
if ($a == "O" $folder = "mno";
if ($a == "P" $folder = "pqr";
if ($a == "Q" $folder = "pqr";
if ($a == "R" $folder = "pqr";
if ($a == "S" $folder = "stu";
if ($a == "T" $folder = "stu";
if ($a == "U" $folder = "stu";
if ($a == "V" $folder = "vwx";
if ($a == "W" $folder = "vwx";
if ($a == "X" $folder = "vwx";
if ($a == "Y" $folder = "yz";
if ($a == "Z" $folder = "yz";
$html = "<html>
<head>
<title>$game_name cheats</title>
</head>
<body>
<link rel='stylesheet' type='text/css' href='../../style.css'>
<style>
<!--
body { background-color: black; color: white; font-family: arial;}
-->
</style>
<center><font size=6>$game_name</font></center>
<a href='../$folder.php'><--Back</a>
<hr>
$cheat
<hr>
<font size=1>Submited by: $nick ($email)</font>
</body>
</html>";
$fp = fopen("$folder/$game_name.html", "w+"
fwrite($fp, $html);
fclose($fp);
?>
<font size=7>Thanx!!</font><br><br><br>
<a href="<? echo $folder ?>.php"><--Back</a>
<?
}
?>
The problem is that when the php script writes to the html file the cheats that the user wants to is beeing on one line in the html file, but it is multiline when opens it. Also it is another problem when the php script writes to the html file it's cutting it off so its just about max350 - 400 characters long. It has an confirm screen and there it shows all cheats.
What have i done wrong??
Cold some body help me with making my script work??
Here is the hole script(if you want to try it you must make some folder namde:abc,def...):
<link rel="stylesheet" type="text/css" href="../style.css">
<style>
<!--
body { background-color: black; color: white; font-family: arial;}
-->
</style>
<?
if (!isset($game_name) || !isset($cheat)) submit_cheat();
elseif ($confirm == "yes" write_html($game_name,$nick,$email,$cheat);
else confirm($game_name,$nick,$email,$cheat);
function submit_cheat() {
?>
<form action="<? PHP_SELF ?>" method="POST">
Name of game<font color="red">*</font>:<br>
<input type="text" name="game_name" size="20"><br>
Your name/nickname:<br>
<input type="text" name="nick" size="20"><br>
Your E-Mail:<br>
<input type="text" name="email" size="20"><br>
Cheats you want to add<font color="red">*</font>:<br>
<textarea cols="70" rows="20" name="cheat" wrap="hard"></textarea><br>
<input type="submit" value="Submit cheats">
<input type="reset" value="Wipe out">
</form>
<hr>
<font color="red">* Must be filled out.</font>
<?
}
function confirm($game_name,$nick,$email,$cheat) {
$cheat = ereg_replace("\n", "<br>\n", $cheat);
if (empty($nick)) $nick = "Anonymous";
if (empty($email)) $email = "Anonymous";
?>
<center><h1>CONFIRM</h1></center>
Game name:<br>
<? echo $game_name ?><br><br>
Your name/nickname:<br>
<? echo $nick ?><br><br>
Your E-Mail:<br>
<? echo $email ?><br><br>
The cheats you want to add:<br>
<pre>
<? echo $cheat ?><br>
</pre>
<hr>
<center>Is this right? If not, hit the back button and fix it.<br>
If it is right click <a href="subnew.php?confirm=yes&game_name=<? echo $game_name ?>&nick=<? echo $nick ?>&email=<? echo $email ?>&cheat=<? echo $cheat ?>">HERE</a></center>
<?
}
function write_html($game_name,$nick,$email,$cheat){
$a = $game_name{0};
if ($a == "a" $folder = "abc";
if ($a == "b" $folder = "abc";
if ($a == "c" $folder = "abc";
if ($a == "d" $folder = "def";
if ($a == "e" $folder = "def";
if ($a == "f" $folder = "def";
if ($a == "g" $folder = "ghi";
if ($a == "h" $folder = "ghi";
if ($a == "i" $folder = "ghi";
if ($a == "j" $folder = "jkl";
if ($a == "k" $folder = "jkl";
if ($a == "l" $folder = "jkl";
if ($a == "m" $folder = "mno";
if ($a == "n" $folder = "mno";
if ($a == "o" $folder = "mno";
if ($a == "p" $folder = "pqr";
if ($a == "q" $folder = "pqr";
if ($a == "r" $folder = "pqr";
if ($a == "s" $folder = "stu";
if ($a == "t" $folder = "stu";
if ($a == "u" $folder = "stu";
if ($a == "v" $folder = "vwx";
if ($a == "w" $folder = "vwx";
if ($a == "x" $folder = "vwx";
if ($a == "y" $folder = "yz";
if ($a == "z" $folder = "yz";
if ($a == "A" $folder = "abc";
if ($a == "B" $folder = "abc";
if ($a == "C" $folder = "abc";
if ($a == "D" $folder = "def";
if ($a == "E" $folder = "def";
if ($a == "F" $folder = "def";
if ($a == "G" $folder = "ghi";
if ($a == "H" $folder = "ghi";
if ($a == "I" $folder = "ghi";
if ($a == "J" $folder = "jkl";
if ($a == "K" $folder = "jkl";
if ($a == "L" $folder = "jkl";
if ($a == "M" $folder = "mno";
if ($a == "N" $folder = "mno";
if ($a == "O" $folder = "mno";
if ($a == "P" $folder = "pqr";
if ($a == "Q" $folder = "pqr";
if ($a == "R" $folder = "pqr";
if ($a == "S" $folder = "stu";
if ($a == "T" $folder = "stu";
if ($a == "U" $folder = "stu";
if ($a == "V" $folder = "vwx";
if ($a == "W" $folder = "vwx";
if ($a == "X" $folder = "vwx";
if ($a == "Y" $folder = "yz";
if ($a == "Z" $folder = "yz";
$html = "<html>
<head>
<title>$game_name cheats</title>
</head>
<body>
<link rel='stylesheet' type='text/css' href='../../style.css'>
<style>
<!--
body { background-color: black; color: white; font-family: arial;}
-->
</style>
<center><font size=6>$game_name</font></center>
<a href='../$folder.php'><--Back</a>
<hr>
$cheat
<hr>
<font size=1>Submited by: $nick ($email)</font>
</body>
</html>";
$fp = fopen("$folder/$game_name.html", "w+"
fwrite($fp, $html);
fclose($fp);
?>
<font size=7>Thanx!!</font><br><br><br>
<a href="<? echo $folder ?>.php"><--Back</a>
<?
}
?>