Jump to content


Photo

PHP Form POST/GET Trouble


  • Please log in to reply
5 replies to this topic

#1 vidyashankara

vidyashankara
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 18 April 2006 - 10:56 PM

<form method="get" action="http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=$_GET['id']">
<input type=text name=id value="">
<input type=submit value="Download">
</form>

I have a problem. In the above form, When some one types the value in the text, and clicks on download, i want the browser to go to the following site
[a href=\"http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=$id\" target=\"_blank\"]http://www.rcsb.org/pdb/downloadFile.do?fi...tureId=$id[/a]
where $_GET['id'] is what they typed in.

For Example, If they type in 1LYN, The browser must download
[a href=\"http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=1LYN\" target=\"_blank\"]http://www.rcsb.org/pdb/downloadFile.do?fi...tructureId=1LYN[/a]

Only the end of the URL changes. Whats wrong with my code?

Any help will be appreciated!




#2 acey99

acey99
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 18 April 2006 - 11:23 PM

[!--quoteo(post=366231:date=Apr 18 2006, 02:56 PM:name=Vids)--][div class=\'quotetop\']QUOTE(Vids @ Apr 18 2006, 02:56 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
<form method="get" action="http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=$_GET['id']">
<input type=text name=id value="">
<input type=submit value="Download">
</form>

I have a problem. In the above form, When some one types the value in the text, and clicks on download, i want the browser to go to the following site
[a href=\"http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=$id\" target=\"_blank\"]http://www.rcsb.org/pdb/downloadFile.do?fi...tureId=$id[/a]
where $_GET['id'] is what they typed in.

For Example, If they type in 1LYN, The browser must download
[a href=\"http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=1LYN\" target=\"_blank\"]http://www.rcsb.org/pdb/downloadFile.do?fi...tructureId=1LYN[/a]

Only the end of the URL changes. Whats wrong with my code?

Any help will be appreciated!
[/quote]


<form method="get" action="http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=$_GET['id']">
<input type=text name=id value="">
<input type=submit value="Download">
</form>

needs to be:

<form method="get" action="http://www.rcsb.org/...ructureId=<?php echo $_GET['id'] ?> ">
<input type=text name=id value="">
<input type=submit value="Download">
</form>


#3 KrisNz

KrisNz
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts
  • LocationAuckland, New Zealand

Posted 18 April 2006 - 11:26 PM

[!--quoteo(post=366231:date=Apr 19 2006, 08:56 AM:name=Vids)--][div class=\'quotetop\']QUOTE(Vids @ Apr 19 2006, 08:56 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
<form method="get" action="http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=$_GET['id']">
<input type=text name=id value="">
<input type=submit value="Download">
</form>

I have a problem. In the above form, When some one types the value in the text, and clicks on download, i want the browser to go to the following site
[a href=\"http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=$id\" target=\"_blank\"]http://www.rcsb.org/pdb/downloadFile.do?fi...tureId=$id[/a]
where $_GET['id'] is what they typed in.

For Example, If they type in 1LYN, The browser must download
[a href=\"http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=1LYN\" target=\"_blank\"]http://www.rcsb.org/pdb/downloadFile.do?fi...tructureId=1LYN[/a]

Only the end of the URL changes. Whats wrong with my code?

Any help will be appreciated!
[/quote]

change your form action to just [a href=\"http://www.rcsb.org/pdb/downloadFile.do\" target=\"_blank\"]http://www.rcsb.org/pdb/downloadFile.do[/a] then access id through the $_GET array in your downloadFile.do script. Obviously I dont know the purpose of this script but you should also probably do some checks on the file the user is requesting if you aren't already.


#4 vidyashankara

vidyashankara
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 21 April 2006 - 05:05 AM

Thanks, KrisNz! Thats worked :)

you rock!

Vidyashankara

#5 gizmola

gizmola
  • Administrators
  • Advanced Member
  • 4,664 posts
  • LocationLos Angeles, CA USA

Posted 21 April 2006 - 05:37 AM

[!--quoteo(post=366231:date=Apr 18 2006, 03:56 PM:name=Vids)--][div class=\'quotetop\']QUOTE(Vids @ Apr 18 2006, 03:56 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
<form method="get" action="http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=$_GET['id']">
<input type=text name=id value="">
<input type=submit value="Download">
</form>

I have a problem. In the above form, When some one types the value in the text, and clicks on download, i want the browser to go to the following site
[a href=\"http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=$id\" target=\"_blank\"]http://www.rcsb.org/pdb/downloadFile.do?fi...tureId=$id[/a]
where $_GET['id'] is what they typed in.

For Example, If they type in 1LYN, The browser must download
[a href=\"http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=1LYN\" target=\"_blank\"]http://www.rcsb.org/pdb/downloadFile.do?fi...tructureId=1LYN[/a]

Only the end of the URL changes. Whats wrong with my code?

Any help will be appreciated!
[/quote]


Well you didn't actually provide any php code ;) YOu might try this:

<form method="get" action="http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=<?php echo $_GET['id']; ?>">
<input type=text name=id value="">
<input type=submit value="Download">
</form>



#6 vidyashankara

vidyashankara
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 21 April 2006 - 05:41 AM

[!--quoteo(post=367105:date=Apr 21 2006, 12:37 AM:name=gizmola)--][div class=\'quotetop\']QUOTE(gizmola @ Apr 21 2006, 12:37 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Well you didn't actually provide any php code ;) YOu might try this:

<form method="get" action="http://www.rcsb.org/pdb/downloadFile.do?fileFormat=pdb&compression=NO&structureId=<?php echo $_GET['id']; ?>">
<input type=text name=id value="">
<input type=submit value="Download">
</form>
[/quote]

I did that. The page directs to [a href=\"http://www.rcsb.org/pdb/downloadFile.do?id=$id\" target=\"_blank\"]http://www.rcsb.org/pdb/downloadFile.do?id=$id[/a]
where $id is the text the user types in.

strange i know.

In the end, I just pointed the script to another file named download.php and used that to download the file.
works like a charm!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users