jesi Posted November 27, 2006 Share Posted November 27, 2006 hi, i have just started learning php and stucked with this code thougt somebody can help methe html code is like this<form name="test" action="test.php" method="post">Keyword: <input name="keyword" type="text"><input type="submit" value="go"></form>and the php part for test.php was like this[code=php:0]<?echo $keyword;?>[/code]so when i submit the test.html should not test.php echo the word inputed in the keyword feild Link to comment https://forums.phpfreaks.com/topic/28656-just-a-beginner-question-pls-help/ Share on other sites More sharing options...
trq Posted November 27, 2006 Share Posted November 27, 2006 This is an old and poorly coded example. Use this as your php.[code]<?php if (isset($_POST['keyword'])) { echo $_POST['keyword']; }?>[/code][/code] Link to comment https://forums.phpfreaks.com/topic/28656-just-a-beginner-question-pls-help/#findComment-131127 Share on other sites More sharing options...
onlyican Posted November 27, 2006 Share Posted November 27, 2006 You are using the POST methodSo you need to call the POST valuewhich in this case would beecho $_POST["keyword"];OR$keyword = $_POST["keyword"];echo $keyword;I would suggest this[code]<?php$keyword = isset($_POST["keyword"]) ? $_POST["keyword"] : "";echo $keyword;?>[/code]The line$keyword = isset($_POST["keyword"]) ? $_POST["keyword"] : "";Is the same as sayingif(isset($_POST["keyword"]){$keyword = $_POST["keyword"];}else{$keyword = "";}A good start for php iswww.w3schools.com/php Link to comment https://forums.phpfreaks.com/topic/28656-just-a-beginner-question-pls-help/#findComment-131134 Share on other sites More sharing options...
Cagecrawler Posted November 27, 2006 Share Posted November 27, 2006 You could just use:[code]<?phpecho $_POST['keyword'];?>[/code] Link to comment https://forums.phpfreaks.com/topic/28656-just-a-beginner-question-pls-help/#findComment-131137 Share on other sites More sharing options...
jesi Posted November 27, 2006 Author Share Posted November 27, 2006 thanx a lot for helping out, Link to comment https://forums.phpfreaks.com/topic/28656-just-a-beginner-question-pls-help/#findComment-131140 Share on other sites More sharing options...
trq Posted November 27, 2006 Share Posted November 27, 2006 [quote author=Cagecrawler link=topic=116495.msg474662#msg474662 date=1164661459]You could just use:[code]<?phpecho $_POST['keyword'];?>[/code][/quote]That will throw a warning if $_POST['keyword'] does not exist. Best to learn good habbits right from the get go. Link to comment https://forums.phpfreaks.com/topic/28656-just-a-beginner-question-pls-help/#findComment-131141 Share on other sites More sharing options...
jesi Posted November 27, 2006 Author Share Posted November 27, 2006 [quote author=thorpe link=topic=116495.msg474666#msg474666 date=1164661650][quote author=Cagecrawler link=topic=116495.msg474662#msg474662 date=1164661459]You could just use:[code]<?phpecho $_POST['keyword'];?>[/code][/quote]That will throw a warning if $_POST['keyword'] does not exist. Best to learn good habbits right from the get go.[/quote]but dat one didn't worked Link to comment https://forums.phpfreaks.com/topic/28656-just-a-beginner-question-pls-help/#findComment-131161 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.