URL Form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

URL Form

Post by AliasBDI »

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.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

<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.
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

Not quite...

Post by AliasBDI »

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]
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

GOT IT!

Post by AliasBDI »

My variable should not be inside the quotes...Here is the correct line.

header('Location: http://www.site.com?config=' . $domain);
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Please use

Code: Select all

and

Code: 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

Post by Illusionist »

Ok... I don't know what you're asking for then...
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Code: Select all

&lt;form action="submit.php" method="post"&gt;
&lt;input type="text" name="domain" /&gt;
&lt;input type="submit" value="Submit" /&gt;
&lt;/form&gt;

Code: Select all

<?php 
header("Location: http://www.site.com/?config=" . $_POST['domain']);
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

don't forget [php_man]urlencode[/php_man]() ;)
Post Reply