bugzy Posted July 27, 2012 Share Posted July 27, 2012 Beginner's question guys. I'm about to do a search function now. I was thinking like this.. From an html form with a method get.. Let's say: textbox_search = 200 URL: www.mywebsite.com.php?id=200 <?php if(isset($_GET['search'])) { $query = "Select * from student where id = '{$_GET['id']}'"; $result = mysql_query = ($query,$connection) or die (mysql_error()); } else { $query = "Select * from student"; $result = mysql_query = ($query,$connection) or die (mysql_error()); } ?> Is this fine? or am I going to have an issue latter? Confused if I'm going to use post or get Link to comment https://forums.phpfreaks.com/topic/266356-basic-question-search-help/ Share on other sites More sharing options...
Pikachu2000 Posted July 27, 2012 Share Posted July 27, 2012 What do you think would happen if I changed the URL to http://www.I_hack_your_site.com/your_vulnerable_form_script.php?id=5%27%2BOR%2B%271%27+%3D+%271? Link to comment https://forums.phpfreaks.com/topic/266356-basic-question-search-help/#findComment-1364979 Share on other sites More sharing options...
bugzy Posted July 27, 2012 Author Share Posted July 27, 2012 What do you think would happen if I changed the URL to http://www.I_hack_your_site.com/your_vulnerable_form_script.php?id=5%27%2BOR%2B%271%27+%3D+%271? Pikachu2000.. Not really mean what you're trying to imply there but I do have mysql_real_escape_string function that I'm using on every sql statement that I'm passing on the server. I just didn't put it on the code above because it isn't part of my question and I just type the code directly here so you guys would understand it better. So it's better to just create a search landing page rather than directing the user to where he search it? Because what I want is to search and show results on the same page.. Link to comment https://forums.phpfreaks.com/topic/266356-basic-question-search-help/#findComment-1364980 Share on other sites More sharing options...
Pikachu2000 Posted July 27, 2012 Share Posted July 27, 2012 When you post code, I have to assume it's the actual code you're using . . . As far as using the same script both to search and display the results, there's nothing wrong with doing it that way. Link to comment https://forums.phpfreaks.com/topic/266356-basic-question-search-help/#findComment-1364982 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.