Jump to content

So i don't know if im posting in the right parent topic, please excuse me if i am.

But i need some help when it comes to this php error i,m getting much information is needed please and thank you, the error i,m getting is 

PHP Notice:  Undefined variable: servername in C:\inetpub\wwwroot\Admin5\WOconf.php on line 11

 

My page code bellow

 

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


// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}


$clientname = $_POST['client_name'];
$accountnumber = $_POST['account_number'];
$contactnumber = $_POST['contact_number'];
$address = $_POST['address'];
//$servicetype = $_POST['service_type'];
//$serialnumber = $_POST['serial_number'];
//$brand = $_POST['d_brand'];
$devicetype = $_POST['device_type'];
$devicemodel = $_POST['device_model'];
$loggeddate = $_POST['logged_date'];
$requesteddate = $_POST['requested_date'];
$cost = $_POST['cost'];
$techID = $_POST['techID'];
$problemcomment = $_POST['problem_comment'];
$email = $_POST['user_email'];

 


$sql = "INSERT INTO work_orders (clientname, accountnumber, contactnumber, address, devicetype,  devicemodel, loggeddate, requesteddate, cost, techID, problemcomment, email)
VALUES ('$clientname', '$accountnumber', '$contactnumber', '$address','$devicetype', '$devicemodel', '$loggeddate', '$requesteddate', '$cost', '$techID', '$problemcomment', '$email')";

if (mysqli_query($conn, $sql)) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}

mysqli_close($conn);
?>

Link to comment
https://linustechtips.com/topic/662313-php/
Share on other sites

Link to post
Share on other sites

This is as an exercise right? Not for an actual application? 

CPU: Intel Core i5 4690K @ 4.6Ghz CPU Cooler: Noctua NH-D15 GPU: GTX 1070 TI RAM: Crucial Ballistix Tactical 16GB (4x4) Mobo: ASUS Z97-PRO(Wi-Fi ac) PSU: Corsair RM Series RM750 Case: Fractal Design Define R4 no window

Link to comment
https://linustechtips.com/topic/662313-php/#findComment-8559564
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×