Link to home
Start Free TrialLog in
Avatar of robrodp
robrodpFlag for Mexico

asked on

Mixing html, php and asp

request comes from a get method

In html I can code:

<%=request("variable")%> and it works ok.

Is there an equivalent to insert a get variable with php?
Avatar of WebDevEM
WebDevEM
Flag of United States of America image

I think this is what you're looking for:
<?php echo $_GET['variable'] ?>

Open in new window

to display the value from mypage.php?variable=123.  It would need to be on a .php page though, so I'm not sure if you plan to mix php and asp on the same page somehow.
Avatar of robrodp

ASKER

I set my code to this line:


"http://ciiam.com/alta/index.asp?ejec=<?php echo $_GET['variable'] ?>"

I need it to be:

http://ciiam.com/alta/index.asp?ejec=variable"
What kind of page is this code on?  (asp or php?) Can you post more of the code so I can see what you're doing better?  

If this is on a mypage.php page, and you're trying to link to that URL, you might do something like this:
<a href="http://ciiam.com/alta/index.asp<?php echo $_GET['variable']; ?>">Alta</a>

Open in new window

If you could post more of the code, that would help.
Avatar of robrodp

ASKER

It is html code:

Origial code is:

It is on a php platform and the variable comes from and html page

<iframe name="Alta Simplificada"  frameborder="0"  width="1000" height="1200" src="http://ciiam.com/alta/index.asp"></iframe>

I need to pass the variable (ejec)  to the asp page:

<iframe name="Alta Simplificada"  frameborder="0"  width="1000" height="1200" src="http://site.com/alta/index.asp?ejec=<?php echo $_GET['variable'] ?>"></iframe>
Ok, thanks... I've created test pages (on an internal server, so I can't send a URL) and have it working here.
 
test.php
<iframe name="Alta Simplificada"  frameborder="0"  width="1000" height="1200" src="http://site.com/alta/index.asp?ejec=<?php echo $_GET['variable']; ?>"></iframe>

Open in new window

form.html
<form method="get" action="test.php">
<input type="text" name="variable" />
<button type="Submit">Submit</button>
</form>

Open in new window

If you fill in the input box and press submit, it sends variable to test.php and adds it to the end of the iframe's URL.  The key pieces that need to be paid attention to are that the NAME of the INPUT field (or SELECT, or whatever you use) needs to be the same as inside the quotes inside the $_GET['variable']  Also, my first example was missing a semicolon before the ?> so that may have caused an error.

With that code, if you enter a "3" in the box and hit SUBMIT, the php page will create
<iframe name="Alta Simplificada"  frameborder="0"  width="1000" height="1200" src="http://site.com/alta/index.asp?ejec=3"></iframe>

Open in new window

Avatar of robrodp

ASKER

Can you do it with a post?
Sure can - If you change the form to method="post" you just need to change the PHP code to $_POST['variable'].  There's an article at http://www.w3schools.com/php/php_forms.asp which explains it nicely and lets you experiment with it.
Avatar of robrodp

ASKER

can I send it with and index.html?ejec=3
Avatar of robrodp

ASKER

Sorry... I am confused will be back later Thx
Avatar of robrodp

ASKER

Ok...

I type this:

http://site1.com.mx/contactosoc/altas.html?ejec=123


<iframe name="Alta Simplificada"  frameborder="0"  width="1000" height="1200" src="http://site2.com/alta/index.asp?ejec=<?php echo $_GET['ejec']; ?>"></iframe>
ASKER CERTIFIED SOLUTION
Avatar of WebDevEM
WebDevEM
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of robrodp

ASKER

Any more ideas? What am I doing wrong?
Avatar of robrodp

ASKER

I've requested that this question be closed as follows:

Accepted answer: 500 points for WebDevEM's comment #a39464819
Assisted answer: 0 points for robrodp's comment #a39464212

for the following reason:

As usual.. I do so many things I get confused and confuse experts. Thx for your help
Avatar of Rob
That's not a solution so can you please clarify why you would accept the comment above as one?

You can use javascript to get the variables in the querystring:

<html>
<head>
<script>
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));

}
window.onload = function() {
	document.getElementById('myiframe').src = "http://site2.com/alta/index.asp?ejec=" + getParameterByName('ejec');
}
</script>
</head>
<body>
<iframe id="myiframe" name="Alta Simplificada"  frameborder="0"  width="1000" height="1200" src=""></iframe>

</body>
</html>

Open in new window

Tagit,

While yours is a valid solution using javascript, I believe I posted a valid solution using PHP as asked in the original post.  Which solution he ends up using ultimately relies on what direction he decides to take with his code (server-side php or client-side javascript) and which he is more comfortable implementing.  

No matter which way he goes with it, the goal is that he gets the job done that he came to solve.  I'm not fighting for points here, but to say my answer isn't a solution seems a bit strong.  It's a different solution than you would have used.

WebDevEM
Avatar of robrodp

ASKER

Hi...

Guys WebDevEM solution certainly works so it is a solution and I accepted as such.

I was trying to mix asp and asp codes and it did just that.

I am sure your javascript solution will work but it was posted after closed the question.

Otherwise I would have tested and considered your solution.
Avatar of robrodp

ASKER

I agree. But if WebDevEM posted a solution it worked and I accepted it,  I don't understand how another expert (tagit in this case) follows up (a closed question) says my accepted solution does not work (which does), post a different solution and gves another solution.

Am I mistaken here? Or should I consider addiitonal solutions once the question is closed as accepted?
Avatar of robrodp

ASKER

What does this mean? On Sep 04 I accepted the solution

I've requested that this question be closed as follows:

Accepted answer: 500 points for WebDevEM's comment #a39464819
Assisted answer: 0 points for robrodp's comment #a39464212

for the following reason:

As usual.. I do so many things I get confused and confuse experts. Thx for your help
Avatar of robrodp

ASKER

So it is not enough to accept an answer and assign ponts to close it? Just to make sure
Avatar of robrodp

ASKER

Ok.. Thx