Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7718515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:11:08+00:00 2026-06-01T03:11:08+00:00

I was wondering what the syntax was in PHP to update a row in

  • 0

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.

This is the code I have for the query:

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);
   }

This is for the fields:

    <div id="header">UPDATE USER INFO</div>
    <form id="testform" name="testform" method="post" action="" >
        <p> <label for="ifirstname">First Name:</label> 
          <input name="ifirstname" type="text" id="ifirstname"/>
      </p>
        <p> <label for="ilastname">Last Name:</label>
          <input name="ilastname" type="text" id="ilastname"/>
      </p>
        <p> <label for="iemail">E-Mail:</label>
            <input name="iemail" type="text" id="iemail"/>
        </p>
        <p> 
            <label for="ipassword">Password:</label>
          <input name="ipassword" type="password" id="ipassword"/>
      </p>
        <p> 
            <label for="iconfpass">Confirm Password:</label>
          <input name="iconfpass" type="password" id="iconfpass"/>
      </p>
        <p> 
            <input type="submit" name="save" value="Register"/>
        </p>
    </form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:11:09+00:00Added an answer on June 1, 2026 at 3:11 am

    I think it must be like this. Also make user to write old password when changing data for security reason. Also dont forget to filter your data before using in query to avoid sql injection attacks

    $query="UPDATE project.customer 
            SET (FirstName,LastName,Email,Password) = 
            ('$firstname','$lastname','$email','$password')
            WHERE UserName= '$1' and Password = '$oldpassword'";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a PHP application that manages some LDAP entries. I have one page
Now that we have tremendous functionality thanks to LINQ, I'm wondering which syntax is
I'm just wondering where this syntax documented: 1 > 2 || raise(error) I have
I noticed that fckeditor tries to fix bad html syntax. I was wondering if
I was wondering if there is a python cognate to PHP's crypt() function that
I've an issue, which is about php syntax/mysql in drupal: Let's say that userA
i was wondering why there is no $parent->function(); syntax in php, but instead we
I am wondering if JavaScript has an enhanced for loop syntax that allows you
I was wondering if there was a tag that auto-highlights the syntax of HTML
i am wondering if the basic link_to syntax is completely broken in current rails3

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.