Jump to content


Photo

Sending An ID to select langauage


  • Please log in to reply
6 replies to this topic

#1 romio

romio
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 10 March 2006 - 09:22 AM

This is my menu.php(part of it) file, what am trying to do is to check what language would the user choose,
                <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>




and this is my index.php(part of it)
<?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/";
    }
}


and for the rest of the menu thats what i got:
    <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>

What am I doing wrong, Thanks

#2 lessthanthree

lessthanthree
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts
  • LocationUK

Posted 10 March 2006 - 09:36 AM

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.
call me a safe bet, i'm betting i'm not

#3 romio

romio
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 10 March 2006 - 09:43 AM

[!--quoteo(post=353557:date=Mar 10 2006, 04:36 AM:name=lessthanthree)--][div class=\'quotetop\']QUOTE(lessthanthree @ Mar 10 2006, 04:36 AM) View Post[/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


#4 lessthanthree

lessthanthree
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts
  • LocationUK

Posted 10 March 2006 - 09:48 AM

In that case..


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


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

//etc

then on your index.php page


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";
}


call me a safe bet, i'm betting i'm not

#5 romio

romio
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 10 March 2006 - 10:00 AM

thats what i have for the moment but its aint working yet:

menu.php
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

index.php
<?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");


#6 lessthanthree

lessthanthree
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts
  • LocationUK

Posted 10 March 2006 - 10:03 AM

in what sense is it not working?

do you get any errors? does $_GET hold any values on index.php? is $directory empty?

call me a safe bet, i'm betting i'm not

#7 romio

romio
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 10 March 2006 - 10:11 AM

I found the mistake.... I had it this way:
$directory = 'content/en';
which it should have been this way

$directory = 'content/en/';

Thanks alot for your help




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users