Note that there are some explanatory texts on larger screens.

plurals
  1. POphp comment form
    text
    copied!<p>I have a comment form that I have created. It gets the id from the database and prints out the data that goes with that id, but what it also does is prints out the information into the form. I want a blank form so that the user can add a comment to the record.</p> <p>Any ideas?</p> <p>This the code for the form: </p> <pre><code>&lt;form method="post" action="pv.php?id=&lt;?php echo $row['ID']?&gt;&amp;action=&lt;?php echo $form_action ?&gt;"&gt; &lt;fieldset&gt; &lt;legend&gt;&lt;/legend&gt; &lt;p&gt; &lt;label for="cname"&gt;Date Of Birth&lt;/label&gt; * &lt;input id="cname" name="dateofbirth" class="required date" value="&lt;?php echo $row['Date_Of_Birth']?&gt;" /&gt; (eg 1978.11.11) &lt;/p&gt; &lt;p&gt; &lt;label for="cgender"&gt;Gender&lt;/label&gt; * &lt;input type="radio" name="gender" value="Male" &lt;?php if($row['Gender']=='male'){echo 'checked';}?&gt;/&gt; Male &lt;input type="radio" name="gender" value="Female" &lt;?php if($row['Gender']=='female'){echo 'checked';}?&gt;/&gt; Female &lt;/td&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="curl"&gt;Title&lt;/label&gt; * &lt;select name="title" id="title" class="required"&gt; &lt;option value=""&gt;Please Select&lt;/option&gt; &lt;option value="Mr" &lt;?php if($row['Title']=='Mr'){echo 'selected';}?&gt;&gt;Mr&lt;/option&gt; &lt;option value="Ms" &lt;?php if($row['Title']=='Ms'){echo 'selected';}?&gt;&gt;Ms&lt;/option&gt; &lt;option value="Mrs" &lt;?php if($row['Title']=='Mrs'){echo 'selected';}?&gt;&gt;Mrs&lt;/option&gt; &lt;option value="Miss" &lt;?php if($row['Title']=='Miss'){echo 'selected';}?&gt;&gt;Miss&lt;/option&gt; &lt;option value="Other" &lt;?php if($row['Title']=='Other'){echo 'selected';}?&gt;&gt;Other&lt;/option&gt; &lt;/select&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="ccomment"&gt;First Name&lt;/label&gt; * &lt;input type="text" name="firstname" value="&lt;?php echo $row['First_Name']?&gt;" maxlength="50" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="cemail"&gt;Last Name&lt;/label&gt; * &lt;input id="cemail" type="text" name="lastname" value="&lt;?php echo $row['Last_Name']?&gt;" maxlength="75" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="ccomment"&gt;Address 1&lt;/label&gt;* &lt;input type="text" name="address1" value="&lt;?php echo $row['Address_Line_1']?&gt;" maxlength="50" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="ccomment"&gt;Address 2&lt;/label&gt; &lt;input type="text" name="address2" value="&lt;?php echo $row['Address_Line_2']?&gt;" maxlength="50" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="ccomment"&gt;City&lt;/label&gt;* &lt;input type="text" name="city" value="&lt;?php echo $row['City']?&gt;" maxlength="50" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="ccomment"&gt;Postcode&lt;/label&gt;* &lt;input type="text" name="postcode" value="&lt;?php echo $row['Postcode']?&gt;" maxlength= "10" /&gt; (eg LE5 5QE) &lt;/p&gt; &lt;p&gt; &lt;label for="ccomment"&gt;Contact No&lt;/label&gt;* &lt;input type="text" name="contactno" value="&lt;?php echo $row['Contact_No']?&gt;" maxlength= "12" /&gt; (eg 077448825723) &lt;/p&gt; &lt;p&gt; &lt;label for="ccomment"&gt;Email&lt;/label&gt;* &lt;input type="text" name="email" value="&lt;?php echo $row['Email']?&gt;" maxlength= "40"/&gt; (eg info@example.com) &lt;/p&gt; &lt;p&gt; &lt;label for="ccomment"&gt;Comment&lt;/label&gt; &lt;textarea rows="10" cols="30" name="note" maxlength= "500"&gt;&lt;?php echo $row['Additional_Comment']?&gt;&lt;/textarea&gt; &lt;/p&gt; &lt;p&gt; &lt;input class="submit" type="submit" value="Submit"/&gt; &lt;/p&gt; &lt;p&gt; &lt;a href='pv.php'&gt;Main Page&lt;/a&gt; &lt;/p&gt; &lt;/fieldset&gt; </code></pre> <p></p> <p>This is the code for printing out the data on the page:</p> <pre><code> if($_GET['action']=='comment'){ $form_action = 'comment_ok'; $id=$_GET['id']; $result = mysql_query("SELECT * FROM project_data WHERE id='$id'"); $row = mysql_fetch_array($result); echo'&lt;b&gt;'; echo $row['Date_Of_Birth']; echo '&amp;nbsp&amp;nbsp'; echo $row['Gender']; echo '&amp;nbsp&amp;nbsp'; echo $row['Title']; echo '&amp;nbsp&amp;nbsp'; echo $row['First_Name']; echo '&amp;nbsp&amp;nbsp'; echo $row['Last_Name']; echo '&amp;nbsp&amp;nbsp'; echo $row['Address_Line_1']; echo '&amp;nbsp&amp;nbsp'; echo $row['Address_Line_2']; echo '&amp;nbsp&amp;nbsp'; echo $row['City']; echo '&amp;nbsp&amp;nbsp'; echo $row['Postcode']; echo '&amp;nbsp&amp;nbsp'; echo $row['Contact_No']; echo '&amp;nbsp&amp;nbsp'; echo $row['Email']; echo '&amp;nbsp&amp;nbsp'; echo $row['Additional_Comment']; echo '&lt;/b&gt;'; } </code></pre> <p>and a snippet of the code I am using to send the id to the form:</p> <pre><code>echo "&lt;td&gt;&lt;a href='pv.php?action=edit&amp;id=" . $row['ID']."'&gt;Edit&lt;/a&gt;&amp;nbsp&amp;nbsp&lt;a href='pv.php?action=delete_ok&amp;id=" . $row['ID']."'&gt;Delete&lt;/a&gt;&amp;nbsp&amp;nbsp**&lt;a href='pv.php?action=comment&amp;id=" . $row['ID']."'&gt;Comment&lt;/a&gt;&lt;/td&gt;"**; echo "&lt;/tr&gt;"; </code></pre> <p>Anyone have any ideas?</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