Page 1 of 1

collect data from html form

Posted: Sun Jan 10, 2010 8:06 pm
by rigas
hello

i am trying to create an html form that it will be able to modify the content of an xml file, or add content to the xml file. this xml file is has certain information about various songs. the content added must also be validated with an xsd file.

Code: Select all

 
<html>
<body>
<form name="home" action="test.php" method="post">
  <p>welcome!!  type the song information:</p></br>
  <p>title:
    <input type="text"  name="title"/>
    </p>
  <p>composer:
    <input type="text"  name="composer"/>
    </p>
  <p>lyrics:
    <input type="text"  name="lyrics"/>
    </p>
  <p>artist:
    <input type="text"  name="artist"/>
    </p>
  <p>album:
    <input type="text"  name="album"/>
    </p>
  <p>produser:
    <input type="text"  name="produser"/>
    </p>
  <p>publiser:
    <input type="text"  name="publisher"/>
    </p>
  <p>length:
    <input type="text"  name="length"/>
    </p>
  <p>year:
    <input type="text"  name="year"/></br>
    </p>
   
  <input type="submit" value="submit info">
   
</form>
</body>
<html> 
 
here is the form. while i was trying to collect the data i found out that i might have a problem. using the code below i couldn't see any of my data i previously filled at the form. does anyone has an idea why?

Code: Select all

 
<html>
<body><p>test</p>
<?php
 
echo $_REQUEST["title"];
 
?>
<p>test again</p>
</body>
</html> 
 

Re: collect data from html form

Posted: Mon Jan 11, 2010 10:05 am
by social_experiment
Why don't you use $_POST instead?

Code: Select all

 
<?php 
  echo $_POST['title'];
?>
 

Re: collect data from html form

Posted: Mon Jan 11, 2010 11:51 am
by rigas
i tried this before and didn't work. i also tried the GET method which failed too.

Re: collect data from html form

Posted: Mon Jan 11, 2010 12:03 pm
by chris8421
I just copied your code exactly and it worked fine for me. How are you testing your code? You need to have a local server set up on your computer if you are testing it offline.

Re: collect data from html form

Posted: Mon Jan 11, 2010 2:06 pm
by rigas
i have a local server but i dont know if it works as it should. anyway i changed the action value at the form to "http://127.0.0.1/test.php" and now it works. thank you