Ericrs
Ericrs

Reputation: 29

PHP Form Creating XML

I've been trying to create a form to create known issues for our tech support group for RSS feed however it does not seem to be creating the XML.

I've tried to keep it as simple as possible but I may have kept it too simple and overlooked something.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
<body>
<form name="form1" action="generate.php" method="post">

Name of Issue: <input name="name" type="text" /><br/><br/>
Core Service(s): <input name="service" type="text" /><br/><br/>
Severity:<br>
<form>
<input type="radio" name="severity" value="Sev1">Sev1<br>
<input type="radio" name="severity" value="Sev2">Sev2<br>
<input type="radio" name="severity" value="Sev3">Sev3<br>
</form> <BR/> <br/>
Team Looking into Issue: <input name="Team" type="text" /> <BR/> <br/>
ETA (if known): <input name="ETA" type="text" /> <BR/> <br/>
Comments: <textarea name="comments" cols="50" rows="5">

</textarea><br/><br/>
<input type="submit" value="Submit" name="B1"></p>
</form>
</body>
</html>

Backend generate.php

<?php

 if(isset($_POST['create_issue'])){

        echo "Issue Posted";

        $xmlfileName = "issues.xml"

        $name = $_POST['name'];

        $service = $_POST['service'];

        $severity = $_POST['severity'];

        $Team = $_POST['service'];

        $ETA = $_POST['ETA'];

        $comments = $_POST['comments'];

        $xml_dec = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";

/* After Receiving data for issue created generate XML*/

        $rootELementStart = "<knownissue>";

        $rootElementEnd = "</knownissue>";

        $xml_doc=  $xml_dec;

        $xml_doc .=  $rootELementStart;

        $xml_doc .=  "<name>";

        $xml_doc .=  $name;

        $xml_doc .=  "</name>";

        $xml_doc .=  "<service>";

        $xml_doc .=  $service;

        $xml_doc .=  "</service>";

        $xml_doc .=  "<severity>";

        $xml_doc .=  $severity;

        $xml_doc .=  "</severity>";

        $xml_doc .=  "<team>";

        $xml_doc .=  $team;

        $xml_doc .=  "</team>";

        $xml_doc .=  "<eta>";

        $xml_doc .=  $ETA;

        $xml_doc .=  "</eta>";

        $xml_doc .=  "<comments>";

        $xml_doc .=  $comments;

        $xml_doc .=  "</comments>";

        $xml_doc .=  $rootElementEnd;

        $default_dir = "";

        $default_dir .=   $xmlfileName .".xml";

/* Write XML */

$fp = fopen($default_dir,'w');

            $write = fwrite($fp,$xml_doc);
            }
?>

Upvotes: 0

Views: 66

Answers (1)

Protomancer
Protomancer

Reputation: 139

This line is missing a semicolon:

$xmlfileName = "issues.xml"

Dont forget to fclose your file too! You can get some useful error information that way.

Upvotes: 1

Related Questions