I have a small form and this put some text into a plain file.
After that, if I want to change a line in this file, I have a PHP script to read the text, get the line I need to change and put this line in a text field on my form.
And now is the problem: on this procedure I lose a part of my text line, my PHP script put in text field just the first word from text line.
Help me, please.
problem with forms
Moderator: General Moderators
feyd | Please use
feyd | Please use
Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]Code: Select all
<?php
//File Name to read Here
$filename = "used_cars.dat";
//Checks to see if the file exist
if (file_exists("$filename")) {
//Assigns all the content from the file to the var $info
$inline = file($filename);
list ($nrcrt, $tip, $capacitate, $an, $km, $carburant, $culoare, $dotari, $pret, $img) = split('[|]', $inline[$y]);
$tip = str_replace ( "_", " ", $tip );
$capacitate = str_replace ( "_", " ", $capacitate );
$an = str_replace ( "_", " ", $an );
$km = str_replace ( "_", " ", $km );
$carburant = str_replace ( "_", " ", $carburant );
$culoare = str_replace ( "_", " ", $culoare );
$dotari = str_replace ( "_", " ", $dotari );
$pret = str_replace ( "_", " ", $pret );
echo "<html><title>Modifica Auto</title><body>";
echo "<FORM name='this' method='post' action='input_mod.php'>";
echo "<BR><table cellpadding="2" cellspacing="0" border="1" bordercolor="#CCCCCC" align="center"><TR>
<TD bgcolor="#003399"><font face="Arial, Helvetica, sans-serif" color='#ffffff' size='2'><b>Detalii Automobil</b></font></TD>
</TR>
<TR>
<TD align="center">
<TABLE border="0" cellspacing="1" cellpadding="1" align="center">";
echo "<TR><TD> </TD></TR>
<TR><TD align='center'>";
echo "<TABLE border='0' cellspacing='1' cellpadding='1' align='center' width='100%'><TR>
<TD><font face='Arial, Helvetica, sans-serif' size='-2'></font></TD>
<TD width='30%'><font face='Arial, Helvetica, sans-serif' size='-2'><b>Tip/Model:</b></font></TD>
<TD width='30%'><font face='Arial, Helvetica, sans-serif' size='-2'></font></TD>
<TD width='30%'><font face='Arial, Helvetica, sans-serif' size='-2'><b>Imagine:</b></font></TD>
</TR>
<TR>
<TD><font face='Arial, Helvetica, sans-serif' size='-2'></font></TD>
<TD width='30%'> <font face='Arial, Helvetica, sans-serif' size='-2'>
<input type='text' name='tip' size='20' value=$tip>
</font></TD><TD colspan="2"><font face='Arial, Helvetica, sans-serif' size='2'>
<input type='file' name='filename' size='29' id='filename' value=$img>
</font></TD>
</TR>
<TR>
<TD align='left'><font face='Arial, Helvetica, sans-serif' size='-2'></font></TD>
<TD align='left' width='30%'><b><font face='Arial, Helvetica, sans-serif' size='-2'>Capacitate
motor (CP):</font></b></TD>
<TD align='left' width='30%'><b><font face='Arial, Helvetica, sans-serif' size='-2'>An
fabricatie:</font></b></TD>
<TD align='left' width='30%'><b><font face='Arial, Helvetica, sans-serif' size='-2'>Rulaj
(km):</font></b></TD>
</TR>
<TR>
<TD> </TD>
<TD width='30%'><font face='Arial, Helvetica, sans-serif' size='-2'>
<input type='text' name='capacitate' value=$capacitate size='12'>
</font></TD>
<TD width='30%'><font face='Arial, Helvetica, sans-serif' size='-2'>
<input type='text' name='an' value=$an size='10'>
</font></TD>";
echo "<TD width='30%'><font face='Arial, Helvetica, sans-serif' size='-2'>
<input type='text' name='km' value=$km size='12'>
</font></TD>
</TR>";
echo "<TR>
<TD> </TD>
<TD width='30%'><b><font face='Arial, Helvetica, sans-serif' size='-2'>Carburant:</font></b></TD>
<TD width='30%'><font face='Arial, Helvetica, sans-serif' size='-2'><b>Culoare:</b>
</font></TD>
<TD width='30%'><b><font face='Arial, Helvetica, sans-serif' size='-2'>Pret
(€):</font></b></TD>
</TR>
<TR>
<TD> </TD>
<TD width='30%'>
<select name='carburant' id='carburant'>";
if ($carburant=" "){
echo "<option value=' ' selected> </option>";}
else{
echo "<option value=' '> </option>";}
if ($carburant="Benzina"){
echo "<option value='Benzina' selected>Benzina</option>";}
else{
echo "<option value='Benzina'>Benzina</option>";}
if ($carburant="Motorina"){
echo "<option value='Motorina' selected>Motorina</option>";}
else{
echo "<option value='Motorina'>Motorina</option>";}
echo "</select>
</TD>
<TD width='30%'>
<input type='text' maxlength='20' size='15' name='culoare' value=$culoare>
</TD>
<TD width='30%'><input type='text' name='pret' value=$pret size='10' maxlength='6'></TD></TR>
<TR>
<TD> </TD>
<TD colspan="3"><span class="style2"><font face="Arial, Helvetica, sans-serif" size='-2'>Dotari:</font></span></TD>
</TR>
<TR>
<TD> </TD>
<TD colspan="3"><textarea name="dotari" cols="50" rows="5" id="dotari" value=$dotari></textarea></TD>
</TR>
<TR>
<TD> </TD>
<TD colspan="3"> </TD>
</TR>
</TABLE></table>";
echo "</TD></TR></TABLE>";
echo "<TABLE width=50% border='0' cellspacing='0' cellpadding='0' align='center'>
<TR>
<TD align='center'><br>
<input type='hidden' name='nrcrt' value=$nrcrt>
<input type='hidden' name='y' value=$y>
<INPUT type='submit' name='yes' value=Modifica>
</td>
<td><br>
<INPUT type='submit' name='Renuntare' value=Renunta>
</TD>
</TR>
</TABLE>";
echo "</FORM>";
</body></html>";
}
?>feyd | Please use
Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
I'm going to hazard a guess that $dotari is the content, or maybe $pret.. at any rate, value attributes need to be in quotes. Textarea's values are a little different though. They are supposed to be stored inside the container, not in a value attribute..
if $dotari contains HTML, then you need to escape it for the code to show up in the textarea: [php_man]htmlentities[/php_man]()
Code: Select all
<textarea name="dotari" cols="50" rows="5" id="dotari">$dotari</textarea>As feyd said:
value=$capacitate
value=$pret
etc..etc..you need to quote them, eg
value="$capacitate"
value="$pret"
but because of your funky way of using quotes you'll need to do:
value=\"$capacitate\"
value=\"$pret\"
Be sure to change all the other place where you do value=$somevar too.
Where you have things like:value attributes need to be in quotes
value=$capacitate
value=$pret
etc..etc..you need to quote them, eg
value="$capacitate"
value="$pret"
but because of your funky way of using quotes you'll need to do:
value=\"$capacitate\"
value=\"$pret\"
Be sure to change all the other place where you do value=$somevar too.