Sepia Posted July 11, 2007 Share Posted July 11, 2007 I am brand new to PHP but would like to create a form in an HTML page that will use the data entered into it to display an XML file. Something like this: http://www.edutech.ch/vista/imsimport.php Go down to User Section Enrollment I fould this tutorial: http://www.topxml.com/php_simplexml/default.asp but didnt really understand it and was getting error messages when trying to use it: Parse error: syntax error, unexpected T_STRING in /xml/php/employee.php on line 8 if(isset($_POST['create_employee'])){ echo "Employee Data Posted"; $xmlfileName = $_POST['xmlfileName']; $empName = $_POST['empName']; $empAddress = $_POST['empAddress']; $empSSN = $_POST['empSSN']; $empCompany = $_POST['empCompany']; $xml_dec = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; $rootELementStart = "<employee>"; $rootElementEnd = "</employee>"; $xml_doc= $xml_dec; $xml_doc .= $rootELementStart; $xml_doc .= "<employeename>"; $xml_doc .= $empName; $xml_doc .= "</employeename>"; $xml_doc .= "<employeeaddress>"; $xml_doc .= $empAddress; $xml_doc .= "</employeeaddress>"; $xml_doc .= "<SSN>"; $xml_doc .= $empSSN; $xml_doc .= "</SSN>"; $xml_doc .= "<company>"; $xml_doc .= $empCompany; $xml_doc .= "</company>"; $xml_doc .= $rootElementEnd; $default_dir = "xml_files/"; $default_dir .= $xmlfileName .".xml"; $fp = fopen($default_dir,'w'); $write = fwrite($fp,$xml_doc); Does anyone know of another tutorial is have any pointers to get me started? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/59517-use-form-data-to-create-xml-file/ Share on other sites More sharing options...
per1os Posted July 11, 2007 Share Posted July 11, 2007 Are you by change using <? or <?php If you are using <? I would suggest switching to <?php for some reason there tends to be conflicts with the two. Quote Link to comment https://forums.phpfreaks.com/topic/59517-use-form-data-to-create-xml-file/#findComment-295759 Share on other sites More sharing options...
Sepia Posted July 11, 2007 Author Share Posted July 11, 2007 I wasn't using either. That is literally my whole PHP. I am beginer. Quote Link to comment https://forums.phpfreaks.com/topic/59517-use-form-data-to-create-xml-file/#findComment-295765 Share on other sites More sharing options...
per1os Posted July 11, 2007 Share Posted July 11, 2007 <?php if(isset($_POST['create_employee'])){ echo "Employee Data Posted"; $xmlfileName = $_POST['xmlfileName']; $empName = $_POST['empName']; $empAddress = $_POST['empAddress']; $empSSN = $_POST['empSSN']; $empCompany = $_POST['empCompany']; $xml_dec = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; $rootELementStart = "<employee>"; $rootElementEnd = "</employee>"; $xml_doc= $xml_dec; $xml_doc .= $rootELementStart; $xml_doc .= "<employeename>"; $xml_doc .= $empName; $xml_doc .= "</employeename>"; $xml_doc .= "<employeeaddress>"; $xml_doc .= $empAddress; $xml_doc .= "</employeeaddress>"; $xml_doc .= "<SSN>"; $xml_doc .= $empSSN; $xml_doc .= "</SSN>"; $xml_doc .= "<company>"; $xml_doc .= $empCompany; $xml_doc .= "</company>"; $xml_doc .= $rootElementEnd; $default_dir = "xml_files/"; $default_dir .= $xmlfileName .".xml"; $fp = fopen($default_dir,'w'); $write = fwrite($fp,$xml_doc); ?> Should work. Quote Link to comment https://forums.phpfreaks.com/topic/59517-use-form-data-to-create-xml-file/#findComment-295767 Share on other sites More sharing options...
Sepia Posted July 11, 2007 Author Share Posted July 11, 2007 Thanks but now I am getting: parse error: syntax error, unexpected $end in xml/php/employee.php on line 31 <?php if(isset($_POST['create_employee'])){ echo "Employee Data Posted"; $xmlfileName = $_POST['xmlfileName']; $empName = $_POST['empName']; $empAddress = $_POST['empAddress']; $empSSN = $_POST['empSSN']; $empCompany = $_POST['empCompany']; $xml_dec = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; $rootELementStart = "<employee>"; $rootElementEnd = "</employee>"; $xml_doc= $xml_dec; $xml_doc .= $rootELementStart; $xml_doc .= "<employeename>"; $xml_doc .= $empName; $xml_doc .= "</employeename>"; $xml_doc .= "<employeeaddress>"; $xml_doc .= $empAddress; $xml_doc .= "</employeeaddress>"; $xml_doc .= "<SSN>"; $xml_doc .= $empSSN; $xml_doc .= "</SSN>"; $xml_doc .= "<company>"; $xml_doc .= $empCompany; $xml_doc .= "</company>"; $xml_doc .= $rootElementEnd; $default_dir = "xml_files/"; $default_dir .= $xmlfileName .".xml"; $fp = fopen($default_dir,'w'); $write = fwrite($fp,$xml_doc); ?> Quote Link to comment https://forums.phpfreaks.com/topic/59517-use-form-data-to-create-xml-file/#findComment-295771 Share on other sites More sharing options...
per1os Posted July 11, 2007 Share Posted July 11, 2007 <?php if(isset($_POST['create_employee'])){ echo "Employee Data Posted"; $xmlfileName = $_POST['xmlfileName']; $empName = $_POST['empName']; $empAddress = $_POST['empAddress']; $empSSN = $_POST['empSSN']; $empCompany = $_POST['empCompany']; $xml_dec = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; $rootELementStart = "<employee>"; $rootElementEnd = "</employee>"; $xml_doc= $xml_dec; $xml_doc .= $rootELementStart; $xml_doc .= "<employeename>"; $xml_doc .= $empName; $xml_doc .= "</employeename>"; $xml_doc .= "<employeeaddress>"; $xml_doc .= $empAddress; $xml_doc .= "</employeeaddress>"; $xml_doc .= "<SSN>"; $xml_doc .= $empSSN; $xml_doc .= "</SSN>"; $xml_doc .= "<company>"; $xml_doc .= $empCompany; $xml_doc .= "</company>"; $xml_doc .= $rootElementEnd; $default_dir = "xml_files/"; $default_dir .= $xmlfileName .".xml"; $fp = fopen($default_dir,'w'); $write = fwrite($fp,$xml_doc); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/59517-use-form-data-to-create-xml-file/#findComment-295779 Share on other sites More sharing options...
TheJoey Posted August 25, 2009 Share Posted August 25, 2009 i am also trying to do something similar, how did u go, i tried visiting one of ur links but it was refered to as unsafe by google stating that 900 malicus files were downloaded to ones computer without consent Quote Link to comment https://forums.phpfreaks.com/topic/59517-use-form-data-to-create-xml-file/#findComment-905863 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.