Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can't get functions to work. Should be able to verify if user exists and then successfully add a new user with this Ajax/Jquery program. 1.

Can't get functions to work. Should be able to verify if user exists and then successfully add a new user with this Ajax/Jquery program.

1. Enter at least three rows of data into

EMAIL (40)

ADDRESS(100) PHONE VARCHAR(10)

2. Create a HTML form that contains three input fields and an update button. After user enters an email in the email field, the form auto populates other fields. Display a message asks if user needs to update the information. If so, use can update the information (After user hits the Update button, display a message saying your information has been updated. Keep other parts on the screen as it is) . Do all these using AJAX/JQuery.

--------index.html-------

Coulter A9: Ajax/JQuery

User Profile


Email Phone Address

---------lookup.php--------

$servername = "localhost"; $username = "icoolsho_dcoulte"; $password = "$!980-49-2554"; $dbname = "icoolsho_dcoulter";

?>

------update.php-----

include 'db.php';

// Get the data that's being written to the database.

$post_data = json_decode(file_get_contents('php://input'), true);

$email = $post_data['email'];

$address = $post_data['address'];

$phone = $post_data['phone'];

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die(json_encode(array("error" => "database fail: " . $conn->connect_error)));

}

// Delete the old record from the database if there was one

$sql = "DELETE FROM Assignment9 WHERE email='" . $email . "'";

if ($conn->query($sql) != TRUE) {

die(json_encode(array("error" => "could not delete old record: " . $conn->error)));

}

// Insert the new record into the database

$sql = "INSERT INTO Assignment9 (email, address, phone) VALUES ( "

. "'" . $email . "',"

. "'" . $address . "',"

. "'" . $phone . "')";

if ($conn->query($sql) === TRUE) {

die(json_encode(array("error" => "Update successful!")));

} else {

die(json_encode(array("error" => "could not update record: " . $conn->error)));

}

?>

------db.php-------

$servername = ""; $username = ""; $password = ""; $dbname = "";

?>

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

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

3031001257, 978-3031001253

More Books

Students also viewed these Databases questions

Question

=+39-1 Explain how hormones influence human sexual motivation.

Answered: 1 week ago

Question

Design a job advertisement.

Answered: 1 week ago