| |||||||
This is a discussion on Quick PHP Help? within the Technical Help forums, part of the Off Topic category; So basically I have a single field form, and I want whatever is inputted into the field to be added ...
![]() |
| | Thread Tools |
| | #1 |
| Mini Mac Join Date: Mar 2007 Location: UK
Posts: 4,655
![]() ![]() ![]() ![]() ![]() | Quick PHP Help?So basically I have a single field form, and I want whatever is inputted into the field to be added on to the end of a link, example: User input='100' URL = 'http://www.website.com/999&extension=100 Currently I have this in my index.php file: Code: form action="submit.php" method="post"> <input name="FieldName" type="text" /> </div> <input type="image" src="image/source.jpg" width="x" height="x" /> </form> Code: <?php
// Change to the URL you want to redirect to
$URL="http://www.website.com/999&extension= $_POST["FieldName"];
header ("Location: $URL");
?>
Maybe it would be better to get rid of submit.php completely? I can take out the '$_POST["FieldName"]' part and just put text or a number and it works fine, but I want it to use the value that the user has typed into the form field. Any help will be much appreciated! Thanks |
|
| | #2 |
| Mini Mac Join Date: Mar 2007 Location: UK
Posts: 4,655
![]() ![]() ![]() ![]() ![]() | Sorry, could this please be moved to technical help? |
|
| | #3 |
| Mini Mac | There are two main issues that I can see with your code. Issue one is that there is no opening < on the form tag in your HTML. To be honest I'm guessing that you have included this, and it just got cut out in the copy/paste, but I thought I'd mention it just to make sure. The second problem is that you have no closing " quote at the end of your $URL definition. The corrected code is: Code: <?php
// Change to the URL you want to redirect to
$URL="http://www.website.com/999&extension={$_POST["FieldName"]}";
header ("Location: $URL");
?>
Hope that makes sense? |
|
| | #4 |
| Mini Mac Join Date: Mar 2007 Location: UK
Posts: 4,655
![]() ![]() ![]() ![]() ![]() | Got to spread the love before giving you rep, thanks so much it works perfectly!! |
|
| | #5 |
| iPod 20gb Join Date: Feb 2008 Location: Birmingham
Posts: 892
![]() | I gave rep for you as it was a very helpful post |
|
| | #6 |
| iPod Nano 4GB Join Date: Jul 2009 Location: My underground lair
Posts: 305
![]() | alternatively, appending using . would work: Code: <?php
// Change to the URL you want to redirect to
$URL="http://www.website.com/999&extension=" . $_POST["FieldName"];
header ("Location: $URL");
?>
|
|
![]() |
| Thread Tools | |
| |