Jump to content

[SOLVED] double language site design problem


zgkhoo

Recommended Posts

<?php

if(isset($_POST['LANG'])){ 
if($_POST['LANG']=='EN'){
		echo "hello
		<form action='index.php' method='post'>
		<select name='LANG'>
		<option value='EN'>English</option>
		<option value='CH'>Chinese</option>
		</select>
		<input type=submit name=submit value=submit>
		</form>

		</br></br></br>
		<form action='index.php' method='post'>
		<h1>Welcome to ABC MLM<h1/><br/>
		<img src='logo.gif' width='200' height='200'></br> 
		<h4>
		Username:<input type='text' name='username' /><br>
		Password: <input type='password' name='password' /><br>
		<input type='submit' name='Login' value='Log In'/>
		<!--<input type='submit' name='cDB' value='cDB'/>-->
		<!--<input type='submit' name='cPerson' value='cPerson'/>-->
		<input type='submit' name='cAdmin' value='cAdmin'/>
		</br>
		<a href='./menu/adminenter.php'>admin menu</a>
		<a href='./menu/userenter.php'>user menu</a>
		<a href='install_db.php'>install db</a>			
		</h4>
		</form>
		</br>
		<h5>
		<a href=register.php>Sign Up</a>
		</h5>
		";
}//end if
else{
			echo "你好


			<form action='index.php' method='post'>
			<select name='LANG'>
			<option value='EN'>English英文</option>
			<option value='CH'>Chinese中文</option>
			</select>
			<input type=submit name=submit value=应用>
			</form>

			</br></br></br>
			<form action='index.php' method='post'>
			<h1>欢迎来到ABC MLM<h1/><br/>
			<img src='logo.gif' width='200' height='200'></br> 
			<h4>
			帐号<input type='text' name='username' /><br>
			密码<input type='password' name='password' /><br>
			<input type='submit' name='Login' value='登入'/>
			<!--<input type='submit' name='cDB' value='cDB'/>-->
			<!--<input type='submit' name='cPerson' value='cPerson'/>-->
			<input type='submit' name='cAdmin' value='cAdmin'/>
			</br>
			<a href='./menu/adminenter.php'>admin menu</a>
			<a href='./menu/userenter.php'>user menu</a>
			<a href='install_db.php'>install db</a>

			</h4>
			</form>
			</br>
			<h5>
			<a href=register.php>登记</a>
			</h5>
			";

}//end else
}//end of isset
?>




<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">  //to show live time and date

// Current Server Time script (SSI or PHP)- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use.

//Depending on whether your page supports SSI (.shtml) or PHP (.php), UNCOMMENT the line below your page supports and COMMENT the one it does not:
//Default is that SSI method is uncommented, and PHP is commented:

//var currenttime = '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' //SSI method of getting server date
var currenttime = '<?php print date("F d, Y g:i:s", time())?>' //PHP method of getting server date

///////////Stop editting here/////////////////////////////////

var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var serverdate=new Date(currenttime)

function padlength(what){
var output=(what.toString().length==1)? "0"+what : what
return output
}

function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
var datestring=montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+", "+serverdate.getFullYear()
var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds())
//document.getElementById("servertime").innerHTML=datestring+" "+timestring
document.getElementById("serverdate").innerHTML=datestring
document.getElementById("servertime").innerHTML=timestring
}

window.onload=function(){
setInterval("displaytime()", 1000)
}

</script>

</head>
<body>
<center>

<form action=index.php method=post>
<select name='LANG'>
<option value='EN'>English</option>
<option value='CH'>Chinese</option>
</select>
<input type=submit name=submit value=submit>
</form>

</br></br></br>
<form action="index.php" method="post">
<h1>Welcome to ABC MLM<h1/><br/>
<img src="logo.gif" width="200" height="200"></br> 
<h4>
Username:<input type="text" name="username" /><br>
Password: <input type="password" name="password" /><br>
<input type="submit" name="Login" value="Log In"/>
<!--<input type="submit" name="cDB" value="cDB"/>-->
<!--<input type="submit" name="cPerson" value="cPerson"/>-->
<input type="submit" name="cAdmin" value="cAdmin"/>
</br>
<a href="./menu/adminenter.php">admin menu</a>
<a href="./menu/userenter.php">user menu</a>
<a href="install_db.php">install db</a>

</h4>
</form>
</br>
<h5>
<a href=register.php>Sign Up</a>
</h5>

</center>
<span class="servertime" id="servertime"></span>
</body>



</html>

 

after i change the language option(select box) neither to english or chinese, then it will appear another form/image/button out, the default one..wont disappear, how to solve it?

Link to comment
Share on other sites

not really sure if I understand the issue you're describing, but from the code you posted you are outputting the form before the rest of the html code, remember php is server side handled and anything outside the <?php ?> tags is not processed by the php engine, so you are actually outputting the form for choosing the language regardless of what the action on the page has been.

 

Also, I would advise strongly against using such big if/else blocks for a simple echo command, an alternative is to load a template file and replace specific language tags with the appropriate language code, similar to what Smarty does but simpler for keeping it practical, just a thought though...

Link to comment
Share on other sites

when user log in to my page , it is certainly i need display title of my site,username, password form for the user,

i dun wan when user log in then in my page just appear a select box for user to choose English or chinese...after they select language only appear those title username,password etc form element.

wat i wan is user log in then default will display all these element is english and if user choose change to chinese then the page become chinese...by display those element with chinese label

get wat i meant?

 

Link to comment
Share on other sites

Well, you have another form outside the PHP code...

 

the outside php code is for default display elements in english , if i without it, how can i display something to user when user browse this page? since my php code's display those element only  after change language action(select box)  taken..

thanks..

Link to comment
Share on other sites

not really sure if I understand the issue you're describing, but from the code you posted you are outputting the form before the rest of the html code, remember php is server side handled and anything outside the <?php ?> tags is not processed by the php engine, so you are actually outputting the form for choosing the language regardless of what the action on the page has been.

Also, I would advise strongly against using such big if/else blocks for a simple echo command, an alternative is to load a template file and replace specific language tags with the appropriate language code, similar to what Smarty does but simpler for keeping it practical, just a thought though...

then wat solution u recommend?  8)

 

Link to comment
Share on other sites

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.