Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

html forms and php problem???

Status
Not open for further replies.

Naits

Programmer
Oct 10, 2001
90
NO
The html form has an textarea, and the php script makes an html page. All is working perfectly except that the text in the textarea is just 1 line in the variable that holds it and in the htlm page that is been generated. How can i fix this??? If you need my script to solv the problem, I can post it.
 
it's better if you post the script but my first guess is that you need to replace all \n with <br>
user ereg_replace for this:
Code:
$text = ereg_replace(&quot;\n&quot;, &quot;<br>\n&quot;, $text);
(-:
 
Okey here it is(it is a script for adding new cheats for the cheat section on my new webpage):

<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;../style.css&quot;>
<style>
<!--
body { background-color: black; color: white; font-family: arial;}

-->
</style>
<?

if (empty($game_name) || empty($cheat)) submit_cheat();
elseif ($confirm == &quot;yes&quot;) write_html($game_name,$nick,$email,$cheat);
else confirm($game_name,$nick,$email,$cheat);

function submit_cheat() {
?>
<form action=&quot;subnew.php&quot; method=&quot;GET/POST&quot;>
Name of game<font color=&quot;red&quot;>*</font>:<br>
<input type=&quot;text&quot; name=&quot;game_name&quot; size=&quot;20&quot;><br>
Your name/nickname:<br>
<input type=&quot;text&quot; name=&quot;nick&quot; size=&quot;20&quot;><br>
Your E-Mail:<br>
<input type=&quot;text&quot; name=&quot;email&quot; size=&quot;20&quot;><br>
Cheats you want to add<font color=&quot;red&quot;>*</font>:<br>
<textarea name=&quot;cheat&quot; rows=&quot;10&quot; cols=&quot;40&quot;></textarea><br>
<input type=&quot;submit&quot; value=&quot;Submit cheats&quot;>
<input type=&quot;reset&quot; value=&quot;Wipe out&quot;>
</form>
<hr>
<font color=&quot;red&quot;>* Must be filled out.</font>
<?
}

function confirm($game_name,$nick,$email,$cheat) {

if (empty($nick)) $nick = &quot;Anonymous&quot;;
if (empty($email)) $email = &quot;Anonymous&quot;;

?>

<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>
<? echo $cheat ?><br>
<hr>
<center>Is this right? If not, hit the back button and fix it.<br>
If it is right click <a href=&quot;subnew.php?confirm=yes&game_name=<? echo $game_name ?>&nick=<? echo $nick ?>&email=<? echo $email ?>&cheat=<? echo $cheat ?>&quot;>HERE</a></center>
<?
}

function write_html($game_name,$nick,$email,$cheat){
$a = $game_name{0};
if ($a == &quot;a&quot;) $folder = &quot;abc&quot;;
if ($a == &quot;b&quot;) $folder = &quot;abc&quot;;
if ($a == &quot;c&quot;) $folder = &quot;abc&quot;;
if ($a == &quot;d&quot;) $folder = &quot;def&quot;;
if ($a == &quot;e&quot;) $folder = &quot;def&quot;;
if ($a == &quot;f&quot;) $folder = &quot;def&quot;;
if ($a == &quot;g&quot;) $folder = &quot;ghi&quot;;
if ($a == &quot;h&quot;) $folder = &quot;ghi&quot;;
if ($a == &quot;i&quot;) $folder = &quot;ghi&quot;;
if ($a == &quot;j&quot;) $folder = &quot;jkl&quot;;
if ($a == &quot;k&quot;) $folder = &quot;jkl&quot;;
if ($a == &quot;l&quot;) $folder = &quot;jkl&quot;;
if ($a == &quot;m&quot;) $folder = &quot;mno&quot;;
if ($a == &quot;n&quot;) $folder = &quot;mno&quot;;
if ($a == &quot;o&quot;) $folder = &quot;mno&quot;;
if ($a == &quot;p&quot;) $folder = &quot;pqr&quot;;
if ($a == &quot;q&quot;) $folder = &quot;pqr&quot;;
if ($a == &quot;r&quot;) $folder = &quot;pqr&quot;;
if ($a == &quot;s&quot;) $folder = &quot;stu&quot;;
if ($a == &quot;t&quot;) $folder = &quot;stu&quot;;
if ($a == &quot;u&quot;) $folder = &quot;stu&quot;;
if ($a == &quot;v&quot;) $folder = &quot;vwx&quot;;
if ($a == &quot;w&quot;) $folder = &quot;vwx&quot;;
if ($a == &quot;x&quot;) $folder = &quot;vwx&quot;;
if ($a == &quot;y&quot;) $folder = &quot;yz&quot;;
if ($a == &quot;z&quot;) $folder = &quot;yz&quot;;
if ($a == &quot;A&quot;) $folder = &quot;abc&quot;;
if ($a == &quot;B&quot;) $folder = &quot;abc&quot;;
if ($a == &quot;C&quot;) $folder = &quot;abc&quot;;
if ($a == &quot;D&quot;) $folder = &quot;def&quot;;
if ($a == &quot;E&quot;) $folder = &quot;def&quot;;
if ($a == &quot;F&quot;) $folder = &quot;def&quot;;
if ($a == &quot;G&quot;) $folder = &quot;ghi&quot;;
if ($a == &quot;H&quot;) $folder = &quot;ghi&quot;;
if ($a == &quot;I&quot;) $folder = &quot;ghi&quot;;
if ($a == &quot;J&quot;) $folder = &quot;jkl&quot;;
if ($a == &quot;K&quot;) $folder = &quot;jkl&quot;;
if ($a == &quot;L&quot;) $folder = &quot;jkl&quot;;
if ($a == &quot;M&quot;) $folder = &quot;mno&quot;;
if ($a == &quot;N&quot;) $folder = &quot;mno&quot;;
if ($a == &quot;O&quot;) $folder = &quot;mno&quot;;
if ($a == &quot;P&quot;) $folder = &quot;pqr&quot;;
if ($a == &quot;Q&quot;) $folder = &quot;pqr&quot;;
if ($a == &quot;R&quot;) $folder = &quot;pqr&quot;;
if ($a == &quot;S&quot;) $folder = &quot;stu&quot;;
if ($a == &quot;T&quot;) $folder = &quot;stu&quot;;
if ($a == &quot;U&quot;) $folder = &quot;stu&quot;;
if ($a == &quot;V&quot;) $folder = &quot;vwx&quot;;
if ($a == &quot;W&quot;) $folder = &quot;vwx&quot;;
if ($a == &quot;X&quot;) $folder = &quot;vwx&quot;;
if ($a == &quot;Y&quot;) $folder = &quot;yz&quot;;
if ($a == &quot;Z&quot;) $folder = &quot;yz&quot;;
$html = &quot;
<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>&quot;;

$fp = fopen(&quot;$folder/$game_name.html&quot;, &quot;w+&quot;);
fputs($fp, $html);
fclose($fp);
?>
<font size=7>Thanx!!</font><br><br><br>
<a href=&quot;<? echo $folder ?>.php&quot;><--Back</a>
<?
}
?>
 
did you try this?
Code:
$cheat = ereg_replace(&quot;\n&quot;, &quot;<br>\n&quot;, $cheat);

this should do the trick.
also add wrapping definition to the textarea:
Code:
<textarea cols=&quot;40&quot; rows=&quot;10&quot; name=&quot;cheat&quot; wrap=&quot;hard&quot;></textarea>
this will force new lines when getting to the end of the line in the textarea. (-:
 
Now i have 2 new problems....

1. When i put lage amount of data in the textare my submit butten wont work.

2. The html file that is been created does only contain 350 - 400 chatacters of the thing i wrote into the textarea.

Can somebody help me with this??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top