Question: mysql.php DEFINE('DB_USER', 'wp_eatery'); DEFINE('DB_PSWD', 'password'); DEFINE('DB_HOST', 'localhost'); DEFINE('DB_NAME', 'wp_eatery'); $dbcon = mysqli_connect(DB_HOST, DB_USER, DB_PSWD, DB_NAME); if(!$dbcon){ die('error connecting to database'); } echo 'you have connected

mysql.php

DEFINE('DB_USER', 'wp_eatery');

DEFINE('DB_PSWD', 'password');

DEFINE('DB_HOST', 'localhost');

DEFINE('DB_NAME', 'wp_eatery');

$dbcon = mysqli_connect(DB_HOST, DB_USER, DB_PSWD, DB_NAME);

if(!$dbcon){

die('error connecting to database');

}

echo 'you have connected successfully'

?>

contract.php

include('mysql.php');

if($_SERVER["REQUEST_METHOD"] == "POST"){

$firstName = $_POST['firstName'];

$lastName = $_POST['lastName'];

$phoneNumber = $_POST['phoneNumber'];

$emailAddress = $_POST['emailAddress'];

$username = $_POST['username'];

$referral = $_POST['referral'];

$query = "INSERT INTO mailingList(firstName, lastName, phoneNumber, emailAddress, username, referral) VALUES ('$firstName', '$lastName', '$phoneNumber', '$emailAddress', '$username', '$referral')";

if( !mysqli_query($dbcon,$query)){

die('error');

}

}

I get you have connected successfully error

why is that, what is wrong in code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!