-3

Hello i need your help or advice about one of my problem , so the thing is i have a multi language website (2 languages for now) and have a ad posting form witch starts on http://newproject.comli.com/step1.php and goes to a step2 and the problem starts if i change language on a step2 file its gives me an error like : enter image description here

you wont see those errors on a hosting but there will be no result ether . so basically i am sending a ids from s step1 to a step2 , ids of user selection to display a category witch they select and later to insert to a database ware get those errors as well if i try to change a language after insert ( i mean i got them inserted into database and then if i change a language its gives me a tons of error it could be moved to a another page if you are trying to change language or just another way to avoid those errors ) the insertions page is ready but i didt create a table for it on my hosting so it wont work there

this is my pages code just to be more understandable what i am talking about and ware is the problem :

step1.php

<?php
include_once 'common.php';
?>
<!DOCTYPE html>
<html lang="<?php echo $lang['LANG']; ?>">
<head>
    <title><?php echo $lang['PAGE_TITLE']; ?></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="styles.css">
    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <script src="js/ism-2.1.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
    $(".level2 > li").hide();
    $(".level1 > li").on("click", function() {
        $(this).siblings().css("background-color", "transparent");
        $(this).css("background-color", "#f1f1f1");
        idx = $(this).index();
        $(".level2 > li").hide();
        $(".level2 > li").eq(idx).show();
    });
    $(".level3").hide();
    $(".level2 > li > ul > li").on("click", function() {
        $(".level2 > li > ul > li").css("background-color", "transparent");
        $(this).css("background-color", "#f1f1f1");  
        $(".level3").hide();
        var idx2 = $(this).index();
        var idx1 = $(this).parent().parent().index();
        $(".level3").show();
        $("#catid").val("CAT" + (idx1+1) + "-" + (idx2+1));
    });
});

    </script>


</head>
<body>
    <div class="advtop">
    </div>
     <div id="topbar2">
        <div id="lang">
            <ul>
            <li>
                <a href="?lang=lt" ><img src="image/Lithuania.png" ></a>
            </li>
            <li>
                <a href="?lang=en"><img src="image/United Kingdom.png" ></a>
            </li>
        </ul>
        </div>
        <div id="text">
            <ul>
            <li>
                <?php 

                    if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
                        echo "Sveiki"; ?> <a href="#"><?php echo $_SESSION["username"]; ?></a><?php
                    }else {
                        ?> <a href="post.php" ><?php echo $lang['LOGIN']; ?></a> <?php
                    }
                    ?><span> |</span>
                </li>
            <li>
                <a href="#" ><?php echo $lang['MYACC']; ?><span class="icn"> &bigtriangledown;</span></a>
                <ul class="dropdown">
                <li><a class="first" href="#"><?php echo $lang['FAV']; ?> (0)</a></li>
                <li><a href="#"><?php echo $lang['ADS']; ?></a></li>
                <li><a href="#"><?php echo $lang['DETAILS']; ?></a></li>
                                <li>
                    <?php 
                        if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
                        ?> <a href="logout.php" ><?php echo $lang['LOGOUT']; ?></a> <?php
                    }else {
                        ?> <a href="post.php" ><?php echo $lang['REGISTER']; ?></a> <?php
                    } ?>

                    </li>
                 </ul>
            </li>
        </ul>
        </div>
        <div id="postadv">
            <a href="<?php 
                     if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
                        echo "step1.php";
                     }else {
                         echo "post.php";
                     }

                     ?>" ><?php echo $lang['POST']; ?></a>
        </div>
    </div>
    <div id="logo2"><a href="index.php"><img src="image/logo.png"></a></div>
    <div id="searchbox2">
    <form class="form" action="search.php" method="get">
        <input class="search-field" type="search" name="search" size="70" maxlength="50" placeholder="<?php echo $lang['SRC']; ?>" height="50">
        <select class="categories" name="categories">
            <option value="0" selected="selected"><?php echo $lang['ALLCAT']; ?></option>
            <option value="1"><?php echo $lang['CAT1']; ?></option>
            <option value="2"><?php echo $lang['CAT2']; ?></option>
            <option value="3"><?php echo $lang['CAT3']; ?></option>
            <option value="4"><?php echo $lang['CAT4']; ?></option>
            <option value="5"><?php echo $lang['CAT5']; ?></option>
            <option value="6"><?php echo $lang['CAT6']; ?></option>
            <option value="7"><?php echo $lang['CAT7']; ?></option>
            <option value="8"><?php echo $lang['CAT8']; ?></option>
            <option value="9"><?php echo $lang['CAT9']; ?></option>
        </select>
        <input class="submit-button" type="submit" value="<?php echo $lang['SRCBTN']; ?>">
    </form>
        <a href="#" ><?php echo $lang['ADVSRC']; ?></a>
    </div>
    <div id="itemsCategLists">
                <ul class="level1">
                   <li>
                    <span><?php echo $lang['CAT1']; ?></span>
                    <i class="fa fa-chevron-right"></i>
                    </li>
                    <li>
                    <span><?php echo $lang['CAT2']; ?></span>
                    <i class="fa fa-chevron-right"></i>
                    </li>
                    <li>
                    <span><?php echo $lang['CAT3']; ?></span>
                    <i class="fa fa-chevron-right"></i>
                    </li>
                    <li>
                    <span><?php echo $lang['CAT4']; ?></span>
                    <i class="fa fa-chevron-right"></i>
                    </li>
                    <li>
                    <span><?php echo $lang['CAT5']; ?></span>
                    <i class="fa fa-chevron-right"></i>
                    </li>
                    <li>
                    <span><?php echo $lang['CAT6']; ?></span>
                    <i class="fa fa-chevron-right"></i>
                    </li>
                    <li>
                    <span><?php echo $lang['CAT7']; ?></span>
                    <i class="fa fa-chevron-right"></i>
                    </li>
                    <li>
                    <span><?php echo $lang['CAT8']; ?></span>
                    <i class="fa fa-chevron-right"></i>
                    </li>
                    <li>
                    <span><?php echo $lang['CAT9']; ?></span>
                    <i class="fa fa-chevron-right"></i>
                    </li>
                </ul>
                <ul class="level2">
                 <li>
                    <ul class="level2list1">
                    <li><span><?php echo $lang['CAT1-1']; ?></span></li>
                     <li><span><?php echo $lang['CAT1-2']; ?></span></li>
                      <li><span><?php echo $lang['CAT1-3']; ?></span></li>
                      <li><span><?php echo $lang['CAT1-4']; ?> </span></li>
                    </ul>
                </li>
                    <li>
                        <ul class="level2list1">
                      <li><span><?php echo $lang['CAT2-1']; ?></span></li>
                      <li><span><?php echo $lang['CAT2-2']; ?></span></li>
                      <li><span><?php echo $lang['CAT2-3']; ?></span></li>
                      <li><span><?php echo $lang['CAT2-4']; ?></span></li>
                      <li><span><?php echo $lang['CAT2-5']; ?></span></li>
                      <li><span><?php echo $lang['CAT2-6']; ?></span></li>
                      <li><span><?php echo $lang['CAT2-7']; ?></span></li>
                      <li><span><?php echo $lang['CAT2-8']; ?></span></li>
                        </ul>
                    </li>
                    <li>
                        <ul class="level2list1">
                      <li><span><?php echo $lang['CAT3-1']; ?></span></li>
                      <li><span><?php echo $lang['CAT3-2']; ?></span></li>
                      <li><span><?php echo $lang['CAT3-3']; ?></span></li>
                      <li><span><?php echo $lang['CAT3-4']; ?></span></li>
                      <li><span><?php echo $lang['CAT3-5']; ?></span></li>
                      <li><span><?php echo $lang['CAT3-6']; ?></span></li>
                      <li><span><?php echo $lang['CAT3-7']; ?></span></li>
                      <li><span><?php echo $lang['CAT3-8']; ?></span></li>
                        </ul>
                    </li>
                     <li>
                        <ul class="level2list1">
                      <li><span><?php echo $lang['CAT4-1']; ?></span></li>
                      <li><span><?php echo $lang['CAT4-2']; ?></span></li>
                      <li><span><?php echo $lang['CAT4-3']; ?></span></li>
                      <li><span><?php echo $lang['CAT4-4']; ?></span></li>
                      <li><span><?php echo $lang['CAT4-5']; ?></span></li>
                      <li><span><?php echo $lang['CAT4-6']; ?></span></li>
                      <li><span><?php echo $lang['CAT4-7']; ?></span></li>
                        </ul>
                    </li>
                     <li>
                        <ul class="level2list1">
                      <li><span><?php echo $lang['CAT5-1']; ?></span></li>
                      <li><span><?php echo $lang['CAT5-2']; ?></span></li>
                      <li><span><?php echo $lang['CAT5-3']; ?></span></li>
                      <li><span><?php echo $lang['CAT5-4']; ?></span></li>
                      <li><span><?php echo $lang['CAT5-5']; ?></span></li>
                        </ul>
                    </li>
                     <li>
                        <ul class="level2list1">
                      <li><span><?php echo $lang['CAT6-1']; ?></span></li>
                      <li><span><?php echo $lang['CAT6-2']; ?></span></li>
                      <li><span><?php echo $lang['CAT6-3']; ?></span></li>
                      <li><span><?php echo $lang['CAT6-4']; ?></span></li>
                      <li><span><?php echo $lang['CAT6-5']; ?></span></li>
                      <li><span><?php echo $lang['CAT6-6']; ?></span></li>
                      <li><span><?php echo $lang['CAT6-7']; ?></span></li>
                        </ul>
                    </li>
                     <li>
                        <ul class="level2list1">
                      <li><span><?php echo $lang['CAT7-1']; ?></span></li>
                      <li><span><?php echo $lang['CAT7-2']; ?></span></li>
                      <li><span><?php echo $lang['CAT7-3']; ?></span></li>
                      <li><span><?php echo $lang['CAT7-4']; ?></span></li>
                      <li><span><?php echo $lang['CAT7-5']; ?></span></li>
                      <li><span><?php echo $lang['CAT7-6']; ?></span></li>
                      <li><span><?php echo $lang['CAT7-7']; ?></span></li>
                        </ul>
                    </li>
                    <li>
                        <ul class="level2list1">
                      <li><span><?php echo $lang['CAT8-1']; ?></span></li>
                      <li><span><?php echo $lang['CAT8-2']; ?></span></li>
                      <li><span><?php echo $lang['CAT8-3']; ?></span></li>
                      <li><span><?php echo $lang['CAT8-4']; ?></span></li>
                      <li><span><?php echo $lang['CAT8-5']; ?></span></li>
                        </ul>
                    </li>
                    <li>
                        <ul class="level2list1">
                      <li><span><?php echo $lang['CAT9-1']; ?></span></li>
                      <li><span><?php echo $lang['CAT9-2']; ?></span></li>
                      <li><span><?php echo $lang['CAT9-3']; ?></span></li>
                      <li><span><?php echo $lang['CAT9-4']; ?></span></li>
                        </ul>
                    </li>
                </ul>
                <div class="level3">
                    <form id="step1" action="step2.php" method="post">
                    <input type="hidden" name="catid" id="catid">
                    <input class="submit-button" type="submit" name="submint" value="<?php echo $lang['NEXT']; ?>">
                    </form>
            </div>

    </div>
   <div class="footer2">
        <div class="copy">
        <ul>
            <li>
                <a href="#" ><?php echo $lang['TERMS']; ?></a>
            </li>
            <li>
                <a href="#" ><?php echo $lang['CONTACT']; ?></a>
            </li>
        </ul>
            <span style="font-size: 13px; color: black"><?php echo $lang['COPY']; ?></span>
        </div>
    </div>


</body>
</html>

and step2.php

<?php
include_once 'common.php';


?>
<!DOCTYPE html>
<html lang="<?php echo $lang['LANG']; ?>">
<head>
    <title><?php echo $lang['PAGE_TITLE']; ?></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="styles.css">
    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <script src="js/ism-2.1.js"></script>


</head>
<body>
    <div class="advtop">
    </div>
     <div id="topbar2">
        <div id="lang">
            <ul>
            <li>
                <a href="?lang=lt" ><img src="image/Lithuania.png" ></a>
            </li>
            <li>
                <a href="?lang=en"><img src="image/United Kingdom.png" ></a>
            </li>
        </ul>
        </div>
        <div id="text">
            <ul>
            <li>
                <?php 

                    if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
                        echo "Sveiki"; ?> <a href="#"><?php echo $_SESSION["username"]; ?></a><?php
                    }else {
                        ?> <a href="post.php" ><?php echo $lang['LOGIN']; ?></a> <?php
                    }
                    ?><span> |</span>
                </li>
            <li>
                <a href="#" ><?php echo $lang['MYACC']; ?><span class="icn"> &bigtriangledown;</span></a>
                <ul class="dropdown">
                <li><a class="first" href="#"><?php echo $lang['FAV']; ?> (0)</a></li>
                <li><a href="#"><?php echo $lang['ADS']; ?></a></li>
                <li><a href="#"><?php echo $lang['DETAILS']; ?></a></li>
                                <li>
                    <?php 
                        if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
                        ?> <a href="logout.php" ><?php echo $lang['LOGOUT']; ?></a> <?php
                    }else {
                        ?> <a href="post.php" ><?php echo $lang['REGISTER']; ?></a> <?php
                    } ?>

                    </li>
                 </ul>
            </li>
        </ul>
        </div>
        <div id="postadv">
            <a href="<?php 
                     if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
                        echo "step1.php";
                     }else {
                         echo "post.php";
                     }

                     ?>" ><?php echo $lang['POST']; ?></a>
        </div>
    </div>
    <div id="logo2"><a href="index.php"><img src="image/logo.png"></a></div>
    <div id="searchbox2">
    <form class="form" action="search.php" method="get">
        <input class="search-field" type="search" name="search" size="70" maxlength="50" placeholder="<?php echo $lang['SRC']; ?>" height="50">
        <select class="categories" name="categories">
            <option value="0" selected="selected"><?php echo $lang['ALLCAT']; ?></option>
            <option value="1"><?php echo $lang['CAT1']; ?></option>
            <option value="2"><?php echo $lang['CAT2']; ?></option>
            <option value="3"><?php echo $lang['CAT3']; ?></option>
            <option value="4"><?php echo $lang['CAT4']; ?></option>
            <option value="5"><?php echo $lang['CAT5']; ?></option>
            <option value="6"><?php echo $lang['CAT6']; ?></option>
            <option value="7"><?php echo $lang['CAT7']; ?></option>
            <option value="8"><?php echo $lang['CAT8']; ?></option>
            <option value="9"><?php echo $lang['CAT9']; ?></option>
        </select>
        <input class="submit-button" type="submit" value="<?php echo $lang['SRCBTN']; ?>">
    </form>
        <a href="#" ><?php echo $lang['ADVSRC']; ?></a>
    </div>
    <div id="itemsCategLists2">
        <div class="post2" >
            <form class="formstyle" action="final.php" method="post" >
                <div class="adtext">
                <p><b><?php echo $lang['KAT']; ?>:</b>
                </p>
                <p><b><?php echo $lang['ACTION']; ?>*:</b>
                </p>
                <p><b><?php echo $lang['ADTITLE']; ?>*:</b><br>
                </p>
                <p><b><?php echo $lang['ADDETAILS']; ?>*:</b>
                </p><br><br><Br>
                <p><b><?php echo $lang['PRICE']; ?>*:</b>
                </p>
                <p><b><?php echo $lang['ADPHOTOS']; ?>:</b>
                </p>
                <p><b><?php echo $lang['UARE']; ?>*:</b>
                </p>
                <p><b><?php echo $lang['PHONE']; ?>*:</b>
                </p>
                <p><b><?php echo $lang['EMAIL']; ?>:</b>
                </p>
                <p><b><?php echo $lang['LOCATION']; ?>*:</b>
                </p>
                <p><b><?php echo $lang['NAME']; ?>*:</b>
                </p>
                <p><b><?php echo $lang['WEB']; ?>:</b>
                </p>
                </div>
                <div class="entry">
                    <?php
                $catid = $_POST['catid'];
                $catid2 = substr($catid,0,4);
                $cat1 = $lang[$catid2];
                $cat2 = $lang[$catid];    

                echo "<font color='grey'>".$cat1." » ".$cat2."</font>";
                ?>
                <br style="margin-bottom: 17px;">
                <input type="hidden" name="catid" value="<?php echo $catid; ?>">
                <input type="radio" name="action" value="1" required> <?php echo $lang['PORPOSE']; ?>
                <input type="radio" name="action" value="2" required> <?php echo $lang['LOOKING']; ?><br style="margin-bottom: 15px;">
                <input type="text" name="title" maxlength="80" pattern=".{10,}" title="At Least 10 symbols" min="10" style="width: 379px;" required><br style="margin-bottom: 15px;">
                <textarea name="details" rows="10" cols="30" pattern=".{10,}" title="At Least 10 symbols" style="width: 379px; height: 75px;" maxlength="5500" required></textarea><br><br style="margin-bottom: 5px;">
                <input type="text" name="price" maxlength="10" pattern="\d+(\.\d{2})?" title="Only numbers" required><br style="margin-bottom: 15px;">
                <input type="file" multiple="true" name="image[]"><br style="margin-bottom: 15px;">
                <input type="radio" name="ocp" value="1" required><?php echo $lang['PRV']; ?>
                <input type="radio" name="ocp" value="2" required><?php echo $lang['BSN']; ?><br style="margin-bottom: 15px;">              
                <input type="text" name="phonenumber" pattern="^\s*\(?(020[7,8]{1}\)?[ ]?[1-9]{1}[0-9{2}[ ]?[0-9]{4})|(0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3})\s*$" title="Only UK Phone numbers ( 07*********) " required><br style="margin-bottom: 15px;">
                <input type="email" name="email"><br style="margin-bottom: 15px;">
                <input type="text" name="location" pattern=".[A-Za-z]{3,15}" title="Only letter (4-15 symbols)" required><br style="margin-bottom: 15px;">
                <input type="text" name="name" pattern=".[A-Za-z]{3,15}" title="Only letter (4-15 symbols)" required><br style="margin-bottom: 15px;">
                <input type="text" name="web" pattern="www\.\w+\.\w{2,3}|www\.\w+\.\w{2,3}\.\w{2}" title="Format :(www.website.com) "><br style="margin-bottom: 15px;">
                <input class="submit-button" type="submit" name="submit" value="<?php echo $lang['POSTADV']; ?>">

                </div>
            </form>
        </div>   
    </div>
   <div class="footer2">
        <div class="copy">
        <ul>
            <li>
                <a href="#" ><?php echo $lang['TERMS']; ?></a>
            </li>
            <li>
                <a href="#" ><?php echo $lang['CONTACT']; ?></a>
            </li>
        </ul>
            <span style="font-size: 13px; color: black"><?php echo $lang['COPY']; ?></span>
        </div>
    </div>


</body>
</html>
Tunaki
  • 132,869
  • 46
  • 340
  • 423
Egi Dijus
  • 25
  • 2
  • 9
  • 2
    Is this the least amount of code needed to demonstrate the issue? See http://stackoverflow.com/help/mcve – chris85 Dec 17 '15 at 16:04
  • Tunaki the answer you posted didt solve my problem there is just told how to make them invisible but doent solve my problem , cuz the problem is that i am sending a veriables from a step1 to a step2 and if u change language on a step2 those variables doesnt exist anymore – Egi Dijus Dec 17 '15 at 16:17
  • Use the `@` to tag users. It's going to be hard to get a good answer here though with all the code you posted. – chris85 Dec 17 '15 at 16:21
  • 1
    @ didt help at all it just hide an error but it doesnt solve a problem – Egi Dijus Dec 17 '15 at 16:42
  • You need to include your error message in your question. Also, this is really *not* how to do multiple languages. [You should be using `gettext` functionality](http://mel.melaxis.com/devblog/2005/08/06/localizing-php-web-sites-using-gettext/). – miken32 Dec 17 '15 at 19:30
  • i do not know i found this multi language tutorial on google its looks good for me and easy to integrate and to understand and anyway this doesnt about a language , cuz its have nothing to do with , i just tell an example because i will get same error if i just reload the page – Egi Dijus Dec 18 '15 at 02:44

1 Answers1

0

okay so i think a little and find a solution for this not the best one but its seams no1 else can help me except my self so what i will try to do is check if a catid is isset and if not then just redirect back to a step1 so if some1 try to access the step2 page it will just redirect to step1 because catid will be not isset and same with language when i change language catid becomes not isset and it should redirect me to step1 page , tell me if i am thinking a right way and if not what i am doing wrong

Egi Dijus
  • 25
  • 2
  • 9