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
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started