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

  • Home
  • SEARCH
  • 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 3486182
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:59:53+00:00 2026-05-18T10:59:53+00:00

I have this HTML form page: form1.html <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd

  • 0

I have this HTML form page:

form1.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"
    >
<html lang="en">
<head>
    <title>Insert Your Details</title>
</head>
<body>
    <h3> Insert Your Name</h3>
    <form action="form1.php" method="post">
    First Name: <input type="text" name="fname"><br>
       Last Name: <input type="text" name="lname"><br>
    E-mail:  <input type="text" name="mail"><br>
            <input type="Submit" value="Submit" name="Submit">
    </form>
</body>
</html>

That forwards to this PHP script to handle the form:

form1.php

<?php
$connection = mysql_connect("localhost","root","")
or die ("Couldn't Connect To Server");
$db = mysql_select_db("db1", $connection)
or die ("Couldn't Select Database");
$query = "CREATE TABLE IF NOT EXISTS table1 (Name VARCHAR(20))";
$result = mysql_query($query)
or die ("Query Failed: " . mysql_error());
$query = "INSERT INTO table1 (fname) VALUES ('".$_POST[fname]."')"; 
$result = mysql_query($query)
or die ("Query Failed: " . mysql_error());
$query = "INSERT INTO table1 (lname) VALUES ('".$_POST[lname]."')"; 
$result = mysql_query($query)
or die ("Query Failed: " . mysql_error());
$query = "INSERT INTO table1 (mail) VALUES ('".$_POST[mail]."')"; 
$result = mysql_query($query)
or die ("Query Failed: " . mysql_error());
$query = "SELECT * FROM table1";
$result = mysql_query($query)
or die ("Query Failed: " . mysql_error());
    echo "<TABLE BORDER = '1'>";
    echo "<TR>";
    echo "<TH>First Name</TH>";
    echo "</TR>";    
while ($row = mysql_fetch_array($result))
     {
echo "<TR>";
echo "<TD>", $row['fname'], "</TD><TD>",
$row['lname'], "</TD><TD>",
$row['mail'], "</TD>";
echo "</TR>";  
     }
    echo "</TABLE>";
    mysql_close($connection);
?>

Now, for some reason, when I insert these values:

First Name: Wide
Last Name: Blade

I get lots of NULL values in the MySQL Table.

So my question is: How do I insert all of these values in the same record, so I don’t get these NULL records in the table?

  • 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-05-18T10:59:53+00:00Added an answer on May 18, 2026 at 10:59 am

    insert adds a new record (row) into the database – you only want to execute an insert statement once.

    INSERT INTO table1(fname, lname, mail) VALUES ($fname, $lname, $mail);
    

    UPDATE: Also – you need to protect against sql injection, either by escaping input, or using prepared statements.

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

Sidebar

Related Questions

HTML Code <%@ Page Language=C# AutoEventWireup=true CodeBehind=WebForm1.aspx.cs Inherits=WebApplication1.WebForm1 %> <!DOCTYPE html PUBLIC -//W3C//DTD XHTML
I have a html form with the data by this post method 'form id='form1'
All, I have this page, <%@ Page Language=C# AutoEventWireup=true CodeBehind=priceLists.aspx.cs Inherits=PriceWorx.priceLists %> <!DOCTYPE html
I have an aspx page with 1 table containing 2 rows: <!DOCTYPE html PUBLIC
I have this html form which has options: <tr> <td width=30 height=35><font size=3>*List:</td> <td
I have this HTML dropdown: <form> <input type=text id=realtxt onkeyup=searchSel()> <select id=select name=basic-combo size=1>
I have this HTML: <form action='uploadhandle.php' method='POST' enctype=multipart/form-data> <input type='file' class='fileinput' id='photo1' name='photo1'> <input
i have this html <ul> <li><form action=# name=formName></li> <li><input type=text name=someName /></li> <li><input type=text
In my ASP MVC 3 application, I have this form @using (Html.BeginForm()) { <input
I have this form for inputting the birthday in html. But I only have

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.