URL Form
Moderator: General Moderators
URL Form
I have a page which requires a variable in order to result. I want the variable and the URL of the page to be submitted by a form.
Here is what happens. A user goes to "index.php" page and there is a form with a text box for the client's name. The client will type in their name and hits SUBMIT. The form takes a predetermined URL (like 'www.site.com?client=') and attaches the client's name as it was typed into the form field. So now the form combines the URL and the client's name and uses it as the newURL. So it looks like this 'www.site.com?client=CLIENTNAME'. And goes to that page. How do I do this?
Thanks.
Here is what happens. A user goes to "index.php" page and there is a form with a text box for the client's name. The client will type in their name and hits SUBMIT. The form takes a predetermined URL (like 'www.site.com?client=') and attaches the client's name as it was typed into the form field. So now the form combines the URL and the client's name and uses it as the newURL. So it looks like this 'www.site.com?client=CLIENTNAME'. And goes to that page. How do I do this?
Thanks.
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
<form action="www.site.com" method=get>
<input type=text name=client>
<input type=submit value=SUBMIT>
</form>
But if you just want it to return back to your page with the client name in the url, leave the action part off. But if you want it target to somewhere else, then you can add the url there.
<input type=text name=client>
<input type=submit value=SUBMIT>
</form>
But if you just want it to return back to your page with the client name in the url, leave the action part off. But if you want it target to somewhere else, then you can add the url there.
Not quite...
It is supposed to append the CLIENTNAME (as it was input into the form) to the target URL. I have the form created here with the text field name = CLIENTNAME. When submit is hit, the form posts to a 'submit.php' page with code like this:
<?php
// Define post fields into simple variables. These are called CONSTANTS.
$domain = $_POST['domain'];
echo $domain;
// Redirect to webstat page with variable.
header('Location: http://www.site.com?config=$domain');
?>
The header redirect is not working...[/php_man]
<?php
// Define post fields into simple variables. These are called CONSTANTS.
$domain = $_POST['domain'];
echo $domain;
// Redirect to webstat page with variable.
header('Location: http://www.site.com?config=$domain');
?>
The header redirect is not working...[/php_man]
GOT IT!
My variable should not be inside the quotes...Here is the correct line.
header('Location: http://www.site.com?config=' . $domain);
header('Location: http://www.site.com?config=' . $domain);
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url]-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
Code: Select all
<form action="submit.php" method="post">
<input type="text" name="domain" />
<input type="submit" value="Submit" />
</form>Code: Select all
<?php
header("Location: http://www.site.com/?config=" . $_POST['domain']);
?>