-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXmlCreator.php
executable file
·82 lines (71 loc) · 3.27 KB
/
XmlCreator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$fh = fopen("transcript.xml", 'w') or exec(dirname(__FILE__) . '/MakeXMLFile.sh');
$domtree = new \DOMDocument('1.0', 'UTF-8');
/* create the root element of the xml tree */
$xmlRoot = $domtree->createElement("xml");
/* append it to the document created */
$xmlRoot = $domtree->appendChild($xmlRoot);
$uname = $_POST['username'];
$pass = $_POST['password'];
$xmljobs = new DOMDocument("1.0","UTF-8");
$xmljobs->load('users.xml');
$xmljobs->getElementById('root');
$domtree1 = $xmljobs->getElementsByTagName("users")->item(0);
var_dump($domtree1);
$domtree1->appendChild($xmljobs->createElement("user",$uname));
$xmljobs->save("users.xml");
$_SESSION['usr'] = $uname;
$arry = ["uname"=>$uname,"pass"=>$pass];
$_SESSION["userdata"]= $arry;
$userRoot = $xmlRoot->appendChild($domtree->createElement("userDetails"));
$userRoot->appendChild($domtree->createElement("username",$uname));
$userRoot->appendChild($domtree->createElement("password",$pass));
$root = $xmlRoot->appendChild($domtree->createElement("transcript"));
$school = $_POST['school'];
$nameorg = $_POST["membership"];
$title = $_POST["title"];
$description = $_POST["description"];
$period = $_POST["period"];
$memb= $root->appendChild($domtree->createElement("membershipName",$nameorg));
$memb->appendChild($domtree->createElement("title",$title));
$memb->appendChild($domtree->createElement("description",$description));
$memb->appendChild($domtree->createElement("period",$period));
foreach ($school as $keyS=> $val){
$subject=$_POST['subjects'.$keyS];
$yStart = $_POST['yearStarted'.$keyS];
$yEnd = $_POST['yearEnded'.$keyS];
$keyword = $_POST['keyword'.$keyS];
$grade = $_POST['grade'.$keyS];
$gradYear = $_POST['gradYear'.$keyS];
$subExtra = null;
if(isset($_POST['subjectsExtra'.$keyS])){
$subExtra = $_POST['subjectsExtra'.$keyS];
$keywordExtra =$_POST['keywordExtra'.$keyS];
$gradYearExtra = $_POST['gradYearExtra'.$keyS];
}
$school= $root->appendChild($domtree->createElement("schools"));
$school->appendChild($domtree->createElement("school",$val));
$subjecti= $root->appendChild($domtree->createElement("subjects"));
foreach ($subject as $key=>$value){
$subjecti->appendChild($domtree->createElement("subject",$subject[$key]));
$subjecti->appendChild($domtree->createElement("yearStarted",$yStart[$key]));
$subjecti->appendChild($domtree->createElement("yearEnded",$yEnd[$key]));
$subjecti->appendChild($domtree->createElement("keyword",$keyword[$key]));
$subjecti->appendChild($domtree->createElement("grade",$grade[$key]));
$subjecti->appendChild($domtree->createElement("gradYear",$gradYear[$key]));
}
$extra = $school->appendChild($domtree->createElement("extraSubjects"));
if($subExtra!= null) {
foreach ($subExtra as $key => $value) {
$extra->appendChild($domtree->createElement("subjectExtra", $subExtra[$key]));
$extra->appendChild($domtree->createElement("keywordExtra", $keywordExtra[$key]));
$extra->appendChild($domtree->createElement("gradYearExtra", $gradYearExtra[$key]));
}
}
}
$domtree->save('transcript.xml');
header("Location: CVForm.php");