Hi,
I have an editing form for my users in which they can change their profiles and the change is saved in database and also displayed for the user.the problem is that testfield that have varchar type only display the first word of what user typed.for example if a user wants to change his last name from 'salehi' to 'salehie rashid' the complete new lastname will be updated in database but in the textfield only the first word(before space) is displayed that is 'salehie'. the textarea,howeve r display the address correctly and only the textfields are like this to show only one word
why is it like this?and what can I do to solve the problem
the code related is:
and the table (in HeidiSQL) is like this:
I have an editing form for my users in which they can change their profiles and the change is saved in database and also displayed for the user.the problem is that testfield that have varchar type only display the first word of what user typed.for example if a user wants to change his last name from 'salehi' to 'salehie rashid' the complete new lastname will be updated in database but in the textfield only the first word(before space) is displayed that is 'salehie'. the textarea,howeve r display the address correctly and only the textfields are like this to show only one word
why is it like this?and what can I do to solve the problem
the code related is:
Code:
<?php if(isset($_POST['username'])){ mysql_query("UPDATE user SET username = '{$_POST['username']}', name = '{$_POST['name']}', lastname = '{$_POST['lastname']}',address = '{$_POST['address']}' WHERE id = {$_SESSION['id']}") or die(mysql_error()); $res = mysql_query("SELECT * FROM user WHERE id = " . $_SESSION['id']); $row = mysql_fetch_assoc($res); ?> <form action="edit_account.php" method="post" enctype="multipart/form-data"> <table> <tr><td>Username:</td> <td><input type="text" name="username" value=<?= $row["username"] ?> ></td></tr> <tr><td>Name:</td> <td><input type="text" name="name" value=<?= $row["name"] ?>> </td></tr> <tr><td>Last Name:</td> <td><input type="text" name="lastname" value=<?= $row["lastname"] ?> ></td></tr> <tr valign="top"><td>Address:</td> <td><textarea name="address" cols="23" rows="4"><?= $row["address"]?> </textarea> </tr> <tr><td><label>image:</label></td> <td><input name="file" type="file"/></td></tr> <tr><td><input type="submit" id="add" value="save" name="submit"></td> </table> </form>
Code:
Create table if not exists user (id INT UNSIGNED NOT NULL auto_increment, username VARCHAR(15), password VARCHAR(40), name VARCHAR(15) NOT NULL, lastname VARCHAR(40) NOT NULL, address VARCHAR(100) NOT NULL, PRIMARY KEY(id))
Comment