473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

redirect to other page if id is missing!!

155 100+
Hello all!!

i got a small problem ,not big :)

i got this example of a link in my site that display everything correctly!

http://www.mysite.com/product.php?id=200

now my problem is : if change the id by hand to id that is not exist ,then all
the page is getting a big mess because there is no data to show!!

normal users wont change the id by hand ,but i want to do something else!!

how do i hide the product.php to be index.php?id=200 ,i want to hide the direct link!

thanx ,and sorry for my poor english :)
Jan 4 '09 #1
3 2417
Dormilich
8,658 Expert Mod 8TB
for URL rewriting you can use Apache's mod_rewrite (via .htaccess) but that may not be enabled, depending on your server settings.

but generally, your script should handle the "wrong ID problem" itself (i.e. you should write some classes/methods/functions that can handle (invalid) IDs)

say, you have a couple of valid IDs, store them in an array and check if the ID from $_GET is contained in the array. if not, forward to a 404 or default page.

regards
Jan 4 '09 #2
canabatz
155 100+
the ids in my site is generated dynamicly on any new product!

i dont understand the $_GET thing and how to use it for my need!!

i prefer to hide the link to the product ,and if there is no product id of the number inserted by hand by some hacker or somthing ,it will be redirect to my main page ,the index.php!!

thanx!! ;)
Jan 5 '09 #3
Dormilich
8,658 Expert Mod 8TB
@canabatz
???

$_GET is a superglobal array, that stores all url parameters (PHP: $_GET - Manual). so in your case $_GET['id'] would give you the id value 200.

in the end, you have to store these values anywhere, otherwise using IDs wouldn't make sense, would it? and from that source you can fetch all IDs and validate the id value from the url against that.
@canabatz
how will you know that the inserted product id is invalid?

regards
Jan 5 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Nazir | last post by:
I am trying to do something pretty simple - but can't see how it can be done in ASP.NET. I have an aspx web page with a form which opens up a new window. The web page uses code behind to build...
4
by: simon | last post by:
If I have <form runat=server> then I can't submit to other page. If I remove runat=server then my controls on that page doesn't work? So I should redirect to other page from codeBehind but how...
5
by: darrel | last post by:
I have a 'cancel' button that should reload the current page. Ie, reset the page back to it's initial state. Is the best way to do this to simply have the event handler for that button redirect...
3
by: Big Charles | last post by:
Hi, How to redirect any page to Login.aspx? I tried writting this in web.config <authentication mode="Forms"> <forms name="aucoockie" loginUrl="wf_login.aspx" protection="All" path="/" />...
2
windows_mss
by: windows_mss | last post by:
hi Programmers, In course of my project now i facing an proble that i have to Redirect the page to some other Page after the Default Session Time Expire <sessionState ...
7
by: tomari | last post by:
hi all, can u please tell me what is the code to select a value from a dropdownlist ..and then passs this value to the other page .... along with it i have to take some details from the database...
10
by: chaos | last post by:
Hi all. How to redirect to other page when press ok button on alert message function checkstatus() { var status = document.getElementById("status").value; alert(status); <input...
2
by: suma | last post by:
hi all... i have array and iwant this array to other page in URL let the name of array is numbers and i fill this array by loop from data base when i write this .. echo "<META...
4
by: apking | last post by:
Hi Friends, iam newbie,This is my form Authentication script.i need to redirect another page when user correctly authenticated.how to redirect anothe rpage? <?php // Include the database...
8
luckysanj
by: luckysanj | last post by:
Dear Sir, How can i redirect index page to wwx.site.com/me/index.php. I have not fineshed front index page work so now i want to redirect this page to my personal information which is located...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.