You are here: Re: Form field entry directs to diff URLs based on entry? « HTML « IT news, forums, messages
Re: Form field entry directs to diff URLs based on entry?

Posted by Luigi Donatello Asero on 04/30/06 00:14

"Luigi Donatello Asero" <jaggillarfotboll@telia.com> skrev i meddelandet
news:eDQ4g.54935$d5.209261@newsb.telia.net...
>
> "Toby Inkster" <usenet200604@tobyinkster.co.uk> skrev i meddelandet
> news:navci3-gh7.ln1@ophelia.g5n.co.uk...
> > AtomicBob wrote:
> >
> > > Example 1:
> > > user enters "Tony Tiger" in the field and hits submit.
> > > user is then sent to tonytiger.exampledomain.com.
> > >
> > > Example 2:
> > > user enters "johnnywalker" in the field and hits submit.
> > > user is then sent to johnnywalker.exampledomain.com.
> >
> > Unless you use some client-side scripting, a form will always submit to
> > just one place.
> >
> > However, that one place could be a script that looks at the form
> > submission and sends an HTTP 301 redirect to various different places
> > based on the form contents.
> >
> > Here's some example code:
> >
> > <form action="redirect.php" method="get">
> > <fieldset>
> > <legend>enter a name</legend>
> > <input name="name">
> > <input type="submit">
> > </fieldset>
> > </form>
> >
> > <?php
> > // This file is "redirect.php".
> >
> > // What is my domain name?
> > $mydomain = 'example.com';
> >
> > // You used 'exampledomain.com' -- you might not have known
> > // that there exists a domain 'example.com' which is specially
> > // reserved just for examples.
> >
> > // What name has the user entered?
> > $name = $_GET['name'];
> >
> > // Convert down to lower case
> > $name = StrToLower($name);
> >
> > // Remove all characters except 0-9 and a-z
> > $name = pReg_Replace('/[^0-9a-z]/', '', $name);
> >
> > // Generate Final URL
> > $url = "http://{%s}.{$mydomain}/";
> >
> > // Redirect
> > Header("HTTP/1.1 301 Redirect");
> > Header("Location: {$url}");
> > ?>
> >
> > --
> > Toby A Inkster BSc (Hons) ARCS
> > Contact Me ~ http://tobyinkster.co.uk/contact
>
> How does the file redirect.php file decide to which URL it shall send the
> form content?


Do you mean perhaps that it will show a page with 404 error to the user if
he or she has filled in the form a name which contains forbidden
characters?


--
Luigi Donatello Asero
https://www.scaiecat-spa-gigi.com/sv/faktaomitalien.php
今天二零零六年四月二十九日
星期五六

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация