Jump to content

Recommended Posts

This is my menu.php(part of it) file, what am trying to do is to check what language would the user choose,
[code]
                <form method='post' action='index.php'>
                        <a class='menu' href='index.php?ID'>
                        <input type='hidden' name='ID' id='ID_Eng' value='ID_Eng'><img src='content/images/en.gif' border=0 alt='English'></a>
                        <a class='menu' href='index.php?ID'>
                        <input type='hidden' name='ID' id='ID_Rus' value='ID_Rus'><img src='content/images/ru.gif' border=0 alt='Russian'></a>
                        <a class='menu' href='index.php?ID'>
                        <input type='hidden' name='ID' id='ID_Ger' value='ID_Ger'><img src='content/images/ge.gif' border=0 alt='German'></a>
                        <input type='hidden' name='Check_ID' value='Check'>
                </form>



[/code]

and this is my index.php(part of it)
[code]
<?php
if (!@$page) $page = "home.htm";


if ($_POST['Check_ID'])
{
    
       $id=$_GET['ID'];


    if ($id = 'ID_Eng')
    {
    $directory = "content/en/";
    }
    else if ($id = 'ID_Rus')
    {
    $directory = "content/ru/";
    }
    else if ($id = 'ID_Ger')
    {
    $directory = "content/ge/";
    }
}

[/code]

and for the rest of the menu thats what i got:
[code]
    <tr><td class='menuDivLine'></td></tr>";
    
    
        if ($page=="home"){echo"<tr bgcolor='#C5B881'>";}
        else{echo"<tr onMouseover=this.bgColor='#C5B881'; onMouseout=this.bgColor='#ACE6FD';  bgcolor='#ACE6FD'>";}echo"
            <td><a class='menu' href='?page=home.htm'>Home</a></td>
    </tr>
    
    <tr><td class='menuDivLine'></td></tr>";
        if ($page=="fact_sheet"){echo"<tr bgcolor='#C5B881'>";}
        else{echo"<tr onMouseover=this.bgColor='#C5B881'; onMouseout=this.bgColor='#9CDAF3';  bgcolor='#9CDAF3'>";}echo"
        <td><a class='menu' href='?page=fact_sheet.htm'>FACT SHEET</a></td>
    </tr>
[/code]

What am I doing wrong, Thanks
Link to comment
https://forums.phpfreaks.com/topic/4593-sending-an-id-to-select-langauage/
Share on other sites

I think you've got a bit confused as to whether to use GET or POST to determine this.

You won't have posted anything because despite your form having a method of post, there is no submit form button. Consequently nothing will get posted.

If you want to use GET with <a> tags and hyperlinks, you don't need to use the form at all.

I think you sould decide which method you would rather use, we can then go from there.
[!--quoteo(post=353557:date=Mar 10 2006, 04:36 AM:name=lessthanthree)--][div class=\'quotetop\']QUOTE(lessthanthree @ Mar 10 2006, 04:36 AM) [snapback]353557[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I think you've got a bit confused as to whether to use GET or POST to determine this.

You won't have posted anything because despite your form having a method of post, there is no submit form button. Consequently nothing will get posted.

If you want to use GET with <a> tags and hyperlinks, you don't need to use the form at all.

I think you sould decide which method you would rather use, we can then go from there.
[/quote]

I think using the <a> tags would be much better, I don’t think the form is needed, but am not sure how to implement it.

Thanks
In that case..


do your href's something like the following and lose the form.


[code]
<a href='index.php?language=eng'>English</a>
<a href='index.php?language=ru'>Russian</a>

//etc
[/code]

then on your index.php page

[code]

switch($_GET["language"])
{
     case("eng"):
           $directory = 'content/en';
     break;

     case("ru"):
            $directory = 'content/ru';
      break;

    //etc

     default: print "An Invalid or No language was specified";
}

[/code]
thats what i have for the moment but its aint working yet:

menu.php
[code]
echo"    
<!-- menu start -->
<table border='0' cellpadding='0' cellspacing='0'  valign='top'>
    
    <tr>
        <td><img src='template/images/left_img.jpg'></td>
    </tr>
    <tr>                    
            <td align='center' valign='middle' bgcolor='#B5E3F5'>
                        
                        <a class='menu' href='index.php?language=en'><img src='content/images/en.gif' border=0 alt='English'></a>
                        
                        <a class='menu' href='index.php?language=ru'><img src='content/images/ru.gif' border=0 alt='Russian'></a>
                    
                        <a class='menu' href='index.php?language=ge'><img src='content/images/ge.gif' border=0 alt='German'></a>
            </td>
    </tr>    
    <tr><td class='menuDivLine'></td></tr>";
    
    
        if ($page=="home"){echo"<tr bgcolor='#C5B881'>";}
        else{echo"<tr onMouseover=this.bgColor='#C5B881'; onMouseout=this.bgColor='#ACE6FD';  bgcolor='#ACE6FD'>";}echo"
            <td><a class='menu' href='?page=home.htm'>Home</a></td>
    </tr>
    
    <tr><td class='menuDivLine'></td></tr>";
        if ($page=="fact_sheet"){echo"<tr bgcolor='#C5B881'>";}
        else{echo"<tr onMouseover=this.bgColor='#C5B881'; onMouseout=this.bgColor='#9CDAF3';  bgcolor='#9CDAF3'>";}echo"
        <td><a class='menu' href='?page=fact_sheet.htm'>FACT SHEET</a></td>
    </tr>
.
.

.etc
[/code]

index.php
[code]
<?php
if (!@$page) $page = 'home.htm';

switch($_GET['language'])
{
      case('en'):
           $directory = 'content/en';
      break;

      case('ru'):
            $directory = 'content/ru';
      break;
      
      case('ge'):
            $directory = 'content/ge';
      break;


      default: $directory = 'content/ge';
}

$PATH = $directory.$page;
include("template/head.php");
[/code]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.