Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PHP Program : I received the following error message(below) when I tried to run the insertRecord2.php page. How to fix this error? Notice: Undefined index:

PHP Program: I received the following error message(below) when I tried to run the insertRecord2.php page. How to fix this error?

Notice: Undefined index: fname in C:\xampp\htdocs\PetShop.com\php\insertRecord2.php on line 5 Notice: Undefined index: lname in C:\xampp\htdocs\PetShop.com\php\insertRecord2.php on line 6 Notice: Undefined index: email in C:\xampp\htdocs\PetShop.com\php\insertRecord2.php on line 7 Notice: Undefined index: phone in C:\xampp\htdocs\PetShop.com\php\insertRecord2.php on line 8 Notice: Undefined index: message in C:\xampp\htdocs\PetShop.com\php\insertRecord2.php on line 9

Here is my program.

insertRecord2.php

//connect to the petshop22 database

include "../../db_connect.php";

$first = $_POST['fname'];

$last = $_POST['lname'];

$email = $_POST['email'];

$phone = $_POST['phone'];

$message = $_POST['message'];

//sql insert command

$sql = "

INSERT INTO message(fname, lname, email, phone, message)

VALUES('$first', '$last', '$email', '$phone', '$message')";

//run query and display results

if (mysqli_query($db_connection, $sql)){

echo" New Record created successfully";

}else{

echo "Error: " . $sql . " " . mysqli_error($db_connection);

}

//close the database

mysqli_close($db_connection);

?>

Back to Home

Back to Message Form

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions