Jump to content

RE: Help with coding


Recommended Posts

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>

Link to comment
Share on other sites

  • 4 weeks later...

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.

Link to comment
Share on other sites

  • 4 weeks later...

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...