Jump to content

Archived

This topic is now archived and is closed to further replies.

Monshery

Dont know how to call this But need help in it .

Recommended Posts

Well i want to have a form with List manu which you pick some choice and it will send you to a page
that fits the choise - is this the way to do it ?.

[code]
<form name="GTP" action="<? echo $GTP; ?>" method="POST">
  <p>
    <select name="FAM" id="FAM">
      <option value="yaniv" selected>yaniv</option>
      <option value="shlomi">shlomi</option>
      <option value="kalfa">kalfa</option>
    </select>
  </p>
  <p>    <input type="submit" name="Submit" value="Submit">
    </p>
</form>
<?PHP
if ($_POST['FAM'] == 'yaniv')
$GTP = 'YANIV.PHP';
elseif ($_POST['FAM'] == 'shlomi')
$GTP = 'SHLOMI.PHP';
elseif ($_POST['FAM'] == 'kalfa')
$GTP = 'KALFA.PHP';
?>
[/code]

i am allready trying this for like 40 mins

Share this post


Link to post
Share on other sites
Hi,

This script would not work as the GTP variable is not declared at any point.

You would need to change your action to something like submit.php then in this file you can decide where you want your browser to be redirected to.

Something along the following lines:

[code]
// submit.php


[\code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=388017:date=Jun 26 2006, 11:52 AM:name=Monshery)--][div class=\'quotetop\']QUOTE(Monshery @ Jun 26 2006, 11:52 AM) [snapback]388017[/snapback][/div][div class=\'quotemain\'][!--quotec--]
thanks for quoting me mate - any clue how do i do it ?
[/quote]

Sorry mate it wont let me post my full replay???

Share this post


Link to post
Share on other sites
a javascript "jump box" is a pretty simple solution.

[a href=\"http://www.javascriptkit.com/combo.htm\" target=\"_blank\"]http://www.javascriptkit.com/combo.htm[/a]

Share this post


Link to post
Share on other sites
[!--quoteo(post=388022:date=Jun 26 2006, 12:03 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 26 2006, 12:03 PM) [snapback]388022[/snapback][/div][div class=\'quotemain\'][!--quotec--]
a javascript "jump box" is a pretty simple solution.

[a href=\"http://www.javascriptkit.com/combo.htm\" target=\"_blank\"]http://www.javascriptkit.com/combo.htm[/a]
[/quote]

Sorry about this there must be something in the code that wont allow me to post my full reply i have just tried to pm it to you but still no luck.

Share this post


Link to post
Share on other sites
Nice solution is ther a way not useing javascript ?

Or at least how do i use thi java script solution . can view the source cose of thoes pages

Share this post


Link to post
Share on other sites
Let's say this file is called index.php

[code]
//Put this at the TOP!!
<?PHP
if(isset($_POST['Submit'])){
if ($_POST['FAM'] == 'yaniv'){
$GTP = 'YANIV.PHP';}
elseif ($_POST['FAM'] == 'shlomi'){
$GTP = 'SHLOMI.PHP';}
elseif ($_POST['FAM'] == 'kalfa'){
$GTP = 'KALFA.PHP';}
else{
$GTP='index.php';};
header("Location: ".$GTP);
exit;
?>

//Other HTML stuff here


<form name="GTP" action"index.php" method="POST">
  <p>
    <select name="FAM" id="FAM">
      <option value="yaniv" selected>yaniv</option>
      <option value="shlomi">shlomi</option>
      <option value="kalfa">kalfa</option>
    </select>
  </p>
  <p>    <input type="submit" name="Submit" value="Submit">
    </p>
</form>[/code]

Because no info but the action is being sent, this would work. If there's other data you can pass them using sessions.

Orio.

Share this post


Link to post
Share on other sites
Let's say this file is called index.php

[code]
//Put this at the TOP!!
<?PHP
if(isset($_POST['Submit'])){
if ($_POST['FAM'] == 'yaniv'){
$GTP = 'YANIV.PHP';}
elseif ($_POST['FAM'] == 'shlomi'){
$GTP = 'SHLOMI.PHP';}
elseif ($_POST['FAM'] == 'kalfa'){
$GTP = 'KALFA.PHP';}
else{
$GTP='index.php';};
header("Location: ".$GTP);
exit;
?>

//Other HTML stuff here


<form name="GTP" action"index.php" method="POST">
  <p>
    <select name="FAM" id="FAM">
      <option value="yaniv" selected>yaniv</option>
      <option value="shlomi">shlomi</option>
      <option value="kalfa">kalfa</option>
    </select>
  </p>
  <p>    <input type="submit" name="Submit" value="Submit">
    </p>
</form>[/code]

Because no info but the action is being sent, this would work. If there's other data you can pass them using sessions.

Orio.

Share this post


Link to post
Share on other sites
Oh I think it's my fault.

Try now:

[code]
//Put this at the TOP!!
<?PHP
if(isset($_POST['Submit'])){
if ($_POST['FAM'] == 'yaniv'){
$GTP = 'YANIV.PHP';}
elseif ($_POST['FAM'] == 'shlomi'){
$GTP = 'SHLOMI.PHP';}
elseif ($_POST['FAM'] == 'kalfa'){
$GTP = 'KALFA.PHP';}
else{
$GTP='index.php';};
header("Location: ".$GTP);
exit;
};
?>

//Other HTML stuff here


<form name="GTP" action"index.php" method="POST">
  <p>
    <select name="FAM" id="FAM">
      <option value="yaniv" selected>yaniv</option>
      <option value="shlomi">shlomi</option>
      <option value="kalfa">kalfa</option>
    </select>
  </p>
  <p>    <input type="submit" name="Submit" value="Submit">
    </p>
</form>[/code]

And make sure you save it as index.php.

Orio.

Share this post


Link to post
Share on other sites
OK i put this at the top of the page
[code]
        <?PHP
        if(isset($_POST['Submit']))
        {
        if($_POST['FAM'] == 'yaniv')
                {
        $GTP = 'yaniv.PHP';
                 }
                else
                {
                $GTP = 'INDEX.PHP';
                }
        header("Location: "$GTP);
        exit;
        };
        ?>
[/code]



well it does bring an error up :

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\Yanivs\MMO-Date\INDEX.PHP:1) in C:\wamp\www\Yanivs\MMO-Date\INDEX.PHP on line 8

Share this post


Link to post
Share on other sites
Make sure the first sing on the page is the <?php tag. You can have any line breaks or even white spaces before of it.

Orio.

Share this post


Link to post
Share on other sites
OK i made it to work - but the form that i used no longer send me the Move variable with post the the next page -

This is on tomp of index.php :
[code]
<?PHP
    if(isset($_POST['submit']))
        {
        if($_POST['FAM'] == 'yaniv')
        {
            $GTP = 'Yaniv.PHP';
        }
        else
        {
            $GTP = 'INDEX.PHP';
        }
        header("Location: ".$GTP);
        exit;
        };
?>
[/code]

then a little bit in the batton i got this form:
[code]
<form name="GTP" action"index.php" method="POST">
  <p>
    <select name="FAM" id="FAM">
      <option value="yaniv" selected>yaniv</option>
      <option value="shlomi">shlomi</option>
      <option value="kalfa">kalfa</option>
    </select>
  </p>
      <p>
<font face="Verdana, Arial, Helvetica, sans-serif">Starting age:

           <input name="AGE" type="text" id="GOOD" value="0" size="10" maxlength="10">
      </p>
  <p>    <input type="submit" name="Submit" value="Submit">
    </p>
</form>
[/code]

then in file name . yaniv.php i have
[code]
<?PHP
if(isset($_POST['AGE']))
{
echo $_POST['AGE'] .$_POST['FAM'];
}
?>
[/code]

But when i run it i will just jump to Page yaniv.php without sending me
$_POST['AGE']
and
$_POST['FAM'].

If anyone knows why it would realy help .

I know its might be passiable doing with session but its too complicated with sessions.

Share this post


Link to post
Share on other sites
Sessions are not complicated, believe me. But if you really dont want to use them, and the information you need to pass is nothing like a password or any other sensetive information, do this:

[code]<?PHP
    if(isset($_POST['submit']))
        {
        $age=$_POST['age'];
        if($_POST['FAM'] == 'yaniv')
        {
            $GTP = 'yaniv.php';
        }
        else
        {
            $GTP = 'index.php';
        }
        header("Location: ".$GTP."?AGE=".$age."&FAM=".$GTP);
        exit;
        };
?>

Rest of HTML here...[/code]



And in yaniv.php and index.php do:

[code]<?PHP
if(isset($_GET['AGE']))
{
echo $_GET['AGE'] .$_GET['FAM'];
}
?>[/code]


If the information IS sensetive, you should use sessions.


Orio.

Share this post


Link to post
Share on other sites
LOL i didnt knew you can use this kinda of way :
header("Location: ".$GTP."?AGE=".$age."&FAM=".$GTP);
Well i solved it allready with sessions. alltough its not sensitive info.
i know session is not complicated i just sayed that useing session for this case is just not nessesery.
:-) THnx very much mate for help .
Realy helped me .

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.