e1seix Posted October 12, 2007 Share Posted October 12, 2007 I have a bit of a problem... I have over 3000 potential redirection in a database... with the wrong address! The shame! What my code does is request this from mySQL and then it redirects to the site. So write up a simple "if" statement? Not possible, as every one of these links to a product with an individual 4 digit code. What I need your help with is a code that will use the $_GET statment to request the "id" (4 digit code) and redirect accordingly with the new file path. Is this possible? Example: This is the incorrect file path... http://www.cheapsmells.com/product_show_new.asp?id=5696&ref=webgains&siteid=20592 This is the correct file path... http://www.awin1.com/awclick.php?awinmid=911&awinaffid=74040&p=http://www.cheapsmells.com/viewProduct.php?id=5696 How can I allow the original link to go to the address bar and then redirect it using the $_GET function to the correct site? Many thanks, Quote Link to comment https://forums.phpfreaks.com/topic/72915-solved-redirection-problem/ Share on other sites More sharing options...
e1seix Posted October 12, 2007 Author Share Posted October 12, 2007 OK, I've thought of my own potential solution. the 4 digit number has be between 0000 & 9999 I could run a simple "if" statement to say for example If { (madeupurl == 'http://www.cheapsmells.com/product_show_new.asp?id=[$variable]&ref=webgains&siteid=20592' echo '<a href="http://www.awin1.com/awclick.php?awinmid=911&awinaffid=74040&p=http://www.cheapsmells.com/viewProduct.php?id=[$variable]" target="_new">Link</a>'; } and simply declare $variable as some loop that will search for all numbers between the parameters of 0000 & 9999, hold that specific number, and redirect Can someone help me write this code. While I can figure out the solution, the execution is a little beyond me... Quote Link to comment https://forums.phpfreaks.com/topic/72915-solved-redirection-problem/#findComment-367738 Share on other sites More sharing options...
GamingWarrior Posted October 12, 2007 Share Posted October 12, 2007 ok if there is always 51 letters befor(http://www.cheapsmells.com/product_show_new.asp?id=) and 26 letters after(&ref=webgains&siteid=20592) then you could save the link as a variable with the ends trimmed. I hope i make sense Quote Link to comment https://forums.phpfreaks.com/topic/72915-solved-redirection-problem/#findComment-367751 Share on other sites More sharing options...
e1seix Posted October 12, 2007 Author Share Posted October 12, 2007 no you'll need to explain that one a bit furher... lol see if you can make sense of this instead... $starter = 1; $code = ($starter > 0) && ($starter < 9999); $cheapsmells3=('http://www.cheapsmells.com/product_show_new.asp?id=".$code."/ref=webgains&siteid=20592'); if ($row['buy_link'] == $cheapsmells3) { // has remainder so add one page echo '<a href="http://www.awin1.com/awclick.php?awinmid=911&awinaffid=74040&p=http://www.cheapsmells.com/viewProduct.php?id='.$code.'" target="_new">'; echo '<img alt="BUY" height="15" src="/BUY.gif" target="_new" width="50" /></a>'; } else { echo '<a href="'.$row['buy_link'].'" target="_new">'; echo '<img alt="BUY" height="15" src="/BUY.gif" target="_new" width="50" /></a>'; } i'm trying to enable it to lift the variable $code from the filepath - it's a number between 0000 & 9999 - and implement it into the "if" statement Quote Link to comment https://forums.phpfreaks.com/topic/72915-solved-redirection-problem/#findComment-367812 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.