Jump to content


Photo

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


  • Please log in to reply
16 replies to this topic

#1 Monshery

Monshery
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts

Posted 26 June 2006 - 10:43 AM

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 ?.

<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';
?>

i am allready trying this for like 40 mins

#2 d_barszczak

d_barszczak
  • Members
  • PipPipPip
  • Advanced Member
  • 188 posts
  • LocationBradford - UK

Posted 26 June 2006 - 10:49 AM

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=auto:0]
// submit.php


[\code]

When all else fails - Try reading the manual.

Integrated IT Systems Ltd


#3 Monshery

Monshery
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts

Posted 26 June 2006 - 10:52 AM

thanks for quoting me mate - any clue how do i do it ?

#4 d_barszczak

d_barszczak
  • Members
  • PipPipPip
  • Advanced Member
  • 188 posts
  • LocationBradford - UK

Posted 26 June 2006 - 11:00 AM

[!--quoteo(post=388017:date=Jun 26 2006, 11:52 AM:name=Monshery)--][div class=\'quotetop\']QUOTE(Monshery @ Jun 26 2006, 11:52 AM) View Post[/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???

When all else fails - Try reading the manual.

Integrated IT Systems Ltd


#5 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 26 June 2006 - 11:03 AM

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]
Legend has it that reading the manual never killed anyone.
My site

#6 d_barszczak

d_barszczak
  • Members
  • PipPipPip
  • Advanced Member
  • 188 posts
  • LocationBradford - UK

Posted 26 June 2006 - 11:05 AM

[!--quoteo(post=388022:date=Jun 26 2006, 12:03 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 26 2006, 12:03 PM) View Post[/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.

When all else fails - Try reading the manual.

Integrated IT Systems Ltd


#7 Monshery

Monshery
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts

Posted 26 June 2006 - 11:07 AM

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

#8 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 26 June 2006 - 11:16 AM

Let's say this file is called index.php

//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>

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

Orio.
Think you're smarty?

(Gone until 20 to November)

#9 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 26 June 2006 - 11:16 AM

Let's say this file is called index.php

//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>

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

Orio.
Think you're smarty?

(Gone until 20 to November)

#10 Monshery

Monshery
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts

Posted 26 June 2006 - 11:36 AM

Not working this way as well

#11 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 26 June 2006 - 11:54 AM

Oh I think it's my fault.

Try now:

//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>

And make sure you save it as index.php.

Orio.
Think you're smarty?

(Gone until 20 to November)

#12 Monshery

Monshery
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts

Posted 26 June 2006 - 12:05 PM

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



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

#13 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 26 June 2006 - 12:56 PM

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.
Think you're smarty?

(Gone until 20 to November)

#14 Monshery

Monshery
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts

Posted 27 June 2006 - 10:51 AM

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 :
<?PHP
    if(isset($_POST['submit']))
        {
        if($_POST['FAM'] == 'yaniv')
        {
            $GTP = 'Yaniv.PHP';
        }
        else
        {
            $GTP = 'INDEX.PHP';
        }
        header("Location: ".$GTP);
        exit;
        };
?>

then a little bit in the batton i got this form:
<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>

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

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.

#15 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 27 June 2006 - 12:45 PM

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:

<?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...



And in yaniv.php and index.php do:

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


If the information IS sensetive, you should use sessions.


Orio.
Think you're smarty?

(Gone until 20 to November)

#16 Monshery

Monshery
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts

Posted 27 June 2006 - 01:41 PM

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 .

#17 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 27 June 2006 - 02:19 PM

Bevakasha :D

Orio.
Think you're smarty?

(Gone until 20 to November)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users