Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

make a php page doing the following that will correspond with a mysql database.

ID: 3730493 • Letter: M

Question

make a php page doing the following that will correspond with a mysql database. what is the working code for all this? also note everything i need to do to get it working. I POSted this before and it was done wrong so do not copy and paste that.

ALSO WHAT WOULD THE MYSQL TABLE LOOK LIKE?

This assignment you will be making a form that will do one of three things in a database

-          It will add a record

-          It will update a record

-          It will search for a record

Your database will contain a table for keeping a record of all your friends and family and should contain:

First name

Last name

Phone number

Address

City

State

Zip

Birthdate

Username

Password

The sex of the person

And the relationship

You should also keep a primary key for the user

You will then have two pages a friends and family form page and a results page

The form will ask the user to enter the information and then choose to either

Create a new record

Update and existing record

Search for a record

The results page will display the information that they are requesting with either adding a record, updating it or displaying the results of a record.

Expert Answer

Explanation / Answer

Program

<?php

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "firstdb"; //<--Your DataBase Name

$con = mysqli_connect("$servername","$username","$password","$dbname") or die("Connection failed");

echo "Connected";

if (mysqli_connect()) { //Connection Check

echo " Hello";

$fname = $_POST("fname"); //Fetching Data From User

$lname = $_POST("lname"); //Fetching Data From User

$no = $_POST("no"); //Fetching Data From User

$add = $_POST("add"); //Fetching Data From User

$city = $_POST("city"); //Fetching Data From User

$state = $_POST("state"); //Fetching Data From User

$zip = $_POST("zip"); //Fetching Data From User

$birthdate = $_POST("birthdate");//Fetching Data From User

$uname = $_POST("uname"); //Fetching Data From User

$pass = $_POST("pass"); //Fetching Data From User

$sex = $_POST("sex"); //Fetching Data From User

$relation = $_POST("relation"); //Fetching Data From User

if (mysql_query($con,$sql)) //Executing Query

{

if (isset($_POST['submit']))

{

$sql = "INSERT INTO user VALUES('$fname','$lname','$no','$add','$city','$state','$zip','$birthdate','$uname','$pass','$sex','$relation')";

//Query

//Same with other queries

}

else

{

echo "error.".$sql."<br>".mysql_error($con);

}

}

}

mysqli_close($con);

?>