0

A little background info: I am using Netbeans IDE 7.3, I have an SQL server running and I am trying to create a html application to insert data into the connected sql server/database structure.

I hope that made enough sense to see what I'm asking.

My question: I simply want to create a page on the HTML application which asks a user to enter information about a person such as their first name, last name, address, phone number, etc.

I want it to appear in this manner to the user:

First Name: [text area]

Last Name: [text area]

etc....

Then at bottom I want a submit button. At this point the information in the fields above would be sent to the "person" table in the database with each column/attribute filled with the appropriate information above.

A new row is created in the table at this point.

How can this be done? Examples of code would be great if you know of any.

Thanks in advance.

2 Answers 2

4

That cannot be done with HTML alone, you'll need a scripting language like PHP to do the job.

Sign up to request clarification or add additional context in comments.

1 Comment

Just to clarify, you need a server-side scripting language. You can build the form in HTML, then submit it with HTML or javascript, but that only gets the data to the web-server. SQL servers are their own piece of software and do not directly communicate with a client (browser). So you need PHP, ASP, JSP, or some similar server-side technology to handle connecting to the database itself.
0

Build a form and use PHP to process it (or some other scripting language, I use PHP):

<form method="post" action="path_to_script.php">
    <label for="username">Username:</label>
    <input type="text" name="username" />
</form>

PHP:

    if(isset($_POST['username'])){
        $username = $_POST['username'];
    }

    // Use $username as a parameter in your query

$stmt = $yourDatabaseConnection->prepare("INSERT INTO yourTableHere (usernameColumn) VALUES (:username)");
$stmt->bindParam(':username', $username);

$stmt->execute();

Learn more about prepared statements here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.