Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating a Row in PostgreSQL with PHP
    primarykey
    data
    text
    <p>I was wondering what the syntax was in PHP to update a row in a PostgreSQL database. I have made a login page that checks a UserName and Password from a database, then it goes to a page where it displays all the user info from the database for that user name. I am trying to allow the user to change some of the columns, like password, name, etc. So I added another page that has fields for each of the columns I want to change.</p> <p>This is the code I have for the query:</p> <pre><code>if(array_key_exists('save',$_POST)) { $firstname=$_POST['ifirstname']; $lastname=$_POST['ilastname']; $email=$_POST['iemail']; $password=$_POST['ipassword']; $conn_string='host=#### port=#### dbname=###### user=####### password=######'; $dbconn=pg_connect($conn_string) or die('Connection failed'); $query="UPDATE project.customer SET FirstName='$firstname', LastName='$lastname',Email='$email',Password='$password') WHERE UserName=$1"; $result=pg_query($dbconn,$query); $row_count= pg_num_rows($result); pg_free_result($result); pg_close($dbconn); } </code></pre> <p>This is for the fields:</p> <pre><code> &lt;div id="header"&gt;UPDATE USER INFO&lt;/div&gt; &lt;form id="testform" name="testform" method="post" action="" &gt; &lt;p&gt; &lt;label for="ifirstname"&gt;First Name:&lt;/label&gt; &lt;input name="ifirstname" type="text" id="ifirstname"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="ilastname"&gt;Last Name:&lt;/label&gt; &lt;input name="ilastname" type="text" id="ilastname"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="iemail"&gt;E-Mail:&lt;/label&gt; &lt;input name="iemail" type="text" id="iemail"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="ipassword"&gt;Password:&lt;/label&gt; &lt;input name="ipassword" type="password" id="ipassword"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="iconfpass"&gt;Confirm Password:&lt;/label&gt; &lt;input name="iconfpass" type="password" id="iconfpass"/&gt; &lt;/p&gt; &lt;p&gt; &lt;input type="submit" name="save" value="Register"/&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.
 

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