collect data from html form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rigas
Forum Newbie
Posts: 6
Joined: Sun Jan 10, 2010 12:14 pm

collect data from html form

Post 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> 
 
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: collect data from html form

Post by social_experiment »

Why don't you use $_POST instead?

Code: Select all

 
<?php 
  echo $_POST['title'];
?>
 
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
rigas
Forum Newbie
Posts: 6
Joined: Sun Jan 10, 2010 12:14 pm

Re: collect data from html form

Post by rigas »

i tried this before and didn't work. i also tried the GET method which failed too.
chris8421
Forum Newbie
Posts: 5
Joined: Fri Jan 08, 2010 3:56 pm

Re: collect data from html form

Post 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.
rigas
Forum Newbie
Posts: 6
Joined: Sun Jan 10, 2010 12:14 pm

Re: collect data from html form

Post 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
Post Reply