Note that there are some explanatory texts on larger screens.

plurals
  1. POvalues not fetched in textboxes from database in php
    primarykey
    data
    text
    <p>I want all details of user to be fetched in textboxes to edit profile of user accordingly based on username stored in session I don't want which statement is wrong I am not able to fetch values in textboxes. Please help me.</p> <p>Profile.php</p> <pre><code>&lt;?php include('connection.php'); //include('validation1.php'); session_start(); if( !empty($_SESSION['username']) &amp;&amp; isset($_SESSION['username'])) { $username=$_SESSION['username']; $checkinfo = mysql_query("SELECT * FROM profile WHERE username=".'"$username"'); //$result=mysql_fetch_array($checkinfo); while($result = mysql_fetch_array($checkinfo,MYSQL_ASSOC)){ $name =($result['name']); $address =($result['address']); $contact =($result['contact']); $state =($result['state']); $city = ($result['city']); $username =($result['uname']); $oldpass = ($result['opass']); } } if (isset($_POST['submit'])) { $name =($_POST['name_txt']); $address =($_POST['address_txt']); $contact =($_POST['contact_txt']); $gender = ($_POST['gender']); $country = ($_POST['country']); $state =($_POST['state_txt']); $city = ($_POST['city_txt']); $username =($_POST['uname_txt']); $oldpass = ($_POST['opass_txt']); $newpass = ($_POST['npass_txt']); $insquery="UPDATE INTO profile(name, address, contact,gender, country, state, city,username,opassword,npassword) VALUES ('$name','$address','$contact','$gender','$country','$state','$city','$username','$oldpass','$newpass')"; $result=mysql_query($insquery); // header("location:display.php"); if(!$insquery) { echo "Error Save [".mysql_error()."]"; } /*else { // header("location:display.php"); }*/ } ?&gt; &lt;body&gt; &lt;form id="form1" name="form1" method="post" action=""&gt; &lt;div align="center"&gt; Registration Form &lt;/div&gt; &lt;div align="right"&gt; &lt;?php if(isset($_SESSION['username'])) { $s="Hello,".$_SESSION["username"]; $r=$_SESSION["userrole"]; echo $s; } ?&gt;&lt;a href='logout.php' id='logout'&gt;Logout&lt;/a&gt; &lt;/div&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Name:&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="name_atxt" type="text" id="name_atxt" value="&lt;?php echo $name; ?&gt;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Address:&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;textarea name="address_txt" cols="40" rows="4" value="&lt;?php echo $address; ?&gt;"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Contact:&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="contact_txt" type="text" id="contact_ntxt" value="&lt;?php echo $contact; ?&gt;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Gender:&lt;/label&gt; &lt;td&gt; &lt;input type=radio name=gender value="male" id=male &gt;Male&lt;/br&gt; &lt;input type=radio name=gender value="female" id=female &gt;Female&lt;/br&gt;&lt;/td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Country:&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;select name="country_select" id="country_select"&gt; &lt;option value="0"&gt;--select a country--&lt;/option&gt; &lt;option value="India"&gt;India&lt;/option&gt; &lt;option value="USA"&gt;USA&lt;/option&gt; &lt;option value="UK"&gt;UK&lt;/option&gt; &lt;option value="Australia"&gt;Australia&lt;/option&gt; &lt;/select&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;State:&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="state_atxt" type="text" id="state_atxt" value="&lt;?php echo $state; ?&gt;"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;City:&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="city_atxt" type="text" id="city_atxt" value="&lt;?php echo $city; ?&gt;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Username:&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="uname_txt" type="text" id="uname_txt" value="&lt;?php echo $username; ?&gt;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Old Password:&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="opass_txt" type="password" id="opass_txt" value="&lt;?php echo $oldpass; ?&gt;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;New Password:&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="npass_txt" type="text" id="npass_txt" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="submit" name="submit" value="Submit" id="btn1" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="reset_btn" type="reset" value="Reset" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; </code></pre> <p>I want values already stored in database should be fetched in textbox of particular user who is in session and it is not fetching values in textbox. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload