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 8585827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:09:47+00:00 2026-06-11T22:09:47+00:00

I am making a php page that retrieves data from a database table and

  • 0

I am making a php page that retrieves data from a database table and putting it in a table for the user to see via MySQLi commands.

I was wondering how I should approach the reverse situation. I want the user to be able to enter in information into textboxes and the click a button at the bottom of the page called ‘save’ which will prompt the user “are you sure” before saving to the database. If the user clicks ‘yes’, then the new entry is inserted into the database.

I have the following code to create the labels and textboxes:

<FORM>
ID: <input type="text" name="id"><br />
NM: <input type="text" name="nm"><br />
Company: <input type="text" name="company"><br />
Address: <input type="text" name="address"><br />
City: <input type="text" name="city"><br />
Zip: <input type="text" name="zip"><br />
State: <input type="text" name="state"><br />
Phone: <input type="text" name="phone"><br />
Website: <input type="text" name="web_site"><br />
</FORM>

However, when it comes to the ‘save’ button, I can implement the button just fine, but how would I go about saving the information entered into the database?

My initial thought process was to find the values that the user entered. I’m new to PHP and WEB dev in general, but I need to know how to get the value of the text in the textbox. Would I have to sift all the values through via the PHP Post method?

Once I have the information the user wants to enter, I was thinking maybe MySQLi has an insert function, which I found here, http://php.net/manual/en/mysqli.insert-id.php. Then it’s just a quick insert and it’s in the database after the user gives the ‘yes’ at the prompt.

Do I have the right idea in mind? Is there a more efficient way to do this?

Any help is greatly appreciated. I’ve looked around for problems and solutions similar to the ones related to my scenario but there were none. =(

Thanks!

EDIT:

Here is the code I have on the agentprocess.php that the action form sends the information to:

<?php
$agent_nm = $_POST['nm']; // gather all the variables
$company = $_POST['company'];
$address = $_POST['address'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$state = $_POST['state'];
$phone = $_POST['phone'];
$web_site = $_POST['web_site'];
$batch_id = $_POST['batch_id']; // added batch id
//connect
$conn = new mysqli('local', 'admin', 'pass', 'DB');
    if(mysqli_connect_errno()) {
        exit('Connect failed: '. mysqli_connect_error());
    }
//generate the query (doesn't add id because id is autoincremented)
$query = "INSERT INTO t_agent VALUES (NULL, " . $agent_nm . ", " . $company . ", " . $address . ", " . $city . ", " . $zip . ", " . $state . ", " . $phone . ", " . $web_site . ", " . $batch_id . ")";

//insert and close.
mysqli_query($conn, $query);
mysqli_close($conn);

Despite the code here, I’ve queried the table and the new entry is not there. Am I missing something here?

Thanks in advance!

  • 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-11T22:09:48+00:00Added an answer on June 11, 2026 at 10:09 pm

    Very simple example, added the label tag to the labels for your input and put it inside of a form.

    <form method="post" action="process.php" id="myForm" name="myForm" >
    <label for="ID">ID</label>:  <input type="text" name="ID" /><br />
    <label for="nm">NM:</label> <input type="text" name="nm"><br />
    <label for="company">Company:</label> <input type="text" name="company"><br />
    <label for="address">Address:</label> <input type="text" name="address"><br />
    <label for="city">City</label>: <input type="text" name="city"><br />
    <label for="zip">Zip</label>: <input type="text" name="zip"><br />
    <label for="state">State</label>: <input type="text" name="state"><br />
    <label for="phone">Phone</label>: <input type="text" name="phone"><br />
    <label for="web_site">Website</label>: <input type="text" name="web_site"><br />
    <input type="submit" name="submit" />// this is your submit button
    </form>
    

    On the process.php page

    //get your inputs from the form
    $ID = $_POST['ID']; 
    //do the same for each of the text inputs
    

    Then you can use mysqli as you described to insert the values into your database, feel free to comment if you need any help with the mysqli part of the question, I didn’t include it here since you had the link posted in the original question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php page that recalls data from an SQL table, and then
I am making a page that accepts post data from any number of pages
I'm making a php page to draw information from a mysql database, and before
I'm making an profile page in PHP, How to make an url like domain.com/profile.php?user=admin
I am making a jQuery Ajax form submit to a PHP page that I
I have a PHP page that gets its content by making an HTTP request
I have a MSSQL database table I'm accessing on a PHP page. I'm displaying
I am making a php based application. When two users are logged in from
I'm making a php file that will run an event after five minutes have
I'm making a PHP image script that will create circles at a given radius.

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.