|
| Index | Recent Threads | Unanswered Threads | Who's Online | User List | Help |
|
|
| No member browsing this thread |
|
Thread Status: Active Total posts in this thread: 19
|
|
| Author |
|
|
Stranger Joined: Dec 11, 2008 Post Count: 11 Status: Offline |
<html> <head> <title>Form</title> <body> Name: <input type="text" name="name" /> Age: <input type="text" name="age" /> <input type="submit" value="send" /> Welcome <?php echo $_POST(["name"]); ?>.<br /> You are <?php echo $_POST["age"] ?> years old. </form> </body> </html> i'm trying to get the $_post to work but i can't for some reason...every time i try the run the code with $_post i get an err message....can some one tell why it wont run on my computer or my server....everything works good i just can't get it to print anyhting on my page |
||
|
|
Advanced Member USA Joined: Aug 14, 2007 Post Count: 1129 Status: Offline |
$_POST assumes that your form has been submitted. I think this is what you were attempting to do: -- missing a closing head tag -- missing an opening form tag -- minor reformatting Basically, what this does is use a PHP snippet to check if the form has been submitted. If it has, it grabs the form values and displays the welcome message. If not, the form gets displayed. ---------------------------------------- Benjamin Falk | student : designer : developer Twitter: falkencreative |
||
|
|
Stranger Joined: Dec 11, 2008 Post Count: 11 Status: Offline |
<html> <head> <title>Form</title> <body> <?php if($_GET["action"] == 'send'){ echo ('Data = '(.$_GET['keyword'])); } ?> <form method="get" action="index.php" <fieldset> <legend>Form Data</legend> <p> <label for="keyword">Search keyword:</label> <input type="text" name="keyword" size="25" /> </p> <p> <input type="submit" name="action" value="send" /> </p> </fieldset> </font> </body> </html> I keep getting an err with post and echo....can some one tell why i'm getting that err.....thanks...... |
||
|
|
Advanced Member USA Joined: Aug 14, 2007 Post Count: 1129 Status: Offline |
-- unnecessary parenthesis in your echo statement -- no closing ">" on your opening form tag -- extra unneccessary "</font>" tag (don't use <font> use CSS) -- use isset() to check if the form has been submitted... otherwise, you'll get an error since PHP is checking a variable that doesn't exist yet Corrected code: <html>---------------------------------------- Benjamin Falk | student : designer : developer Twitter: falkencreative |
||
|
|
Stranger Joined: Dec 11, 2008 Post Count: 11 Status: Offline |
How come my fieldset falls down when i click on send the echo doest work? |
||
|
|
Advanced Member USA Joined: Aug 14, 2007 Post Count: 1129 Status: Offline |
How come my fieldset falls down when i click on send the echo doest work? You are going to have to rephrase your question. It doesn't seem to make much sense. I did test my code above and I know it works correctly. ---------------------------------------- Benjamin Falk | student : designer : developer Twitter: falkencreative |
||
|
|
Stranger Joined: Dec 11, 2008 Post Count: 11 Status: Offline |
what editor are you using....maybe if i use the same editor it will work or could have something to do with my configuration....i'm using php expert editor 4.0......it has its on server could it be that i'm not configuring it right |
||
|
|
Advanced Member USA Joined: Aug 14, 2007 Post Count: 1129 Status: Offline |
what editor are you using....maybe if i use the same editor it will work or could have something to do with my configuration....i'm using php expert editor 4.0......it has its on server could it be that i'm not configuring it right What text editor you are using doesn't matter, it's all working with the same code. I am using Textmate on my mac / Notepad++ on a PC. Also, this is very basic script, so you shouldn't need to adjust any server settings. Just to be clear, here is what it currently does for me: -- I open the page. The form displays, with an input that asks what search keyword I want -- I enter something, "test" in this case, and press "send" -- The page refreshes, and I then get the text "Data = test" at the top of a page, followed by the form. If that isn't what you were intending, you'll need to explain what you were expecting the code to do. It is working correctly, and I have tested it on two machines. If you are still getting some sort of error, you'll need to explain clearly what issue you are running into. ---------------------------------------- Benjamin Falk | student : designer : developer Twitter: falkencreative |
||
|
|
Stranger Joined: Dec 11, 2008 Post Count: 11 Status: Offline |
its running for me and i'm get the the text box and everyting but when i type something into the box and press send the page refreshes and i get the same screen as it did when i run it....it doesnt show me the "Data= " and text that i type into it |
||
|
|
Advanced Member USA Joined: Aug 14, 2007 Post Count: 1129 Status: Offline |
OK, a couple questions then... -- Do you have a server running (you know you have to have a server to display .PHP files correctly, right?). Either you'll need to upload your files to your hosting and view them in your browser, or you'll need to use something like WAMP (http://www.wampserver.com/en/ -- PC) or MAMP (http://www.mamp.info/en/index.php -- for mac). -- If you are using a server on your local machine, are you actually viewing your files on the server (your URL in the browser should be something like: http://localhost/) or are you just accessing the file directly (the URL in your browser will start with file:///C... etc). If you are trying to access the file directly, it won't work. It needs to be run through localhost. ---------------------------------------- Benjamin Falk | student : designer : developer Twitter: falkencreative ---------------------------------------- [Edit 1 times, last edit by falkencreative at Dec 12, 2008 12:25:14 PM] |
||
|
|
|
|
|
Current timezone is GMT Mar 20, 2010 12:17:31 PM |