Page 1 of 1

URL Form

Posted: Thu Jul 29, 2004 7:57 pm
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.

Posted: Thu Jul 29, 2004 8:32 pm
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.

Not quite...

Posted: Thu Jul 29, 2004 8:43 pm
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]

GOT IT!

Posted: Thu Jul 29, 2004 8:58 pm
by AliasBDI
My variable should not be inside the quotes...Here is the correct line.

header('Location: http://www.site.com?config=' . $domain);

Posted: Thu Jul 29, 2004 9:15 pm
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]

Posted: Thu Jul 29, 2004 9:25 pm
by Illusionist
Ok... I don't know what you're asking for then...

Posted: Thu Jul 29, 2004 10:26 pm
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']);
?>

Posted: Thu Jul 29, 2004 11:10 pm
by feyd
don't forget [php_man]urlencode[/php_man]() ;)