HEX
Server: Apache
System: Linux 162-241-121-228.webhostbox.net 3.10.0-862.3.2.el7.x86_64 #1 SMP Mon May 21 23:36:36 UTC 2018 x86_64
User: apiuattsproject (10003)
PHP: 8.2.31
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/uat-api.tsprojects.net/httpdocs/ratemycoach-web/newFileUploadOld.php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>User Profile Form</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        h1 {
              color: #642d90;
              text-align: center;
             font-size: 24px; /* Adjust the font size as needed */
             margin-bottom: 20px; /* Add some margin below the title */
         }

        .form-container {
            width: 600px; /* Adjust the width as needed */
        }

        .form-group {
            display: flex;
            margin-bottom: 10px;
        }

        
        .form-group .input-column {
            flex: 1;
        }
        .form-group label {
         width: 150px;
         padding-right: 10px;
        text-align: right;
        color: #652d90; /* Text color */
        font-weight: bold; /* Make the text bold */
        }

        input, select {
            width: 100%;
            box-sizing: border-box;
            border: 1px solid #652d90;
            color: #652d90;
            padding: 5px;
        }

        .submit-button {
            background-color: #652d90;
            color: #ffffff;
            padding: 10px;
            border: none;
            cursor: pointer;
        }
    </style>
<script>
    function disableSubmitButton() {
        document.getElementById("submitBtn").disabled = true;
    }
</script>

</head>
<body>

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$message = ''; // Initialize an empty message variable
$photoFileName = ''; // Initialize $photoFileName

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Debugging statement
    error_log('Form submitted: ' . date('Y-m-d H:i:s'));

    
    // Your database credentials
    $servername = "localhost";
    $username = "pxhlcbmy_ccast99942cr";
    $password = "rYCh2@23";
    $dbname = "pxhlcbmy_coachrychdb";

    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);

    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

    // Prepare and bind the SQL statement
    $stmt = $conn->prepare("INSERT INTO tblcoachesXL (f_name, l_name, emailUsers, schoolname, schoolcity, schoolstate, sports, userImg) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");

    $stmt->bind_param("ssssssss", $firstName, $lastName, $email, $schoolName, $city, $state, $sports, $photoFileName);

    // Set parameters
    $firstName = $_POST['first_name'];
    $lastName = $_POST['last_name'];
    $email = $_POST['email'];
    $schoolName = $_POST['school_name'];
    $city = $_POST['city'];
    $state = $_POST['state'];
    $sports = $_POST['sports'];

    // Process file upload
    $uploadsDirectory = 'Profile4/uploads/';
    $photoFileName = '';

    if ($_FILES['photo']['error'] === UPLOAD_ERR_OK) {
        $tmpName = $_FILES['photo']['tmp_name'];
        $photoFileName = $_FILES['photo']['name'];
        move_uploaded_file($tmpName, $uploadsDirectory . $photoFileName);
    }

    // Execute the statement

   if ($stmt->execute()) {
      $message = "Coach Profile Successfully Added";
    // Redirect to a success page
    header("Location: coachsuccess.php");
    exit(); // Make sure to stop script execution after the redirect
   } else {
    $message = "Error: " . $stmt->error;
 }
   

  

    // Close the statement and connection
    $stmt->close();
    $conn->close();
}
?>



  

<div class="form-container">
    <h1>Coach Profile</h1>
    <?php echo $message; // Display the message here ?>
    <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post" enctype="multipart/form-data">
        
        <div class="form-group">
        <label for="first_name">First Name:</label>
        <div class="input-column">
            <input type="text" name="first_name" required>
        </div>
    </div>

    <div class="form-group">
        <label for="last_name">Last Name:</label>
        <div class="input-column">
            <input type="text" name="last_name" required>
        </div>
    </div>

    <div class="form-group">
        <label for="email">Email:</label>
        <div class="input-column">
            <input type="email" name="email" required>
        </div>
    </div>

    <div class="form-group">
        <label for="school_name">School Name:</label>
        <div class="input-column">
            <input type="text" name="school_name" required>
        </div>
    </div>

    <div class="form-group">
        <label for="city">City:</label>
        <div class="input-column">
            <input type="text" name="city" required>
        </div>
    </div>

    <div class="form-group">
        <label for="state">State:</label>
        <div class="input-column">
            <input type="text" name="state" required>
        </div>
    </div>

    <div class="form-group">
        <label for="sports">Sports:</label>
        <div class="input-column">
            <select name="sports" required>
                <option value="Please select a sport">Please select a sport</option>
                <option value="baseball">Baseball</option>
                <option value="basketball">Basketball</option>
                <option value="football">Football</option>
                <option value="soccer">Soccer</option>
                <option value="volleyball">Volleyball</option>
            </select>
        </div>
    </div>

    <div class="form-group">
        <label for="photo">Photo:</label>
        <div class="input-column">
            <input type="file" name="photo" accept="image/*" required>
        </div>
    </div>

    <div class="form-group">
        <label for="photo_file_name">Photo File Name:</label>
        <div class="input-column">
            <input type="text" name="photo_file_name" value="<?php echo $photoFileName; ?>" readonly>
        </div>
    </div>
        
       <center>
        
        <button type="submit" class="submit-button" id="submitBtn" onclick="disableSubmitButton()">Submit</button>

       </center>
    </form>
</div>

</body>
</html>