Results 1 to 1 of 1

Thread: select row from database, use the fields in a html form for user to update

  1. #1
    Join Date
    May 2009
    Location
    Greensboro, GA
    Posts
    163
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default select row from database, use the fields in a html form for user to update

    I need help with the following. User inputs his fname and lname. Program finds that record in a MySQL database.
    Display the data fields on a html form and allow the user to update any of the fields. User then hits submit button and changes are made and database is closed.

    I'm new to PDO and am having a hard time understanding it. Thanks for any help

    <?php
    $fname = filter_input(INPUT_POST, "fname"); // from previous html program
    $lname = filter_input(INPUT_POST, "lname"); // from previous html program

    try
    {
    $connect = new PDO('mysql:host=localhost;dbname=xxxxxx', "xxxxxx", "xxxxxx");
    echo 'Connected to database<br />';
    $connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    $sql = "SELECT * FROM contacts WHERE firstname = '$fname' && lastname = '$lname' ";


    $connect = null;
    }

    catch(PDOException $e)
    {
    echo 'ERROR: ' . $e->getMessage();
    }
    ?>
    Last edited by mcolton; 06-16-2014 at 03:38 PM.

Similar Threads

  1. Replies: 1
    Last Post: 08-09-2011, 06:29 AM
  2. How to make the form generate fields for user input
    By kunyomi in forum Looking for such a script or service
    Replies: 0
    Last Post: 09-06-2008, 06:05 AM
  3. Select/unselect all checkbox fields using pure Javascript and HTML
    By m3andros in forum Submit a DHTML or CSS code
    Replies: 1
    Last Post: 02-20-2008, 03:16 AM
  4. Dynamic <select> form fields - IE sudden crash
    By Aaron in forum JavaScript
    Replies: 7
    Last Post: 08-20-2007, 07:17 AM
  5. Replies: 5
    Last Post: 05-22-2007, 05:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •