Mike D Posted July 13, 2011 Share Posted July 13, 2011 I'm trying to add a simple feature to my website. I don't know much about php (nor the other languages), so I need a bit "spoon feeding" I want it to work like this: I type a name into a search box and hit enter or click "search". It searches an matching .txt document from a specific folder and displays the contains. Also, it would be good if it wasnt case-sensitive and if theres a typo in the name it would suggest some options.. At the moment I have some copy pasted code which I have heavily edited without knowing exactly what to do.. You can see it here: http://pastebin.com/MhJTLbUU If you need more information about the website or the structure etc, just ask and I will reply Thanks for you time! - Mike Quote Link to comment https://forums.phpfreaks.com/topic/241895-need-a-bit-help-with-a-simple-feature/ Share on other sites More sharing options...
AyKay47 Posted July 13, 2011 Share Posted July 13, 2011 you will probably want to store the data in a database. It would be much easier if you pasted your code to this thread please Quote Link to comment https://forums.phpfreaks.com/topic/241895-need-a-bit-help-with-a-simple-feature/#findComment-1242216 Share on other sites More sharing options...
Mike D Posted July 13, 2011 Author Share Posted July 13, 2011 you will probably want to store the data in a database. It would be much easier if you pasted your code to this thread please Yea I was thinking that also, I'm using phpmyadmin case "npc_drops": //if (!$post && isset($HTTP_RAW_POST_DATA)) // $post = $HTTP_RAW_POST_DATA; echo "<form method='post'><div class='table'><div class='header'><img src='infrastructure/content/images/Monster Database.png'></div></br></br><div class='content'> <input type='hidden' name='query' value='npc' /> <table style='width:75%;margin:auto;'> <tr> <td style='width:50%;'><font color=#000000>Type in monster name</font></br></br></td> <td style='width:50%;'><input type='text' maxlength='30' size='25' value='" . (isset($_POST['npc']) && !isset($_POST['clearit']) ? $_POST['npc'] : 1) . "' name='npc' /></br></br></td> <td><input type='submit' name='npc' value='Search' /></br></br></td> </tr> </form> "; Quote Link to comment https://forums.phpfreaks.com/topic/241895-need-a-bit-help-with-a-simple-feature/#findComment-1242222 Share on other sites More sharing options...
AyKay47 Posted July 13, 2011 Share Posted July 13, 2011 your form needs an action attribute, so it knows where to send the date.. <form method='post' action='test.php'> then on your test.php page you will have something like this mysql_connect('host', 'user', 'pass'); //your credentials mysql_select_db('test'); //you credentials $submit_button = $_POST['npc']; if(isset($submit_button)){ //check if the submit button has been clicked $name = $_POST['name']; //you need to change your textbox name from npc $name = mysql_real_escape_string(trim($name)); //clean up the input for insertion $query = mysql_query("INSERT INTO table_name VALUES('$name')"); //place inside VALUES the values that you want to insert into your db if($query){ print "Successfully inserted"; }else{ exit(mysql_error()); } } Quote Link to comment https://forums.phpfreaks.com/topic/241895-need-a-bit-help-with-a-simple-feature/#findComment-1242279 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.