Jump to content

Recommended Posts

Posted

I threw this together quickly, I thinks its about there, let me know...

<html>
<head>
<title>Create XML</title>
</head>
     
<body>

<?php
if (isset($_POST['Submit'])) {
// Collect post data from submitted form
$name = $_REQUEST['name'];
$val1 = $_REQUEST['val1'];
$val2 = $_REQUEST['val2'];
$val3 = $_REQUEST['val3'];

// Creates a new document according to 1.0 specs
$document = domxml_new_doc("1.0");

// Lets create an element and call it root, we will then append it to the new document.
$rootElement = $document->create_element($name);
$new_node = $document->append_child($rootElement);

// Lets create a new node called "Items" and append that to the root node.
$itemsElement = $document->create_element("movie");
$items_node = $new_node->append_child($itemsElement);

// Now go into a for loop in which we will create, set, and add five nodes to our Items node.
$item = $document->create_element("1st");
$item->set_content($val1);
$items_node->append_child($item);
$item = $document->create_element("2nd");
$item->set_content($val2);
$items_node->append_child($item);
$item = $document->create_element("3rd");
$item->set_content($val3);
$items_node->append_child($item);

// Lets dump this structure out to a file called output.xml
$document->dump_file("output.xml");
} 

?>
<form action="" id="form" method="post">
Enter your name and top 3 movies
<label>Name:</label><input type="text" name="name" />
<label>1st Place</label><input type="text" name="val1" />
<label>2nd Place</label><input type="text" name="val2" />
<label>3rd Place</label><input type="text" name="val3" />
<input type="submit" name="Submit" value="Submit" />
</form>
</body>
</html>

  • 4 weeks later...
Posted

I think this post was meant to reply my topic which i had closed. Thanks anyway.

 

By the way, i need a little help of php coding. How to write this code, lets say i have a bunch of numbers. And if something matches with one of those numbers then it will do something.

 

Sorry for my bad english :D. I hope you guys know what i mean.

Posted

You could use the in_array() function to determine if your number is in an array of those numbers.

  • 4 weeks later...
Posted

First, you (of course) need to install the PEAR package using CPanel. Some people assume it will just magically install itself, and of course this assumption is false.

 

Do i have to write the full include_path or only by using the require('package/class.php') function?

 

You should not have to use the full include path, since PHP will search in the include path if it does not find the file in the current directory.

Posted
First, you (of course) need to install the PEAR package using CPanel. Some people assume it will just magically install itself, and of course this assumption is false.

 

Do i have to write the full include_path or only by using the require('package/class.php') function?

 

You should not have to use the full include path, since PHP will search in the include path if it does not find the file in the current directory.

Yes, I know that i have to install it by myself. I just dont know how to include it into php codes. I found on google that we should change the include_path to home/account/php to get the right path. Is this right?

Posted

When you install PEAR packages, cpanel willautomatically set the include path to that folder.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...