villain222 Posted July 25, 2010 Share Posted July 25, 2010 OK, here is my scenario. I'm working on a method to find specific users ip address within a vpn. I have the DB all set to test, and I've got the search and form working correctly as I can echo the correct record. Now I'm looking for a way to pass the ip address that results straight to the browser and have it go there. Is that possible? I've been searching with no luck. All i can find is people who want to take the address bar information, not send to it. thanks for your help, if any. $terms = $_POST["terms"]; $query = "SELECT fullname, ownip FROM userdata WHERE fullname ='$terms'"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "user :{$row['fullname']} <br>" . "ip : {$row['ownip']} <br>" ; } Quote Link to comment https://forums.phpfreaks.com/topic/208813-mysql-result-as-a-direct-link-to-address-bar/ Share on other sites More sharing options...
trq Posted July 25, 2010 Share Posted July 25, 2010 echo "<a href='http://{$row['ownip']}'>{$row['fullname']}</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/208813-mysql-result-as-a-direct-link-to-address-bar/#findComment-1090830 Share on other sites More sharing options...
villain222 Posted July 26, 2010 Author Share Posted July 26, 2010 Thanks for your help, but won't this just give a link in the browser window? I'm really looking for someway to bypass the user and go to the link. Quote Link to comment https://forums.phpfreaks.com/topic/208813-mysql-result-as-a-direct-link-to-address-bar/#findComment-1091135 Share on other sites More sharing options...
dezkit Posted July 26, 2010 Share Posted July 26, 2010 header("location: http://" . $row['ownip'] . "/"); Quote Link to comment https://forums.phpfreaks.com/topic/208813-mysql-result-as-a-direct-link-to-address-bar/#findComment-1091137 Share on other sites More sharing options...
villain222 Posted July 26, 2010 Author Share Posted July 26, 2010 I was reading about the header() tag. Dezkit? Where does this go? My form is a hidden pop out JavaScript box. Sorry I don't have the code handy for that. I'm on my iPod right now. Should I put it after the query? How do I call it into action Quote Link to comment https://forums.phpfreaks.com/topic/208813-mysql-result-as-a-direct-link-to-address-bar/#findComment-1091397 Share on other sites More sharing options...
jcbones Posted July 26, 2010 Share Posted July 26, 2010 header() must be used before any output to the browser. So it must go at the very top of the script. Quote Link to comment https://forums.phpfreaks.com/topic/208813-mysql-result-as-a-direct-link-to-address-bar/#findComment-1091479 Share on other sites More sharing options...
villain222 Posted July 27, 2010 Author Share Posted July 27, 2010 the header isn't working. I looked it up and I see why not. the problem is that header() is the only thing that should run and then the rest of the page dies. Let me break this down for everyone. I have a form that queries the DB for a user, I get his ip as a result also, but as i get the result i want that Ip address passed to the browser as the site it should go to. no link clicking, almost like the google "i'm feeling lucky" button. straight to the result. I had a hobo's way to do it, and maybe the only way. send the ip result to a page that redirects to that address. is that possible? I've tried to pass the variable over url. didn't work. Quote Link to comment https://forums.phpfreaks.com/topic/208813-mysql-result-as-a-direct-link-to-address-bar/#findComment-1091543 Share on other sites More sharing options...
Pikachu2000 Posted July 27, 2010 Share Posted July 27, 2010 As already stated by others, header() is what you need. If you feel header() is not what you need, you need to rephrase your question, and provide more detail, and post whatever code you've already tried to use. Quote Link to comment https://forums.phpfreaks.com/topic/208813-mysql-result-as-a-direct-link-to-address-bar/#findComment-1091558 Share on other sites More sharing options...
villain222 Posted July 28, 2010 Author Share Posted July 28, 2010 Ok, i've figured out what to do. I made 2 files. one for the form that posts to the second. the second gets the info from the DB and then echos it into a meta refresh to the location with a 1 second refresh time. it works, not slick, but will do for now. The Header() tag wouldn't work because it was a case of the chicken before the egg. Header() stops all the rest of your script from going into action, so the query to the db never runs and gets the variable needed to do the job of redirection. Thanks for your assistance everyone, you lead me in the right directions. Quote Link to comment https://forums.phpfreaks.com/topic/208813-mysql-result-as-a-direct-link-to-address-bar/#findComment-1091955 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.