abndonurfriends
abndonurfriends

Reputation: 11

Issue with php and xml in Linux Instance

I currently have a Linux Instance running CentOS and I am trying to create a php form that takes input and updates an xml file with what is submitted. It works on my local network exactly how I want it to but when I run it from the server it does not update the xml file. The server is running php 5.3 and it php works. Is there something different I need to do?

The php file is below:

<?php
if (isset($_POST['submit']))
{
$ID = $_POST['ID'];
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];

$xml = simplexml_load_file("test.xml");

$sxe = new SimpleXMLElement($xml->asXML());
$entry = $sxe->addChild("item"); 
$entry->addChild("name", $name); 
$entry->addChild("email", $email); 
$entry->addChild("phone", $phone); 
$sxe->asXML("test.xml");  
}
?>
<!doctype html>
<head>
</head>
<body>
<form method="POST" action=''>
ID# <input type="text" value=""  name="ID"/>
Name <input type="text" value=""  name="name"/>
Email <input type="text" value=""  name="email"/>
Phone <input type="text" value=""  name="phone"/>
<input name="submit" type="submit" />
</form>
</body>

Upvotes: 1

Views: 29

Answers (1)

Akshay Khetrapal
Akshay Khetrapal

Reputation: 2676

Make sure you have write permissions to that file. Set chmod value to 666 if you want to write to that file.

Upvotes: 1

Related Questions