Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to automaticall fill out a form with user data
    text
    copied!<p>I am new to PHP, so please forgive my simple question (I'm not even sure of how to ask it or what keywords I need to use).</p> <p>Basically, I'm trying to update a user's data in my database. I have a php for listing out all customers (phpselect.php):</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;?php # # Connect to the database # $conn=odbc_connect('database1','',''); if (!$conn) {exit("Connection Failed: " . $conn);} # # SQL statements # $sql="SELECT * FROM customer"; $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} # # Make a table # echo "&lt;table&gt;&lt;tr&gt;"; echo "&lt;th&gt;Action&lt;/th&gt;"; echo "&lt;th&gt;Customer ID&lt;/th&gt;"; echo "&lt;th&gt;Last Name&lt;/th&gt;"; echo "&lt;th&gt;First Name&lt;/th&gt;"; echo "&lt;th&gt;Middle Initial&lt;/th&gt;"; echo "&lt;th&gt;Home Phone&lt;/th&gt;"; echo "&lt;th&gt;Cell Phone&lt;/th&gt;"; echo "&lt;th&gt;Date of Birth&lt;/th&gt;"; echo "&lt;th&gt;Address&lt;/th&gt;"; echo "&lt;th&gt;City&lt;/th&gt;"; echo "&lt;th&gt;State&lt;/th&gt;"; echo "&lt;th&gt;Zip Code&lt;/th&gt;"; echo "&lt;th&gt;Employer&lt;/th&gt;"; echo "&lt;th&gt;Referrer&lt;/th&gt;"; echo "&lt;th&gt;Agent&lt;/th&gt;&lt;/tr&gt;"; # # Fetch records from SQL result-set # while (odbc_fetch_row($rs)) { # # Set field variables... # $cust_ID=odbc_result($rs,"cust_ID"); $cust_last=odbc_result($rs,"cust_last"); $cust_first=odbc_result($rs,"cust_first"); $cust_mi=odbc_result($rs,"cust_mi"); $home_phone=odbc_result($rs,"home_phone"); $cell_phone=odbc_result($rs,"cell_phone"); $DOB=odbc_result($rs,"DOB"); $street=odbc_result($rs,"street"); $city=odbc_result($rs,"city"); $state=odbc_result($rs,"state"); $zip_code=odbc_result($rs,"zip_code"); $employer=odbc_result($rs,"employer"); $referrer=odbc_result($rs,"referrer"); $agent_ID=odbc_result($rs,"agent_ID"); # # ...and display them by variable name # echo "&lt;tr&gt;"; echo "&lt;td&gt;edit&lt;/td&gt;"; echo "&lt;td&gt;$cust_ID&lt;/td&gt;"; echo "&lt;td&gt;$cust_last&lt;/td&gt;"; echo "&lt;td&gt;$cust_first&lt;/td&gt;"; echo "&lt;td&gt;$cust_mi&lt;/td&gt;"; echo "&lt;td&gt;$cust_last&lt;/td&gt;"; echo "&lt;td&gt;$home_phone&lt;/td&gt;"; echo "&lt;td&gt;$cell_phone&lt;/td&gt;"; echo "&lt;td&gt;$DOB&lt;/td&gt;"; echo "&lt;td&gt;$street&lt;/td&gt;"; echo "&lt;td&gt;$city&lt;/td&gt;"; echo "&lt;td&gt;$state&lt;/td&gt;"; echo "&lt;td&gt;$zip_code&lt;/td&gt;"; echo "&lt;td&gt;$employer&lt;/td&gt;"; echo "&lt;td&gt;$referrer&lt;/td&gt;"; echo "&lt;td&gt;$agent_ID&lt;/td&gt;&lt;/tr&gt;"; } # # Close the connection to the database # odbc_close($conn); # # End the table # echo "&lt;/table&gt;"; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>...and I am trying to add in a link ('Update') on each line that will send <em>that</em> user's information (from the database) to the fields in a form in order for the fields to be edited (phpinsert.php):</p> <pre><code>&lt;html&gt; &lt;body&gt; Enter Customer Information &lt;br&gt; (* indicates required fields) &lt;p&gt; &lt;form action="phpinsert.php" method="post"&gt; Last Name*: &lt;input type="text" name="cust_last"&gt; &lt;br&gt; First Name*: &lt;input type="text" name="cust_first"&gt; &lt;br&gt; Middle Initial: &lt;input type="text" name="cust_mi"&gt; &lt;br&gt; Home Phone*: &lt;input type="text" name="home_phone"&gt; &lt;br&gt; Cell Phone: &lt;input type="text" name="cell_phone"&gt; &lt;br&gt; Date of Birth (mm/dd/yyyy)*: &lt;input type="text" name="DOB"&gt; &lt;br&gt; Street Address: &lt;input type="text" name="street"&gt; &lt;br&gt; City: &lt;input type="text" name="city"&gt; &lt;br&gt; State: &lt;input type="text" name="state"&gt; &lt;br&gt; Zip Code: &lt;input type="text" name="zip_code"&gt; &lt;br&gt; Employer: &lt;input type="text" name="employer"&gt; &lt;br&gt; Referrer: &lt;input type="text" name="referrer"&gt; &lt;br&gt; &lt;tr&gt; &lt;td class="formLabel"&gt;Agent*:&lt;/td&gt; &lt;td&gt; &lt;select name="agent_ID" class="formEntry"&gt; &lt;option value="1"&gt;Guy Smiley&lt;/option&gt;&lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;br&gt;&lt;br&gt; &lt;input type="submit"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I'm not sure how to do this or how to ask it correctly though? </p> <p>Thanks for any help.</p>
 

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