Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hello Can you help me I want to connect my database and table name admin on my PHP code but it throw some error I did not commit any sql query I just create table but it does not have function. Can you help me to create a proper table with the info below.

Here is the error:

 Warning: Undefined array key "fname" in C:\xampp\htdocs\VaccinationSystem\adduser.php on line 10

Warning: Undefined array key "mname" in C:\xampp\htdocs\VaccinationSystem\adduser.php on line 11

Warning: Undefined array key "gender" in C:\xampp\htdocs\VaccinationSystem\adduser.php on line 12

Can't Insert Data : Column count doesn't match value count at row 1

 

And here is my code 

<?php
    session_start();

    include 'database_connection.php';

    if($_POST['uname'] && $_POST['password'])
    {
        $name=$_POST['uname'];
        $lname = $_POST['lname'];
        $gen = $_POST['gender'];
        $city = $_POST['city'];
        $birth = $_POST['birth'];
        $type = $_POST['utype'];
        $email = $_POST['email'];
        $pass=$_POST['password'];

        if($type=='Admin')
            admin($name,$lname,$gen,$city,$birth,$email,$pass,$con);
        else
            parent($name,$lname,$gen,$city,$birth,$email,$pass,$con);
    }

    function admin($name,$lname,$gen,$city,$birth,$email,$pass,$con)
    {
        $query="INSERT INTO admin VALUES('$name','$lname','$gen','$city','$birth','$email','$pass')";
        
        $result=mysqli_query($con,$query);

        if(!$result)
        {
            die("<br>Can't Insert Data : " .mysqli_error());
        }
        echo "<script>alert('Admin Record Inserted..!!');window.location='index.php'</script>";
    }

    function parent($name,$lname,$gen,$city,$birth,$email,$pass,$con)
    {
        $query="INSERT INTO parent VALUES('$name','$lname','$gen','$city','$birth','$email','$pass')";
        
        $result=mysqli_query($con,$query);

        if(!$result)
        {
            die("<br>Can't Insert Data : " .mysqli_error());
        }
        echo "<script>alert('Parent Record Inserted..!!');window.location='index.php'</script>";
    }

?>

DServer. 127.0.0.1 » ODatabase: vaccination »
Table: admin
E Browse
A Structure
I SQL
Search
3i Insert
E Export
2 Import
E Privileges
Operations
O Tracking
E Triggers
A Table structure
E Relation view
# Name
Туре
Collation
Attributes Null Default Comments Extra Action
1 username
varchar(100) latin1_swedish_ci
No None
2 Change
Drop v More
2 lastname
varchar(100) latin1_swedish_ci
Yes NULL
2 Change
Drop - More
3 firstname
varchar(100) latin1_swedish_ci
Yes NULL
O Change
Drop - More
4 middlename varchar(100) latin1_swedish_ci
Yes NULL
Change
Drop - More
O 5 gender
varchar(8)
latin1_swedish_ci
No None
O Change
Drop v More
6 birth
date
Yes NULL
O Change
Drop
v More
O 7 category
varchar(100) latin1_swedish_ci
Yes NULL
O Change
Drop - More
8 email
varchar(500) latin1_swedish_ci
Yes NULL
O Change
Drop - More
O 9 pass
varchar(500) latin1_swedish_ci
Yes NULL
O Change
Drop v More
O Check all
With selected:
I Browse
O Change
O Drop
O Primary
U Unique
個Index
Is Spatial
T Fulltext
Add to central columns
A Remove from central columns
Transcribed Image Text:DServer. 127.0.0.1 » ODatabase: vaccination » Table: admin E Browse A Structure I SQL Search 3i Insert E Export 2 Import E Privileges Operations O Tracking E Triggers A Table structure E Relation view # Name Туре Collation Attributes Null Default Comments Extra Action 1 username varchar(100) latin1_swedish_ci No None 2 Change Drop v More 2 lastname varchar(100) latin1_swedish_ci Yes NULL 2 Change Drop - More 3 firstname varchar(100) latin1_swedish_ci Yes NULL O Change Drop - More 4 middlename varchar(100) latin1_swedish_ci Yes NULL Change Drop - More O 5 gender varchar(8) latin1_swedish_ci No None O Change Drop v More 6 birth date Yes NULL O Change Drop v More O 7 category varchar(100) latin1_swedish_ci Yes NULL O Change Drop - More 8 email varchar(500) latin1_swedish_ci Yes NULL O Change Drop - More O 9 pass varchar(500) latin1_swedish_ci Yes NULL O Change Drop v More O Check all With selected: I Browse O Change O Drop O Primary U Unique 個Index Is Spatial T Fulltext Add to central columns A Remove from central columns
Vaccination Management
Username
Enter Username
Last Name
Enter Last Name
First Name
Enter First Name
Middle Name*
Enter Middle Name
Gender
O Male o Female
Birth Date *
dd/ nn/ yyy
You are a"
Select an Option
Email Address"
Enter email address
Password"
Enter Password
Register
Already have an Account? Login
Transcribed Image Text:Vaccination Management Username Enter Username Last Name Enter Last Name First Name Enter First Name Middle Name* Enter Middle Name Gender O Male o Female Birth Date * dd/ nn/ yyy You are a" Select an Option Email Address" Enter email address Password" Enter Password Register Already have an Account? Login
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Hyperlinks
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education