Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/php/
Upload File :
Current File : /var/www/cesa.co.za/php/unemployedreg.php

<script src='https://www.google.com/recaptcha/api.js' async defer></script>
<?php
//ini_set('display_errors', 1);
//error_reporting(E_ALL);
include($_SERVER['DOCUMENT_ROOT'] . "/php/inc_db.php");
?>
<h1>Unemployed Engineering Practitioners Database</h1>
<p>Are you an engineering practitioner looking for employment?
    Add your details and CV using our form below. Only our members will be able to access your information.</p>
<h3>Your information will only be kept for 6 months. After 6 months you will need to re-enter you details, if you are still unemployed.</h3>
<?php
$bDisplayForm = true;
if (isset($_REQUEST["go"]) && ($_REQUEST["go"] == 1)) {
    $err = array();
    $filename = "";
    if (!reCaptcha($_POST["g-recaptcha-response"])) {
        $err[] = "You could not be verified as not being a robot, please tick the reCaptcha verification option at the bottom of the form.";
    } else {
        if (isset($_FILES["strresume"]["name"])) {
            $strresume_name = $_FILES["strresume"]["name"];
            $strresume_type = $_FILES["strresume"]["type"];
            $strresume_size = $_FILES["strresume"]["size"];
            $strresume_temp = $_FILES["strresume"]["tmp_name"];

            $fp = fopen($strresume_temp, "rb");
            $file = fread($fp, $strresume_size);

            $filename = "cvfiles/" . date("YmdHi") . str_replace("'", "", $strresume_name);

            touch($filename);
            $fp2 = fopen($filename, "wb");
            fwrite($fp2, $file);
            fclose($fp);
            fclose($fp2);
            chmod($filename, 0x777);
        }
    }
    if (empty($_REQUEST["firstname"])) {
        $err[] = "Your name is required";
    }
    if (empty($_REQUEST["surname"])) {
        $err[] = "Your name is required";
    }
    if (empty($_REQUEST["qualification"])) {
        $err[] = "Your qualification is required";
    }
    if (empty($_REQUEST["province"])) {
        $err[] = "Your province is required";
    } else {
        $sProvince = substr(strtolower(trim($_REQUEST["province"])), 0, 3);
        if (!in_array($sProvince, array("eas", "fre", "gau", "kwa", "lim", "mpu", "wes", "nor"))) {
            $err[] = "Please enter a valid South African province";
        }
    }
    if (empty($_REQUEST["email"])) {
        $err[] = "Your email address is required";
    } else {
        if (filter_input(INPUT_POST, "email", FILTER_VALIDATE_EMAIL) == false) {
            $err[] = "Your email address is invalid";
        }
    }
    if ($_REQUEST["ecsa"] == "Y") {
        //        if (filter_input(INPUT_POST, "yearreg", FILTER_VALIDATE_INT, ["options" => ["min_range" => 1950, ["max_range"] => date("Y")]]) == false) {
        if (!isset($_REQUEST['yearreg']) || $_REQUEST['yearreg'] < 1950 || $_REQUEST['yearreg'] > date("Y")) {
            $err[] = "Your year of ECSA registration is invalid. Please enter a valid numeric year.";
        }
    }
    if (!empty($_REQUEST["institution"])) {
        if (empty(filter_var($_POST["institution"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH))) {
            $err[] = "Please enter a valid academic institution";
        }
    }

    if (!empty($_REQUEST["yearqual"])) {
        if (filter_input(INPUT_POST, "yearqual", FILTER_VALIDATE_INT, array("options" => array("min_range" => 1950, "max_range" => date("Y")))) == false) {
            $err[] = "Your year of qualification is invalid. Please enter a valid numeric year.";
        }
    }

    if (!empty($_REQUEST["fromdate"])) {
        $arrDateParts = explode("-", $_REQUEST["fromdate"]);
        if (count($arrDateParts) == 3) {
            if (!checkdate($arrDateParts[1], $arrDateParts[2], $arrDateParts[0])) {
                $err[] = "The date you are available from is invalid. Please use the YYYY-MM-DD format, for example " . date("Y-m-d");
            } else {
                if (strtotime($_REQUEST["fromdate"] . " 23:59:59") < time()) {
                    $err[] = "The date you are available from cannot be in the past.";
                }
            }
        } else {
            $err[] = "The date you are available from is invalid. Please use the YYYY-MM-DD format, for example " . date("Y-m-d");
        }
    }
    if (!isset($_REQUEST["unemployed"]) || empty($_REQUEST["unemployed"])) {
        $err[] = "Please indicate whether you are unemployed or not";
    }

    if (!isset($_REQUEST["declarecorrect"]) || empty($_REQUEST["declarecorrect"])) {
        $err[] = "Please confirm that the information is correct by ticking the box next to the declaration";
    }
    if (count($err) == 0) {

        $sql = "SELECT * FROM UnempPractitioners WHERE firstname='" . addslashes($_REQUEST["firstname"]) . "' AND surname='" . addslashes($_REQUEST["surname"]) . "' AND email='" . addslashes($_REQUEST["email"]) . "'";
        $rec = mysqli_query($conni, $sql);
        if (mysqli_num_rows($rec) > 0) {
            $err[] = "An entry with the supplied name and email address already exists in our database.";
        }
    }

    if (count($err) == 0) {

        $iApproved = 0;
        if (($_REQUEST["unemployed"] == "Y") || ($_REQUEST["unemployed"] == "F"))
            $iApproved = 1;

        if (!isset($_REQUEST["profreg"]) || !is_array($_REQUEST["profreg"])) {
            $_REQUEST["profreg"] = array();
        }

        $sql = "insert into UnempPractitioners (title, firstname, surname, cvfile,
		qualification, institution, yearqual, province, location, fulltime, ecsa, yearreg, profreg,
		profile, telnum, email, fromdate, jobtype, qualiflevel, specialisation, unemployed, declarecorrect, approved)
		values ('" . addslashes($_REQUEST["title"]) . "', '" . addslashes($_REQUEST["firstname"]) . "', '" . addslashes($_REQUEST["surname"]) . "', '" . $filename . "',
		'" . addslashes($_REQUEST["qualification"]) . "', '" . addslashes(filter_var($_POST["institution"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH)) . "',
    " . intval($_REQUEST["yearqual"]) . ",
		'" . addslashes($_REQUEST["province"]) . "',
		'" . addslashes($_REQUEST["location"]) . "', '" . addslashes($_REQUEST["fulltime"]) . "', '" . addslashes($_REQUEST["ecsa"]) . "',
		'" . addslashes($_REQUEST["yearreg"]) . "', '" . addslashes(implode(",", $_REQUEST["profreg"])) . "', '" . addslashes($_REQUEST["profile"]) . "',
		'" . addslashes($_REQUEST["telnum"]) . "', '" . addslashes($_REQUEST["email"]) . "',
		'" . date("Y-m-d", strtotime($_REQUEST["fromdate"])) . "', '" . addslashes($_REQUEST["jobtype"]) . "', '" . addslashes($_REQUEST["qualiflevel"]) . "',
		'" . addslashes($_REQUEST["specialisation"]) . "', '" . $_REQUEST["unemployed"] . "', '" . $_REQUEST["declarecorrect"] . "', " . $iApproved . ")";
        if (mysqli_query($conni, $sql)) {
            echo "<p><b style='color:red'>Thank you, your information has been added to our database.</b></p><p>Once we have approved it, it will be visible to our members.</p>";
            $bDisplayForm = false;

            $sendto = "godfreyr@cesa.co.za";
            //			$sendto="julia@xe.co.za";
            mail($sendto, "Unemployed Engineering Practitioner added to database", "The following person has submitted their information to the Unemployed Engineering Practitioners database:

" . $_REQUEST["firstname"] . " " . $_REQUEST["surname"] . "", "From: webmaster@cesa.co.za");
        }
    } else {
        echo "<p><b style='color:red'>Your information has NOT been saved, please correct the errors below:</b></p><ul><li>" . implode("</li><li>", $err) . "</li></ul>";;
    }
}
if ($bDisplayForm) {
?>
    <form action="/unemployed-eng-practitioners" method="post" enctype="multipart/form-data" name="form1" id="form1">
        <input type="hidden" name="go" value="1" />
        <p><b>Your Details:</b> (fields marked with a <strong>*</strong> are required)</p>
        <table width="530" border="1" cellspacing="0" cellpadding="5">
            <tr>
                <td width="174">Title:</td>
                <td width="330">
                    <table border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td nowrap>Prof.<input type="radio" name="title" value="Prof" <?php if ($_POST["title"] == "Prof") echo " checked"; ?>></td>
                            <td nowrap style="padding:0px 10px 0px 5px">Dr.<input type="radio" name="title" value="Dr" <?php if ($_POST["title"] == "Dr") echo " checked"; ?>></td>
                            <td nowrap style="padding:0px 10px 0px 5px">Mr.<input name="title" type="radio" value="Mr" <?php if (!isset($_POST["title"]) || ($_POST["title"] == "Mr")) echo " checked"; ?>></td>
                        </tr>
                        <tr>
                            <td nowrap style="padding:0px 10px 0px 5px">Mrs.
                                <input type="radio" name="title" value="Mrs" <?php if ($_POST["title"] == "Mrs") echo " checked"; ?>>
                            </td>
                            <td nowrap style="padding:0px 0px 0px 5px">Ms.
                                <input type="radio" name="title" value="Ms" <?php if ($_POST["title"] == "Ms") echo " checked"; ?>>
                            </td>
                            <td nowrap style="padding:0px 10px 0px 5px">&nbsp;</td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>First Name:</td>
                <td><input type="text" name="firstname" id="firstname" size="50" value="<?php echo $_REQUEST["firstname"]; ?>" required /> <strong>*</strong></td>
            </tr>
            <tr>
                <td>Surname:</td>
                <td><input name="surname" type="text" id="surname" value="<?php echo $_REQUEST["surname"]; ?>" size="50" required />
                    <strong>*</strong>
                </td>
            </tr>
            <tr>
                <td>Qualification Level:</td>
                <td><select name="qualiflevel" id="qualiflevel">
                        <option<?php if ($_REQUEST["qualiflevel"] == "Diploma / Certificate") echo " selected"; ?>>Diploma / Certificate</option>
                            <option<?php if ($_REQUEST["qualiflevel"] == "National Diploma") echo " selected"; ?>>National Diploma</option>
                                <option<?php if ($_REQUEST["qualiflevel"] == "Degree") echo " selected"; ?>>Degree</option>
                    </select></td>
            </tr>
            <tr>
                <td>Your Qualification:</td>
                <td><input name="qualification" type="text" id="qualification" size="50" value="<?php echo $_REQUEST["qualification"]; ?>" required /> <strong>*</strong></td>
            </tr>
            <tr>
                <td>Institution Where You Obtained Your Qualification:</td>
                <td><input name="institution" type="text" id="institution" size="50" value="<?php echo $_REQUEST["institution"]; ?>" /></td>
            </tr>
            <tr>
                <td>Year of Qualification:</td>
                <td><input name="yearqual" type="text" id="yearqual" size="50" value="<?php echo $_REQUEST["yearqual"]; ?>" /></td>
            </tr>
            <tr>
                <td>Professional registration (ECSA)?</td>
                <td>
                    <input name="ecsa" type="radio" value="Y" <?php if ($_REQUEST["ecsa"] == "Y") echo " checked"; ?> required>Yes,
                    I am registered with ECSA<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    Year of registration:
                    <input name="yearreg" type="text" id="yearreg" size="15" value="<?php echo $_REQUEST["yearreg"]; ?>" /><br>
                    <input name="ecsa" type="radio" value="N" <?php if ($_REQUEST["ecsa"] == "N") echo " checked"; ?>>No
                </td>
            </tr>
            <tr>
                <td>Professional registration (Other)?</td>
                <td>
                    <input name="profreg[]" type="checkbox" value="SACQSP" <?php
                                                                            if (!is_array($_REQUEST["profreg"])) {
                                                                                $_REQUEST["profreg"] = array();
                                                                            }

                                                                            if (in_array("SACQSP", $_REQUEST["profreg"])) {
                                                                                echo " checked";
                                                                            }
                                                                            ?>>SACQSP<br>
                    <input name="profreg[]" type="checkbox" value="SACAP" <?php
                                                                            if (in_array("SACAP", $_REQUEST["profreg"])) {
                                                                                echo " checked";
                                                                            }
                                                                            ?>>SACAP<br>
                    <input name="profreg[]" type="checkbox" value="SACLAP" <?php
                                                                            if (in_array("SACLAP", $_REQUEST["profreg"])) {
                                                                                echo " checked";
                                                                            }
                                                                            ?>>SACLAP<br>
                    <input name="profreg[]" type="checkbox" value="SACPCMP" <?php
                                                                            if (in_array("SACPCMP", $_REQUEST["profreg"])) {
                                                                                echo " checked";
                                                                            }
                                                                            ?>>SACPCMP<br>
                    <input name="profreg[]" type="checkbox" value="SACPVP" <?php
                                                                            if (in_array("SACPVP", $_REQUEST["profreg"])) {
                                                                                echo " checked";
                                                                            }
                                                                            ?>>SACPVP
                </td>
            </tr>
            <tr>
                <td>Specialisation Field:</td>
                <td>
                    <select name="specialisation" id="specialisation">
                        <option<?php if ($_REQUEST["specialisation"] == "Acoustics") echo " selected"; ?>>Acoustics</option>
                            <option<?php if ($_REQUEST["specialisation"] == "Agricultural") echo " selected"; ?>>Agricultural</option>
                                <option<?php if ($_REQUEST["specialisation"] == "Building Services") echo " selected"; ?>>Building Services</option>
                                    <option<?php if ($_REQUEST["specialisation"] == "Chemical") echo " selected"; ?>>Chemical</option>
                                        <option<?php if ($_REQUEST["specialisation"] == "Civil") echo " selected"; ?>>Civil</option>
                                            <option<?php if ($_REQUEST["specialisation"] == "Development") echo " selected"; ?>>Development</option>
                                                <option<?php if ($_REQUEST["specialisation"] == "Electrical") echo " selected"; ?>>Electrical</option>
                                                    <option<?php if ($_REQUEST["specialisation"] == "Electronic") echo " selected"; ?>>Electronic</option>
                                                        <option<?php if ($_REQUEST["specialisation"] == "Environmental") echo " selected"; ?>>Environmental</option>
                                                            <option<?php if ($_REQUEST["specialisation"] == "Geotechnical") echo " selected"; ?>>Geotechnical</option>
                                                                <option<?php if ($_REQUEST["specialisation"] == "Industrial") echo " selected"; ?>>Industrial</option>
                                                                    <option<?php if ($_REQUEST["specialisation"] == "Mechanical") echo " selected"; ?>>Mechanical</option>
                                                                        <option<?php if ($_REQUEST["specialisation"] == "Marine") echo " selected"; ?>>Marine</option>
                                                                            <option<?php if ($_REQUEST["specialisation"] == "Mining") echo " selected"; ?>>Mining</option>
                                                                                <option<?php if ($_REQUEST["specialisation"] == "Process") echo " selected"; ?>>Process</option>
                                                                                    <option<?php if ($_REQUEST["specialisation"] == "Structural") echo " selected"; ?>>Structural</option>
                                                                                        <option<?php if ($_REQUEST["specialisation"] == "Transportation") echo " selected"; ?>>Transportation</option>
                                                                                            <option<?php if ($_REQUEST["specialisation"] == "Architecture") echo " selected"; ?>>Architecture</option>
                                                                                                <option<?php if ($_REQUEST["specialisation"] == "Rural Development") echo " selected"; ?>>Rural Development</option>
                                                                                                    <option<?php if ($_REQUEST["specialisation"] == "Project Management") echo " selected"; ?>>Project Management</option>
                                                                                                        <option<?php if ($_REQUEST["specialisation"] == "Quantity Surveying") echo " selected"; ?>>Quantity Surveying</option>
                                                                                                            <option<?php if ($_REQUEST["specialisation"] == "Town Planning") echo " selected"; ?>>Town Planning</option>
                                                                                                                <option<?php if ($_REQUEST["specialisation"] == "Multidisciplinary") echo " selected"; ?>>Multidisciplinary</option>
                                                                                                                    <option<?php if ($_REQUEST["specialisation"] == "Dispute Resolution") echo " selected"; ?>>Dispute Resolution</option>
                                                                                                                        <option<?php if ($_REQUEST["specialisation"] == "Expert Witness") echo " selected"; ?>>Expert Witness</option>
                                                                                                                            <option<?php if ($_REQUEST["specialisation"] == "Information Systems") echo " selected"; ?>>Information Systems</option>
                                                                                                                                <option<?php if ($_REQUEST["specialisation"] == "Facilities Management") echo " selected"; ?>>Facilities Management</option>
                                                                                                                                    <option<?php if ($_REQUEST["specialisation"] == "GIS") echo " selected"; ?>>GIS</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Type of job you are looking for:</td>
                <td><input name="jobtype" type="text" id="jobtype" size="50" value="<?php echo $_REQUEST["jobtype"]; ?>" /></td>
            </tr>
            <tr>
                <td>Are you looking for:</td>
                <td>
                    <input name="fulltime" type="radio" value="F" <?php if ($_REQUEST["fulltime"] == "F") echo " checked"; ?> required>Full-time
                    work<br>
                    <input name="fulltime" type="radio" value="P" <?php if ($_REQUEST["fulltime"] == "P") echo " checked"; ?>>Part-time
                    work
                </td>
            </tr>
            <tr>
                <td>Province:</td>
                <td><input name="province" type="text" id="province" size="50" value="<?php echo $_REQUEST["province"]; ?>" required />
                    <strong>*</strong>
                </td>
            </tr>
            <tr>
                <td>Preferred Location / City:</td>
                <td><input name="location" type="text" id="location" size="50" value="<?php echo $_REQUEST["location"]; ?>" /></td>
            </tr>
            <tr>
                <td>Available From (Date):</td>
                <td><input type="text" name="fromdate" id="fromdate" size="50" value="<?php echo $_REQUEST["fromdate"]; ?>" placeholder="YYYY-MM-DD" /></td>
            </tr>
            <tr>
                <td>Telephone:</td>
                <td><input type="text" name="telnum" id="telnum" size="50" value="<?php echo $_REQUEST["telnum"]; ?>" /></td>
            </tr>
            <tr>
                <td>Email:</td>
                <td><input name="email" type="text" id="email" size="50" value="<?php echo $_REQUEST["email"]; ?>" required />
                    <strong>*</strong>
                </td>
            </tr>
            <tr>
                <td>Brief profile:</td>
                <td><textarea name="profile" rows="4" cols=40 required><?php echo $_REQUEST["profile"]; ?></textarea> <strong>*</strong></td>
            </tr>
            <tr>
                <td>Upload your CV:</td>
                <td><input type="file" name="strresume" id="strresume" required="required" /> <strong>*</strong></td>
            </tr>
            <tr>
                <td>I am currently unemployed</td>
                <td><input name="unemployed" type="radio" value="Y" <?php if ($_REQUEST["unemployed"] == "Y") echo " checked"; ?> required>Yes<br>
                    <input name="unemployed" type="radio" value="F" <?php if ($_REQUEST["unemployed"] == "F") echo " checked"; ?>>Freelancing<br>
                    <input name="unemployed" type="radio" value="N" <?php if ($_REQUEST["unemployed"] == "N") echo " checked"; ?>>No
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <p><input type="checkbox" value="Y" name="declarecorrect" <?php if ($_REQUEST["declarecorrect"] == "Y") echo " checked"; ?> required> I declare that the information given is true and correct. I am aware that it is an offence to wilfully make a false statement.</p>
                    <div class="g-recaptcha" data-sitekey="6LcoIWUrAAAAAKBLHpjS7GyroBey9G6yhilbpyNa"></div>
                    <br>
                    <input name="button" type="submit" id="button" value="Submit" />
                </td>
            </tr>
        </table>
        <p>&nbsp;</p>
    </form>
<?php
}

include_once($_SERVER['DOCUMENT_ROOT'] . "/php/templates/inc_footer.php");