Venciity

CV GENERATOR

Aug 19th, 2014
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.53 KB | None | 0 0
  1. <!doctype html>
  2.  
  3. <?php
  4. if (isset($_POST['firstName']) && isset($_POST['secondName']) &&
  5.     isset($_POST['Email']) && isset($_POST['phone']) && isset($_POST['sex'])&&
  6.     isset($_POST['nationality']) && isset($_POST['companyName']) &&isset($_POST['from']) &&
  7.     isset($_POST['to']) && isset($_POST['progLanguages']) && isset($_POST['comprehension']) &&
  8.     isset($_POST['reading']) && isset($_POST['writing'])) {
  9.  
  10.     $firstName = $_POST['firstName'];
  11.     $lastName = $_POST['secondName'];
  12.     $email = $_POST['Email'];
  13.     $phone = $_POST['phone'];
  14.     $sex = $_POST['sex'];
  15.     $birthDate = $_POST['birthDate'];
  16.     $nationality = $_POST['nationality'];
  17.     $companyName = $_POST['companyName'];
  18.     $workedFrom = $_POST['from'];
  19.     $workedTo = $_POST['to'];
  20.     $programmingLanguage = $_POST['progLanguages'];
  21.     $levelProgramming = $_POST['level'];
  22.     $speakingLanguages = $_POST['language-text'];
  23.     $comprehension = $_POST['comprehension'];
  24.     $reading = $_POST['reading'];
  25.     $writing = $_POST['writing'];
  26.     $bCategory = '';
  27.     $cCategory = '';
  28.     $aCategory = '';
  29.     if(isset($_POST['bCategory'])) {
  30.         $bCategory = 'B';
  31.     }
  32.     if(isset($_POST['aCategory'])) {
  33.         $aCategory = 'A';
  34.     }
  35.     if(isset($_POST['cCategory'])) {
  36.         $cCategory = 'C';
  37.     }
  38.  
  39.     if(!preg_match('/[^A-Za-z]/', $firstName) && !preg_match('/[^A-Za-z]/', $lastName)
  40.         && !preg_match('/[^A-Za-z0-9 ]/', $companyName) && strlen($firstName) <= 20 && strlen($firstName) >= 2 &&
  41.         strlen($lastName) <= 20 && strlen($lastName) >= 2 &&
  42.         strlen($companyName) <= 20 && strlen($companyName) >= 2 &&
  43.         !preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $birthDate) &&
  44.         !preg_match('/[^0-9\+\-\s]/', $phone)
  45.     ) {
  46.         $personalInfoTable = '<table><thead><tr><th colspan="2">Personal Information</th></tr></thead><tbody>' .
  47.             '<tr><td>First Name</td><td>' . $firstName . '</td></tr><td>Last Name</td><td>' . $lastName  . '</td></tr>' .
  48.             '<tr><td>Email</td><td>' . $email . '</td></tr>' .
  49.             '<tr><td>Phone</td><td>' . $phone . '</td></tr>' .
  50.             '<tr><td>Gender</td><td>' . $sex . '</td></tr>' .
  51.             '<tr><td>Birth Date</td><td>' . $birthDate . '</td></tr>' .
  52.             '<tr><td>Nationality</td><td>' . $nationality . '</td></tr></tbody></table>';
  53.         $lastWorkTable = '<table><thead><tr><th colspan="2">Last Work Position</th></tr></thead><tbody>' .
  54.             '<tr><td>Company Name</td><td>' . $companyName . '</td></tr>' .
  55.             '<tr><td>From</td><td>' . $workedFrom . '</td></tr>' .
  56.             '<tr><td>To</td><td>' . $workedTo . '</td></tr></tbody></table>';
  57.         $computerSkillsTable = '<table><thead><tr><th colspan="2">Computer Skills</th></tr></thead><tbody>' .
  58.             '<tr><td>Programming Languages</td><td><table><thead><tr><th>Language</th><th>Skill Level</th></tr></thead>' .
  59.             '<tbody>';
  60.         for($i = 0; $i < count($levelProgramming) ;$i++) {
  61.             $computerSkillsTable .= '<tr>';
  62.             $computerSkillsTable .= '<td>' . $programmingLanguage[$i] . '</td>';
  63.             $computerSkillsTable .= '<td>' . $levelProgramming[$i] . '</td>';
  64.             $computerSkillsTable .= '</tr>';
  65.  
  66.         }
  67.         $computerSkillsTable .= '</tbody></table></tr></tbody></table>';
  68.  
  69.         $otherSkills = '<table><thead><tr><th colspan="2">Other Skills</th></tr></thead><tbody>' .
  70.             '<tr><td>Languages</td><td><table><thead><th>Language</th><th>Comprehension</th>' .
  71.             '<th>Reading</th><th>Writing</th></tr>';
  72.  
  73.         for($i = 0; $i < count($comprehension) ;$i++) {
  74.             $otherSkills .= '<tr>';
  75.             $otherSkills .= '<td>' . $speakingLanguages[$i] . '</td>';
  76.             $otherSkills .= '<td>' . $comprehension[$i] . '</td>';
  77.             $otherSkills .= '<td>' . $reading[$i] . '</td>';
  78.             $otherSkills .= '<td>' . $writing[$i] . '</td>';
  79.         }
  80.         $otherSkills .= '</tbody></table></tr><tr><td>Driver`s License</td><td>' . $bCategory . " ".  $aCategory. "" . $cCategory .'</td></tr>';
  81.         $otherSkills .= '</tbody></table>';
  82.     }
  83. }
  84. ?>
  85.  
  86. <html lang="en">
  87. <head>
  88.     <meta charset="UTF-8">
  89.     <title>CV Generator</title>
  90.     <style>
  91.         table ,th , td {
  92.             border: 1px solid black;
  93.             border-collapse: collapse;
  94.         }
  95.  
  96.         table {
  97.             margin: 10px;
  98.         }
  99.     </style>
  100. </head>
  101. <body>
  102.  
  103. <script>
  104.     // add programming language
  105.     var idCounter = 0;
  106.     function addProgLang() {
  107.         var myDiv = document.createElement("div");
  108.         myDiv.setAttribute("id", "inputBox" + idCounter);
  109.         idCounter++;
  110.         myDiv.innerHTML = "<input type='text' name='progLanguages[]' id='prog-langs' required='required'>" +
  111.             "<select name='level[]' id='level' required='required'>" +
  112.             "<option value='Beginner'>Beginner</option>" +
  113.             "<option value='Programmer'>Programmer</option>" +
  114.             "<option value='Ninja'>Ninja</option>" +
  115.             "</select>" +
  116.             "<br/>";
  117.         document.getElementById("parent-prog-lang").appendChild(myDiv);
  118.     }
  119.  
  120.     // remove programming language
  121.     function removeProgLang() {
  122.         var getChild = document.getElementById("parent-prog-lang").lastChild;
  123.         if (getChild.id != "ipnutBox0") {
  124.             document.getElementById("parent-prog-lang").removeChild(getChild);
  125.         }
  126.     }
  127.  
  128.     // add speaking language
  129.     var idLangCounter = 0;
  130.     function addSpeakingLang() {
  131.         var langParent = document.getElementById("speaking-lang-parent");
  132.         var newDiv = document.createElement("div");
  133.         newDiv.setAttribute("id", "lang" + idLangCounter);
  134.         idLangCounter++;
  135.         newDiv.innerHTML = "<input type='text' id='lang' name='language-text[]' required='required'/>" +
  136.             "<select name='comprehension[]' id='comprehension' required='required'>" +
  137.             "<option value='default' disabled selected>-Comprehension-</option>" +
  138.             "<option value='beginner'>beginner</option>" +
  139.             "<option value='intermediate'>intermediate</option>" +
  140.             "<option value='advanced'>advanced</option>" +
  141.             "</select>" +
  142.             "<select name='reading[]' id='reading' required='required'>" +
  143.             "<option value='default' disabled selected>-Reading-</option>" +
  144.             "<option value='beginner'>beginner</option>" +
  145.             "<option value='intermediate'>intermediate</option>" +
  146.             "<option value='advanced'>advanced</option>" +
  147.             "</select>" +
  148.             "<select name='writing[]' id='writing'>" +
  149.             "<option value='default' disabled selected>-Writing-</option>" +
  150.             "<option value='beginner'>beginner</option>" +
  151.             "<option value='intermediate'>intermediate</option>" +
  152.             "<option value='advanced'>advanced</option>" +
  153.             "</select>" +
  154.             "<br/>";
  155.         langParent.appendChild(newDiv);
  156.     }
  157.  
  158.     // remove speaking language
  159.     function removeSpeakingLang() {
  160.         var lastElement = document.getElementById("speaking-lang-parent").lastChild;
  161.         if  (lastElement.id != "lang0") {
  162.             document.getElementById("speaking-lang-parent").removeChild(lastElement);
  163.         }
  164.     }
  165.  
  166. </script>
  167.  
  168.  
  169. <form action="" method="post">
  170.     <fieldset>
  171.         <legend>Personal Information</legend>
  172.         <input type="text" placeholder="First Name" name="firstName"/><br/>
  173.         <input type="text" placeholder="Last Name" name="secondName"/><br/>
  174.         <input type="text" placeholder="Email" name="Email"/><br/>
  175.         <input type="text" placeholder="Phone Number" name="phone"/><br/>
  176.         <label for="Female">Female</label>
  177.         <input type="radio" name="sex" value="Female" id="Female"/>
  178.         <label for="Male">Male</label>
  179.         <input type="radio" name="sex" value="Male" id="Male"/> <br/>
  180.         <label for="birthDate">Birth Date</label> <br/>
  181.         <input type="text" id="birthDate" name="birthDate" placeholder="dd/mm/yyyy"/> <br/>
  182.         <label for="nationality">Nationality</label> <br/>
  183.         <select name="nationality" id="nationality">
  184.             <option value="Bulgarian">Bulgarian</option>
  185.             <option value="Albanian">Albanian</option>
  186.             <option value="American">American</option>
  187.         </select>
  188.     </fieldset>
  189.     <fieldset>
  190.         <legend>Last Work Position</legend>
  191.         <label for="companyName">Company Name</label>
  192.         <input type="text" id="companyName" name="companyName"/><br/>
  193.         <label for="from">From</label>
  194.         <input type="text" id="from" placeholder="dd/mm/yyyy" name="from"/><br/>
  195.         <label for="to">To</label>
  196.         <input type="text" id="to" placeholder="dd/mm/yyyy" name="to"/><br/>
  197.     </fieldset>
  198.     <fieldset>
  199.         <legend>Computer Skills</legend>
  200.         <label for="prog-langs">Programming Languages</label><br/>
  201.         <div id="parent-prog-lang">
  202.  
  203.         </div>
  204.         <script>addProgLang();</script>
  205.         <input type="button" name="remove-item" id="remove" value="Remove Language" onclick="removeProgLang()"/>
  206.         <input type="button" name="progLang[]" id="add" value="Add Language" onclick="addProgLang()"/>
  207.     </fieldset>
  208.     <fieldset>
  209.         <legend>Other Skills</legend>
  210.         <label for="lang">Languages</label><br/>
  211.         <div id="speaking-lang-parent">
  212.  
  213.         </div>
  214.         <script> addSpeakingLang();</script>
  215.         <input type="button" id="remove-lang" name="remove-lang" value="Remove Language" onclick="removeSpeakingLang()"/>
  216.         <input type="button" id="remove-lang" name="remove-lang" value="Add Language" onclick="addSpeakingLang()"/><br/>
  217.         <label for="driver">Driver`s License</label><br/>
  218.         <label for="b-category">B</label>
  219.         <input type="checkbox" name="bCategory" id="b-category"/>
  220.         <label for="a-category">A</label>
  221.         <input type="checkbox" name="aCategory" id="a-category"/>
  222.         <label for="c-category">C</label>
  223.         <input type="checkbox" name="cCategory" id="c-category"/>
  224.     </fieldset>
  225.     <input type="submit" name="submit-cv" id="submitBtn" onclick="submitAll()"/>
  226. </form>
  227. <div id="result">
  228.     <?php
  229.     if(isset($personalInfoTable) && isset($lastWorkTable) && isset($computerSkillsTable) && $otherSkills) {
  230.         echo $personalInfoTable;
  231.         echo $lastWorkTable;
  232.         echo $computerSkillsTable;
  233.         echo $otherSkills;
  234.     }
  235.     else {
  236.         echo "Please enter a valid information to generate your CV";
  237.     }
  238.     ?>
  239. </div>
  240. </body>
  241. </html>
Advertisement
Add Comment
Please, Sign In to add comment