Forum Moderators: coopster
Any and all help is requested. I am currently migrating from an asp environment to php and need assistance converting my scripts. I am trying to pass a value from one page to another.
with asp, i use the following:
First page:
<form name="form1" method="post" action="XXX.asp">
<select name="ABC" id="ABC">
<option value="na">a</option>
<option value="b">b</option>
<option value="c">c</option>
<option value="d">d</option>
</select>
<input type="submit" name="Submit" value="Go">
</form>
Second page:
named XXX.asp
code:
<a href="http://www.example.net/click-123-456?SID=<%=request.form("ABC")%>" target="_blank">DEF </a>
What PHP code will place the value of the selection (A,B,C, or D) in the <%=request.form("ABC")%>" spot?
Thanks in advance!
[edited by: coopster at 4:57 pm (utc) on Sep. 20, 2004]
[edit reason] generalized url [/edit]
<a href="http://www.example.net/click-123-456?SID=<?php print $_POST['ABC']; ?>" target="_blank">DEF </a>
PHP has superglobals [php.net] that you'll want to read up on. Some other areas are an introduction [us4.php.net] and a simple tutorial [us4.php.net]. Best regards!
P.S. Our PHP Forum Library [webmasterworld.com] is also packed with information.
Your second question would be answered with the answer above and some kind of 'if some variable value is A, then print out 1' statement in php - like,
if($_POST['ABC'] == 'A') {
echo '1';
} elseif($_POST['ABC'] == 'B') {
echo '3';
}
at that one point; this same statement except with echo '2' and echo '4' replacing the above lines beginning with 'echo'. (echo is more or less like print).
for more on this 'if' business, see [be2.php.net...]
What you suggest seems to me (a newbie to PHP) very complicated. I guess what I was wondering was how I could incorporate a second value in my form and then post it in a spot on the XXX.asp page, just like the answer from coopster. The reason I want to do it this way, if possible, is that each selection (a,b,c,d, etc.) has a unique number assigned to it, and it seems that my coding would be extensive if i used a large number of if statements to gather the proper number. Maybe I just don't understand the implementation of your response. Thanks.
I guess this is what I was hoping for....
<form name="form1" method="post" action="XXX.asp">
<select name="ABC" id="ABC">
<option value="na">a</option>
<option value="b" "number=1" >b</option>
<option value="c">c</option>
<option value="d">d</option>
</select>
<input type="submit" name="Submit" value="Go">
</form>
See option "b" for what i was searching for. Thanks again.
Once I get the two variables assigned, I am simply appending them to a link, like is done with the first POST from Coopster. Also, one variable is going to be assigned a distinct URL based on the selection of a,b or c.
At this time, I do not need to do anything with them except populate my linking fields and create my new links.
I tried your "if" statements. they work as expected. There is no limit to the number of "ifs" i use, correct...because I will likely be adding over 200 of these statements to the code. if it works...i do not kow what i am complaining about, except that it seems to be a very long way to code to get the desired result.
Thanks again!