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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:14:47+00:00 2026-06-18T16:14:47+00:00

I am doing an exercise that extracts data from a form, then inputs the

  • 0

I am doing an exercise that extracts data from a form, then inputs the data into a table in the database.

I have total of 6 fields on the form, but only first 3 fields are registered in the table.

Data type in the table

first_name  varchar(30)
last_name   varchar(30)
pd          varchar(10)
b_month     varchar(2)
b_day       varchar(2)
b_year      varchar(4)

HTML Code for the form

    <form action="handle_reg2.php" method="post">
    <p>first name: <input type="text" name="first_name" size="20" /></p>
    <p>last name: <input type="text" name="last_name" size="20" /></p>
    <p>Password: <input type="password" name="pwd" size="10" /></p>
    <p>confirm password: <input type="password" name="confirm" size="10" /></p>
     <select name="month">
    <option value="">Month</option>
    <option value="1">January</option>
     </select> 
     <select name="day">
    <option value="">Day</option>
    <option value="1">1</option>
  </select>
  <input type="text" name="year" value="yyyy" size="4"/>
  </p>

PHP Code to handle the form data

$db_connect = mysql_connect("localhost", "$db_user", "$db_pass");
 $sql = "insert into reg_data (first_name, last_name, pd, b_month, b_day, b_year) 
 values 
 ('$first_name', '$last_name', '$password', '$b_month',
 '$b_day', '$b_year')";

$insert_data = mysql_query ($sql, $db_connect );

Please take a look at my code fragment and advise me what is the cause and how to resolve the issue.

  • 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-18T16:14:48+00:00Added an answer on June 18, 2026 at 4:14 pm

    You altered the name of the variables …
    EG

    $byear = $_POST['year'];
    

    TO

    $b_year
    

    EDIT:

    You’ve changed the Q and removed the code showing how you named the incoming variable $byear and then tried to reference it as $b_year.

    Stick to a naming convention and you’ll have less of these daft errors. EG from your form to your db:

    <input type =text name="b_year" />
    

    THEN

    $b_year = (int)$_POST['b_year'];
    

    THEN

    "insert into mytable (b_year) values ($b_year )";
    

    Except of course you will have listed to what everyone has said and be using prepared statements or have found another way to protect your db.

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

Sidebar

Related Questions

I'm doing exercise #9 from http://openbookproject.net/thinkcs/python/english2e/ch09.html and have ran into something that doesn't make
There's a little script that grabs a bunch of data from a database, and
I am doing some exercise from a book and have some problems with the
i am doing an exercise from Orielly book, and they used that Twitter package
I have a question about map and delegate. I am doing a exercise from
Good evening. I am doing a basic exercise to insert data into an Access
Hey all. I'm doing a linked list exercise that involves dynamic memory allocation, pointers,
Today I was doing the thread ring exercise from the Programming Erlang book and
im doing an exercise where i have to make a parking lot application. The
I'm doing a book exercise that says to write a program that generates psuedorandom

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.