0

I would like to start off saying that I'm very new to programming. I am developing a site (www.example.com) that has multiple hyperlinks.

When a user visits my site I want all the links to be defaulted to the back office of another site (www.tvcmatrix.com/mhammonds) I use. How do I set the links to redirect to the query string value based on inputted text from a form that is on my site (www.example.com)?

In other words, if the url reads www.example.com/?user=abelliard, how do I make all the links on the site change to "www.tvcmatrix.com/abelliard"? If no query string is present, then I would like for the links to be www.tvcmatrix.com/mhammonds.

Here is a file on my site for the form called "form.asp"

<!DOCTYPE html>
<html>
    <body>
        <form action="viral.asp" method="get" name="input" target="_self">
            Your TVC Matrix Associate ID: <input type="text" name="user" />
            <input type="submit" value="Submit" />
        </form>
    </body>
</html>

Here is the "viral.asp" file in the "form.asp" file.

<%@ language="javascript"%>
<!DOCTYPE html>
<html>
    <body>
    <%
        var id = Request.QueryString("user");                    
        Response.Write("Your URL is: www.mca.com/?user=" + id)
    %>
    </body>
</html>

1 Answer 1

-1

You can use an if statement and set the value to mhammonds if the querystring is empty ("")

<%
Dim id = Request.QueryString("user")
Dim url = id                 
If id = ""  Then
  url = "mhammonds"
End If
 'Every URL in your site reads    
Response.Write "www.tvcmatrix.com/" & id 

%>

`

Sign up to request clarification or add additional context in comments.

2 Comments

I inputted this, but it didn't work for me. I did however change the Dim to var, lower cased the "I's" in if, and changed the & to + being that I am using javascript and not vbscript. I wasn't exactly sure where to put it either so I tried multiple places. None worked for me. @schar
After <html>, add <head> and put in <base href=" then your <% .. %> code, then "></head>.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.