Jump to content

[SOLVED] Text box not having the entire string value


Recommended Posts

Hey guys,

 

again I'm stuck on this simple code. I might have missed something so want your help.

 

Basically, my issue is this.

The textbox cusadd is supposed to have the customers address.

But when the page is displayed only the first word is entered in the text box automatically.

But if echo the string, the entire value is shown.

 

My code is below. The bolded section is where i need your help.

 

<?php

ob_start();

$database = $_COOKIE["database"];

$password = $_COOKIE["password"];

$username = $_COOKIE["username"];

$host="localhost"; // Host name

$db_name=$database; // Database name

$tbl_name="cards"; // Table name

 

mysql_connect("$host", "$username", "$password")or die(mysql_error());

mysql_select_db("$database")or die(mysql_error());

 

$nama = $_GET["nama"];

$ty = "customer";

//$query="SELECT * FROM $tbl_name WHERE nama = '$nama' AND type = '$ty'";

 

$query="SELECT addy,tel FROM $tbl_name WHERE nama = '$nama' AND typer = '$ty'";

$result=mysql_query($query);

$num=mysql_num_rows($result);

 

while($row = mysql_fetch_array($result))

{

$cusadd = $row['addy'];

$custel = $row['tel'];

}

echo "<form name='edit_php' id='form' method='post' action = 'customer_editor.php'>";

echo "<table width='763' height = '65' border='1' bordercolor='#ECE9D8' bgcolor='#CC0033'>";

//echo "<table width="763" height="65" border="1" bordercolor='#ECE9D8' bgcolor='#CC0033' >";

echo "<tr>";

$a = "Edit Customer Details  :  " . $nama ;

echo "<td align='center' valign='middle'><span class='style2 style1'><span class='style7'>".$a."</span></span></td>";

echo "</tr>";

echo "</table>";

echo "<br>";

//echo "<label><strong class='style3 style6'>Old Account Number :</strong><br />";

echo "<br>";

echo "<input type='hidden' name='nama_old' id='nama_old' value=".$nama.">";

echo "<br>";

echo "<br>";

echo "<label><strong class='style3 style6'>New customer Name :</strong><br />";

echo "<br>";

echo "<input type='text' name='nama' id='nama' value=".$nama.">";

echo "<br>";

echo "<p class='style4'>Please enter the new address.</p>";

echo "<br>";

echo "<label><strong class='style3 style6'>Customer Address :</strong><br />";

echo "<br>";

echo "<input type='text' name='cusadd' id='cusadd' value=".$cusadd."/input>";

echo $cusadd;

exit;

echo "<p class='style4'>Please enter the new address.</p>";

echo "<br>";

echo "<label><strong class='style3 style6'>Telephone :</strong><br />";

echo "<br>";

echo "<input type='text' name='custel' id='custel' value=".$custel.">";

echo "<p class='style4'>Please enter the new telephone number.</p>";

 

echo "<input type='submit' name='update_cuscard' id='submitter' value='Edit Customer' />";

echo "</form>";

 

?>

 

If you can help me out on this I'd appreciate it very much.

FYI php is working fine, the file has a .php extension.

All other text boxes load fine exept for this ( I didnt test the cusname text box) how ever if i get the solution for the current one then the its gonna be the same for cusname.

 

thanks in advance

The address is only on one line or multiple lines?

You probably want textarea not text.

http://www.w3schools.com/TAGS/tag_textarea.asp

 

I tried the below code with no luck as well.

 

echo "<input type='text' name='cusadd' id='cusadd' value=".htmlspecialchars($cusadd)."/>";

Knsito, PFMaBismAd ;

 

thank you guys.

both of your tips worked like a charm.

 

the below code worked.

echo "<textarea name='cusadd' id='cusadd' cols='45' rows='5' value = ".htmlentities($cusadd,ENT_QUOTES)."/textarea>";

 

thank thank you again guys

ok tried the following but still with no luck :( :(

 

$nama1 = htmlentities($cusadd,ENT_QUOTES);

echo $nama1;

echo "<textarea name='cus_add' id='cus_add' cols='45' rows='5'-

-value='" . $nama1 . "'</textarea>";

 

the problem is no value loads up to the text area.

 

i kinda wanted to delete the above post but apparently i cant. i thought it worked for a while but when i suddenly refreshed the page it didnt work and so did all the retries of loading the page from scratch.

Like this

 

<textarea textarea name="cusadd" id="cusadd" cols="45" rows="5">

--- Your Text Here ---

</textarea>

 

BTW I think the standard for attributes is to use double quotes, not single. (maybe it doesnt matter.. I dont remember :\)

 

 

ok tried the following but still with no luck :( :(

 

$nama1 = htmlentities($cusadd,ENT_QUOTES);

echo $nama1;

echo "<textarea name='cus_add' id='cus_add' cols='45' rows='5'-

-value='" . $nama1 . "'</textarea>";

 

the problem is no value loads up to the text area.

 

i kinda wanted to delete the above post but apparently i cant. i thought it worked for a while but when i suddenly refreshed the page it didnt work and so did all the retries of loading the page from scratch.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.