Clinker Posted April 19, 2006 Share Posted April 19, 2006 Hello everyone. I am a PHP noob and on the verge of pulling all my hair out!I am trying to make a web page that uses a simple form that lets you input data and then passes that data in the form of a variable to a PHP file which then displays it on another page. But for some reason i just can't get it to work. Could someone please tell me what i'm doing wrong. Thanks in advance for any help and advice. Clinker[u]HTML [/u]<html> <head> <title>My Form</title> </head> <body text="#0000ff"><div align="center"><table width="350" cellpadding="10" cellspacing="0" bgcolor="#fffacd" border="2"><tr><td><h4 align="center"><u>Roof Coverings</u></h4><form action="http://localhost/myfiles.php/names.php" method=post>Title: .................... <input type="text" name="YourName"><p>My real name is:<input type="text" name="RealName"><br><input type="submit" name="submit" value="Submit"></form></td></tr></table></div> </body> </html>[u]PHP code[/u]<?php$MyName = array('Colin' , 'David' , 'Peter' , 'Mark' , 'Simon' , 'Paul' , 'Lee');echo $MyName'Colin';?> Quote Link to comment https://forums.phpfreaks.com/topic/7832-forms-and-arrays/ Share on other sites More sharing options...
wildteen88 Posted April 19, 2006 Share Posted April 19, 2006 If you want to get the submitted data from the form then you'll do this:[code]<?php$name = $_POST['YourName'];$rname = $_POST['RealName'];echo "HI you're name is " . $name . ", your real name is: " . $rname;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7832-forms-and-arrays/#findComment-28535 Share on other sites More sharing options...
Clinker Posted April 19, 2006 Author Share Posted April 19, 2006 Hey that works great Wildteen88 many thanks! But is there anyway to keep the data in the php file once it's been added or until i decide to change it? Thanks again Clinker Quote Link to comment https://forums.phpfreaks.com/topic/7832-forms-and-arrays/#findComment-28573 Share on other sites More sharing options...
freshrod Posted April 19, 2006 Share Posted April 19, 2006 Greetings ClinkerIf you want to have the data available over several pages, or for the complete time that person is accessing the server, you might want to look into using a SESSION.SESSIONS are kind of a big topic for one post, so you might want to look around a bit. I learned enough about them to use them for multi-page forms from different tutorials and articles on the web.I hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/7832-forms-and-arrays/#findComment-28580 Share on other sites More sharing options...
Clinker Posted April 19, 2006 Author Share Posted April 19, 2006 Thanks Freshrod i'll have a look around mate. Quote Link to comment https://forums.phpfreaks.com/topic/7832-forms-and-arrays/#findComment-28582 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.