HTML/PHP Won’t add to MySQL

I’m running into an issue with my code where the PHP portion of it works, the mysql portion works, and I’m pretty sure the html portion works but I can’t put it all together for some reason. If I had to take a guess the html is wrong or I’m missing something.

Everything in the processUser function works if I put in hard inputs and not ones via the html form. Does anyone have any idea? Sorry if this is a stupid fix any help is appreciated thank you!

<!DOCTYPE html>
<html>
        <head>
        </head>

<body>
        <h1> Application Form</h1>
                <h2> Requirements </h2>
                        <p>Please include name to make it easier to add (Not saved once admitted)</p>
                        <p>Password needs the following: 10+ Char, 1 Special Char (Include one of the following !#$%^&*_+|:,.?")</p>

<form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
  Username: <input type="text" name="fName" title="Enter your desired username (No special Chars)">
  Email: <input type="email" name="fEmail" title="Enter desired Email">
  Password: <input type="password" name="fPass" title="Enter desired password">
  Extra Info: <input type="text" name="fExtra">
  <input type="submit">
</form>

<?php
        require_once "connect.php";
        require_once "sanitize.php";
        require_once "log.php";
        require_once "goat.php";



if ($_SERVER["REQUEST_METHOD"] == "POST") {
  // Configure file for MySQL change to call a function



        $name = htmlspecialchars($_POST['fName']);
        $email = htmlspecialchars($_POST['fEmail']);
        $pass = htmlspecialchars($_POST['fPass']);
        $extra = htmlspecialchars($_POST['fExtra']);


        processUser($_POST['fName'], $_POST['fEmail'], $_POST['fPass'], $_POST['fExtra']);
}

function processUser($name, $email, $pass, $extra){

        // Implement checks from sanitatize.php here
        $usrCheck = sanitizeUser($name,1);
        $emailCheck = sanitizeEmail($email,1);
        $passCheck = sanitizePass($pass, $name);


        if($usrCheck && $emailCheck && $passCheck){
                // Add Salting for password
                $pass = salty($pass);

                $filePath = "../../Issues/AboutUser.txt";
                if (file_exists($filePath) && is_readable($filePath)) {
                        $tmpFile = fopen($filePath, "a");

                        if ($tmpFile){
                                $fileSize = count(file($filePath));
                                $text = $fileSize+1 . ")" . $name . " " . $email . " " . $extra . "n";
                                fwrite($tmpFile, $text);
                                fclose($tmpFile);

                                logs("Successfully added" . $name . "to the list. Waiting to be added");

                                echo '<p> Added user </p>';
                                echo '<div class="success-message">Successfuly added.You will be reached out to when added or message Cam for assistance</div>';

                                //Add them to the database
                                addInfo($name,$email,$pass,0,0);

                        }else{echo '<p> failed check 5 </p>';} //'<div class="error-message"Failed to add reach out to Cam</div>';}
                }else{echo '<p> Failed check 4 </p>';} //'<div class="error-message"Failed to read file reach out to Cam</div>';}
        }
        else{
                if(!$usrCheck){ echo  '<p>Failed check 1 </p>';} //'<div class="error-message"Failed Username check, try again</div>';}
                if(!$emailCheck){ echo '<p> failed check 2 </p>';} //'<div class="error-message"Failed Email check, try again</div>';}
                if(!$passCheck){ echo '<p> Failed check 3 </p>';} //'<div class="error-message"Failed Password check, try again</div>';}
        }

}

//processUser("Glowstick016","glowstick016@gmail","scooby016!!","etherhe");
?>
</body>
</html>

This is the code for addInfo() also

function addInfo($username, $email, $pass, $admin, $rights){
/* Database credentials. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
        $DB_SERVER = 'localhost:3306';
        $DB_USERNAME = 'GlowWeb';
        $DB_PASSWORD = REDACTED;
        $DB_NAME = 'GlowWeb';

        /* Attempt to connect to MySQL database */
        $link = new mysqli($DB_SERVER, $DB_USERNAME, $DB_PASSWORD, $DB_NAME);

        // Check connection
        if($link ->connect_error){
                die("ERROR: Could not connect. " . mysqli_connect_error());
                logs("ERROR: Could not connect" . mysqli_connect_error());
        }

        //User Info

        $sql = "INSERT INTO Users (Usr, EMAIL, Password, Admin, Rights) VALUES ('$username', '$email', '$pass', '$admin', $rights)";

        //Checking if it worked
        if ($link->query($sql) === TRUE) {
                echo "New user added successfully";
        } else {
                echo "Error: " . $sql . "<br>" . $link->error;
                logs("Error: " . $sql . "<br>" . $link->error);
        }

        $link->close();
}

I basically want to enter info into the form which then get’s checked for sanitization then inserted into my mysql database. It works when done with processUser() but not when done via html form

New contributor

Cameron Kennedy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật