Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your query need to be modified as bellow.</p> <pre><code>mysql_query("UPDATE user SET username = '" .$_POST[nusername] . "' , password = ' " .$_POST[npassword] . "', name = '" . $_POST[nname] . " ', surname = '" . $_POST[nsurname]', role = '$_POST[nrole] . "' WHERE username='" . $_POST[us] . "'"); </code></pre> <p>Also you are open for the SQL Injection attacks. So you better use <code>mysql_real_escape_string()</code> function as well.</p> <p><a href="http://php.net/manual/en/function.mysql-real-escape-string.php" rel="nofollow">http://php.net/manual/en/function.mysql-real-escape-string.php</a></p> <p>Also I would like to suggest you few steps to over come this kind of issue. This is just an example.</p> <p>Step 1 </p> <p>When you need a SQL statement in your PHP code. You better write it in your MySQL tool first and test it with sample values.</p> <pre><code>UPDATE subscriber SET Subscriber_Name = 'Test' , Email = 'test@test.com' WHERE Subscriber_ID = '2' ; </code></pre> <p>Step 2:</p> <p>If the query works fine then copy it to php. And replace values with <code>mysql_real_escape_string()</code> support.</p> <pre><code>$sql = "UPDATE subscriber SET Subscriber_Name = '" . mysql_real_escape_string($_POST['name']) . "' , Email = '" . mysql_real_escape_string($_POST['email']) . "' WHERE Subscriber_ID = '" . mysql_real_escape_string($_POST['id']) . "' ;" </code></pre> <p>Step 3:</p> <p>Execute your query.</p> <pre><code>$result = mysql_query($sql); </code></pre> <p>Step 4 : </p> <p>You can see any if there any errors available.</p> <pre><code>echo mysql_error(); </code></pre> <p><strong>EDIT:</strong></p> <p>Answer for you Question 2 "How can I achieve already filled boxes in the html file, with the right values, if I choose a certain username?" could be like this.</p> <p>First you have to write a select statement and get whatever data you want. Ex.</p> <pre><code>$sql = "SELECT user.username, user.name, user.surname , user.role FROM USER WHERE user.username = '" . mysql_real_escape_string($_POST[us]) . "'"; $result = mysql_query($sql, $link) or die(mysql_error()); $row = mysql_fetch_assoc($result); </code></pre> <p>Then put your HTML code. Ex:</p> <pre><code>&lt;form action="edit_user.php" method="post"&gt; &lt;p&gt;Username&lt;input type="text"name="nusername" size="40" value="&lt;?php echo $row['username'];?&gt;"&gt;&lt;/p&gt; &lt;p&gt;Password&lt;input type="password"name="npassword" size="40"&gt;&lt;/p&gt; &lt;p&gt;Name&lt;input type="text"name="nname" size="40" value="&lt;?php echo $row['name'];?&gt;"&gt;&lt;/p&gt; &lt;p&gt;Surname&lt;input type="text"name="nsurname" size="40" value="&lt;?php echo $row['surname'];?&gt;"&gt;&lt;/p&gt; &lt;p&gt;Role&lt;input type="text"name="nrole" size="40" value="&lt;?php echo $row['role'];?&gt;"&gt;&lt;/p&gt; &lt;p&gt;&lt;input type="submit&gt;&lt;/p&gt; &lt;/form&gt; </code></pre>
    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.
    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