$dbname = "userdata"; $errors = ""; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $first_name = $_POST["user_f_name"]; $last_name = $_POST["user_l_name"]; $email = $_POST["u_email"]; $donor_acceptor = $_POST["u_donor"]; $password = $_POST["u_password"]; $address = $_POST["u_address"]; $contact_number = $_POST["u_contact_no"]; if (!validateContact($contact_number)) { //echo "<script> alert('enter contact number in the given format') </script>"; } if (!validateName($first_name)) { echo "<script> alert('enter valid name') </script>"; } //ask for correct input $sql = "insert into mh_user_data(user_first_name, user_last_name, user_email, user_donor, user_password, user_address, user_contact_number) values ('{$first_name}','{$last_name}', '{$email}', '{$donor_acceptor}','{$password}', '{$address}', '{$contact_number}') "; $result = $conn->query($sql); if ($conn->query($sql) === TRUE) { echo "New record created successfully. Last inserted ID is: " . $conn->insert_id; } else { echo "Error: " . $sql . "<br>" . $conn->error; } $conn->close(); }
$contact->con_first_name = $rowValues[1]; $contact->con_middle_name = $rowValues[2]; $contact->con_last_name = $rowValues[3]; $contact->con_email = $rowValues[4]; $contact->con_phone_no = $rowValues[5]; $contact->con_fax_no = $rowValues[6]; $contact->src_con_id = $rowValues[7]; $contact->con_zipcode = $rowValues[8]; $contact->con_country = $rowValues[9]; $contact->con_created_date = $rowValues[10]; if (is_null($contact->con_created_date) || empty($contact->con_created_date)) { $contact->con_created_date = date("m/d/y"); } $contact->src_id = $_SESSION['username']; $contact->con_created_by = $_SESSION['username']; if (validateContact($contact)) { array_push($contacts, $contact); } else { $recordsInvalid = true; } } } if (!empty($contacts)) { $DBResource = getDBConnection(); insertData($DBResource, $contacts); closeDBConnection($DBResource); runMatching($contacts); if ($recordsInvalid) { echo "File uploaded successfully (discarding invalid data)"; } else { echo "File uploaded successfully.";