Page 1 of 1

Need help with form output

Posted: Sun Jan 28, 2007 2:32 am
by rickou812
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I need a form to contact a URL with a specific output but I do not know how to strip out the unnecessary symbols.
Here is a copy of the form:

[syntax="html"]
<form method="get" name="Request" action="http://website.com/12345/">
<input name="" value="" type="hidden">
<table align="center" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td>	
<table class="formTable" align="center" border="0" cellpadding="0" cellspacing="0">
</table>
<table class="formTable" align="center" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="label" valign="middle"><label for="">Number:</label></td>
<td align="left">
<input size="10" maxlength="10" name="/" value="" type="">&nbsp;&nbsp;</td>
</tr></tbody></table><table align="center" border="0"></tbody>
<tr><td class="globalButtons" align="right" width="100%">
<button type="submit"><b>Request</b></button></td></tr></tbody></table>
</td></tr></tbody></table>
</form>
This is what this will output:
http://website.com/12345/?%2F=10
It adds the ?%2F=
I need it to output:
http://website.com/12345/10

How can I strip out the ?%2F

Thanks,
Richard Cook


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sun Jan 28, 2007 3:15 am
by superdezign
Firstly, %2F is the URLEncode for "/"
<input size="10" maxlength="10" name="/" value="" type="">
See it?

When you use the get method, it add the field name = the field value into the url. So.. rename that field for starters.


Secondly, I don't think you should be using the get method to do this. I think you should use method="post" and action="<?=$_SERVER['PHP_SELF']?>"

Then, at the very start of the file, do a check for if the form has been submitted, and redirect to the new location

Code: Select all

header("Location: http://website.com/12345/".$_POST['fieldname']);

Posted: Sun Jan 28, 2007 4:00 am
by rickou812
It looks like your on the right track, but I still can not get it to work.
Using the post method the "entered value is not added to the URL.
The website requires the value to be entered like this:
http://www.website.com/1234/value from form output
It must not contain any symbols, only the integer added from the form.

I hope this helps clarify...
Thanks for any assistance,
Richard Cook

Posted: Sun Jan 28, 2007 4:04 am
by superdezign
Did you rename the field that you want to pass and retrieve the same name from $_POST?

BTW, the post method doesn't add any string to URL; you have to do that yourself with header()

Posted: Sun Jan 28, 2007 4:12 am
by rickou812
It just isn't clicking in my head...lol
can you modify the code above to make it work?
Thanks,
Richard

Posted: Sun Jan 28, 2007 4:17 am
by louie35
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


what about removing the / from the input name. Not a very good way to name your fields:

modified code
[syntax="html"]
<form method="get" name="Request" action="http://website.com/12345/"> 
<input name="secret" value="" type="hidden"> 
<table align="center" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td>    
<table class="formTable" align="center" border="0" cellpadding="0" cellspacing="0"> 
</table> 
<table class="formTable" align="center" border="0" cellpadding="0" cellspacing="0"> 
<tbody> 
<tr> 
<td class="label" valign="middle"><label for="">Number:</label></td> 
<td align="left"> 
<input size="10" maxlength="10" name="number" value="" type="">&nbsp;&nbsp;</td> 
</tr></tbody></table><table align="center" border="0"></tbody> 
<tr><td class="globalButtons" align="right" width="100%"> 
<button type="submit"><b>Request</b></button></td></tr></tbody></table> 
</td></tr></tbody></table> 
</form> 

feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sun Jan 28, 2007 4:41 am
by superdezign
rickou812 wrote:It just isn't clicking in my head...lol
can you modify the code above to make it work?
Thanks,
Richard
You are a php programmer, right?
Nothing I've said is much more than a beginner could handle...

Code: Select all

<?php
if(isset($_POST['number']))
{
      header("Location: http://website.com/12345/".$_POST['number']);
}

Code: Select all

<form method="post" name="Request" action="<?=$_SERVER['PHP_SELF']?>"> 

Posted: Sun Jan 28, 2007 4:47 am
by rickou812
Yeap I got it now...lol
Just was having a blond moment...

Thanks,
Richard

Posted: Sun Jan 28, 2007 4:50 am
by superdezign
Don't worry. Maybe it's me. Maybe I assume too much. :roll:

Posted: Sun Jan 28, 2007 9:19 am
by feyd
Please try to avoid double posting threads in the future rickou812.