[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Building a little cool masking tool using PHP, HTML, or something!

Posted on 2008-11-05
17
Medium Priority
?
347 Views
Last Modified: 2013-12-13
Hi,

So here is the scenario: I'm trying to build a website that allows a user to supply a URL as a result, builds a blank webpage at the backend that is used to redirect the user to the URL they provided and provides the user with the new url. So for example, if the user goes to my website (http://www.cebdata.com/maskit/) and types in lets say http://www.amazon.com/ into a text field or something and then the user presses submit, the thank you page comes up with a url something like http://www.executiveboard.com/survey123.html.

Now, if I send http://www.executiveboard.com/survey123.html the link to anyone, they are auto-redirected to www.amazon.com.

An alternative way is to somehow provide a masked url by typing in HTML into Outlook 2002 or 2003 but I can't seem to figure that out.

ANY ANY help is sincerely appreciated. I really need this to work to help the integrity of our marketing and sales efforts for senior management.
0
Comment
Question by:piyushdabomb
  • 9
  • 6
  • 2
17 Comments
 
LVL 29

Expert Comment

by:QPR
ID: 22893016
Are you planning to use a database in this scenario?
One thought maybe to have a table in your DB that has 2 (at least) columns. LinkID and URL.
The user types the URL into the text field and then this is inserted into the db alongside an ID.
The next page would feature the LinkID in the querystring.

So the initial URL may look like  http://www.executiveboard.com/goto.asp?LinkID=12345
12345 would be the LinkID (sorry I don't know PHP)
Then when someone clicks on that link your code would look up the URL associated with that LinkID and redirect them to that link.

You could "select" the URL based on the LinkID and then write this value into a response.redirect
0
 

Author Comment

by:piyushdabomb
ID: 22894379
Sure, I'm okay with throwing in a Database. Note that I have VERY limited database experience and therefore I might just access to start off with.

If I were to do this, how would i get this started? Please advise! How can I auto generate this 'blank' ID?

What is response.redirect? Could you provide a sample example of the code I would need to write to achieve tis?
0
 
LVL 29

Accepted Solution

by:
QPR earned 2000 total points
ID: 22898679
the blankid could simply be an incrementing number in the database.
In access this field is called autonumber.
So when you insert a new URL the autonumber field is auto populated and will increase by 1 each time you put another in.

Then you have (for my example) as asp page. You would need to Google how to set up the connection string to your Access DB.
Lets assume that this example os for the very first URL ever provided and the page is called Goto.asp
You would send someone a link such as www.yoursite.com/Goto.asp?ID=1

Then in your Goto.asp page you would retrieve the URL associated with the ID 1
Once you have this and have put it into a variable (hint) myVar = rs("url")
You redirect the user to that url with this tag in the head of the page...

<%
response.redirect(myVar)
%>

If you are new to db driven sites then the above may seem daunting but give it a go. It's pretty easy once you get your head around it. There are probably better ways to achieve it by using asp.net or other but asp has a fairly gentle learning curve.

Some links to help.
http://www.codeproject.com/KB/database/accessdb.aspx
Connection string to Access and how to return data from the db

http://www.w3schools.com/asp/default.asp
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 44

Expert Comment

by:scrathcyboy
ID: 22901043
Your question doesn't make a lot of sense, because you will actually have to OWN the domain --
 http://www.executiveboard.com/survey123.html.
and the survey page will have to be a REAL web page with an HTTP redirect in the main HTML page.  I don't see how this will ever work unless you OWN that domain, and manually create the pages you describe.
0
 

Author Comment

by:piyushdabomb
ID: 22901498
I own the domain! The domain is www.cebdata.com

I was merely using http://www.executiveboard.com as an example
0
 
LVL 44

Expert Comment

by:scrathcyboy
ID: 22901671
So --
the survey page will have to be a REAL web page with an HTTP redirect in the main HTML page. You will have to manually create the pages you describe, unless you develop a PHP script to make the pages for you, in which case you have a form with the link, it is sent to a PHP script, it creates a new page and puts an HTTP request for redirect into the header, and saves the page.

I would not do this for all the tea in China, however.  All a spammer or trojan writer has to do is discover your page, and he could create 1000s of pages using their automated software, all pointing to sites that load viruses and trojans on people's systems.  In a single blow, your site could be the Grand Central launch point for 1000s of virus pages across the web .. and when they track you down .... ooops.

BTW, these low-lifes are tractoring the web each day looking for forms to fill in, and within about 2 weeks of you putting it up, it will be found by all the spammers and virus writers you never wanted to know.  It may sound dramatized,  but it happens to people all the time on the WWW.
0
 

Author Comment

by:piyushdabomb
ID: 22901686
So what do you recommend I do then...? I need to make our client experience as smooth as possible!
0
 
LVL 29

Expert Comment

by:QPR
ID: 22901725
add a "captcha" control so that only humans can submit the form
0
 

Author Comment

by:piyushdabomb
ID: 22937043
Do I necessarily have to build the page? Can't I use some sort of database and store the original link and the final link in there?

There HAS to be a way to do this. Someone help me figure this out :(
0
 
LVL 29

Expert Comment

by:QPR
ID: 22937491
Well you started the question with "i'm trying to build a web site" so a page can't be too hard :)
But yes you do have to build a page if you want to interact with a person (other than use a webservice).
That said the page would probably amount to about 10 lines and would need no design as the user would never actually see it.
What you are wanting to do is incredibly simple and is outlined in the coments above.
0
 

Author Comment

by:piyushdabomb
ID: 22939246
I was reading up on your comments again and 'm up on giving it a try.

I'll keep you posted.
0
 

Author Comment

by:piyushdabomb
ID: 22942339
QPR,

I'm going slowly at this but in the meantime PLEASE check this out:

http://www.cebdata.com/SurveyLinks/RedirectorForm.htm

If a user types in a URL, the response comes out as you can see in the .asp page

How do I get a the SOURCE URL displayed from the form on the asp page? I can't seem to figure this out. I am able to connect to the database and display the ID # the way I wanted to. Should I just paste the original source into the database and retrive it as well?
0
 

Author Comment

by:piyushdabomb
ID: 22943008
I need help. I'm further but not quite there.

If you go to:

http://www.cebdata.com/SurveyLinks/RedirectorForm.htm

Supply a source url and click submit, you'll get a masked URL you can go to. If you then type in the masked URL, another .asp page loads up but apparently, it doesn't redirect me to the source page. Any clue? Please HELP Me with this. I'm SOO close!

It has to do with this line:

<meta http-equiv="refresh" content="5;url="" & <%=rsGetURL("SourceURL")%> & "">

Attached is the file that I'm attempting to redirect with.

Let me know your thoughts!
0
 
LVL 29

Expert Comment

by:QPR
ID: 22943573
No attachment.

Everything works fine for me. I pasted the masked URL into the addres bar and there I went.
Note you have to include the http:// bit in the text box else it will act as a link within the site e.g. http://www.cebdata.com/surveylinks/surveylink.asp?ID=47/www.google.com

If using asp you can do away with the <meta http-equiv="refresh" content="5;url="" & <%=rsGetURL("SourceURL")%> & "">
 and just use
<%
response.redirect(rsGetURL("SourceURL"))
%>

0
 

Author Comment

by:piyushdabomb
ID: 22946732
QPR,

Your logic gave me all the power I needed to get this going for me in ASP. I'm starting to enjoy ASP but one issue... PEOPLE ARE ON ASP.NET! I tried to play around with asp.net and its a lot more confusing for me than asp is. I do know a little bit of vb(i'm all vba) but I couldn't seem to get test.aspx right.

Should I move to asp.net just yet or should I feel out asp? The solution I was working with works very well and thanks a lot.

Regarding the asp piece, can we use for loops to parse through a string? In VB, I can use the following:

If Left(sURL,7) = "http://" then
'Save sURL in Access DB
elseif Left(sURL,3) = "www" then
'sURL = http:// & sURL
'Save sURL in Access DB
else
'sURL = "http://www."
'Save sURL in Access DB

Let me know your thoughts. I can even use a for loop.
0
 

Author Closing Comment

by:piyushdabomb
ID: 31513784
It is a good solution that forces the user to think through the given logic and implement the technology. Great learning curve!
0
 
LVL 29

Expert Comment

by:QPR
ID: 22947152
I'd get a base handle on asp first as it requires more coding by hand which will give you insight into the response/request side of things.
This way when you move to asp.net you'll have a better understanding of what is going on under the bonnet.
That plus your VBA skills mean you should be flying.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question