Jump to content

[SOLVED] how to make an action after a select box is selected?


Recommended Posts

<table border =0 bgcolor=orange width=100%>
<tr>
<td>
<select name=language>
<option value=English>English</option>
<option value=Chinese>Chinese</option>
</select>

</td>

</tr>

</table>

how to make an php action(reload the page as language selected) after a select box is selected?

 

This is HTML, but use the onChange Event.

<table border =0 bgcolor=orange width=100%>
<tr>
<td>
<select name="language" onChange="document.location = this.value + '.php'">
<option value="english">English</option>
<option value="chinese">Chinese</option>
</select>

</td>

</tr>

</table>

<select name="language" onChange="document.location = this.value + '.php'">

<option value="english">English</option>

<option value="chinese">Chinese</option>

</select>

 

it means... If you select English you will be redirected to english.php if you select chinese you will be redirected to chinese.php

 

You can whatever you want. For example:

<script>

function do_it() {

alert ( getelemenetbyid('language') );

//or whatever you want. Else I recommend you to use AJAX technology. 
//find more at: www.jquery.com


}

</script>

<select id="language" name="language" onChange="do_it();">
<option value="english">English</option>
<option value="chinese">Chinese</option>
</select>

<?php
session_start();
$session[counter]=0;//got problem with viarable should $_SESSION
$lock='F';
ob_start();
echo "Your IP=".$_SERVER['REMOTE_ADDR']; //display ip




include 'config.php';
include 'opendb.php';





if(isset($_POST['Login'])){ 

/*$today = Now('Y-m-d H:i:s');
echo "today".$today;
exit;
*/

$ip=$_SERVER['REMOTE_ADDR'];
//$currdate=date('Y-m-d H:i:s'); //current date n tm
//echo "currdate".$currdate."<br>";
//$cdate=date('Y-m-d');// current date
//echo "<br>cdate".$cdate;

$ipquery  = "SELECT * FROM ip where ipaddress='$ip' AND logindate=DATE(NOW()) AND ipstatus='Fail' ORDER BY ipID";
$ipresult = mysql_query($ipquery);
$num=mysql_num_rows($ipresult); 
echo "num".$num;
if($num>=5){
$lock='T';
}

$username=$_POST[username];
$password=$_POST[password];


$query  = "SELECT * FROM person where username='$username' ORDER BY UserID";
$result = mysql_query($query);
$totalrows=mysql_num_rows($result); 

if ($lock!='T'){

if ($totalrows!=0){// valid user name
       while($row = mysql_fetch_array($result,MYSQL_ASSOC)){//getting user rec
    	 //unable to use echo here->error
      	if($row['Acctstatus']=='Active'){
     	 
       		if($password==$row['Password']){
       	    
       	
       			$restore=0;
       			mysql_query("UPDATE Person SET Trackuser = '$restore' 
            	where username='$username'");
    			session_start();
    			if ($row[Level]=='User'){  //if login is user
    			
       				$_SESSION['loginname']=$username;
       				//$_SESSION['user_ic']=$row['ic'];
       				$_SESSION['UserID']=$row['UserID'];
       				//unset($_SESSION['login_try']);
       				
       				header('Location: ./EN/menu/userenter.php');
       			}
       			else{                       //if login is admin
       				$_SESSION['loginname']=$username;
       				//$_SESSION['user_ic']=$row['ic'];
       				if($_SESSION['LANG']=="EN"){
       					//unset($_SESSION['login_try']);	  	 
       			        header('Location: ./EN/menu/adminenter.php');
       				}
       				else{
       					unset($_SESSION['login_try']);	 
       					header('Location: ./CH/menu/adminenter.php');
       					}
       		     }
         		//keep track of ip address
       				$dbresult = mysql_query("SELECT * FROM ip order by IpID") or die('Query failed: ' . mysql_error());
	 				$totalrows=mysql_num_rows($dbresult); 
	 				if($totalrows==0){
	 					$lastip="1001";
	 				}
	 				else{
     					while($row = mysql_fetch_array($dbresult,MYSQL_ASSOC)){
       	
       	 					$lastip=$row["LatestIp"];
       	    
      					}
     					$lastip++;
	 				}
       				$sql="INSERT INTO ip(IpID,Ipaddress,Loginuser,Logindate,Logintm,Ipstatus)
				VALUES('$lastip','$ip','$username',DATE(NOW()),NOW(),'Success')";
				mysql_query($sql,$con);
				mysql_query("UPDATE ip SET LatestIp='$lastip'") or die(mysql_error());
		    //end of keep track of ip address
         		include 'closedb.php'; // when the rec found, stop searching by close db

       }
       else{//user enter the wrong password for the correct user name
       		
       
   	 		$failtm=$row["Trackuser"];
   	 		
   	 		$failtm++;
       		mysql_query("UPDATE Person SET Trackuser = '$failtm' 
            where username='$username'");
       		
       		if($failtm==5){// inform user his acct will b suspended
       			

			$status='Lock';
			mysql_query("UPDATE Person SET Acctstatus = '$status' 
            	where username='$username'");
			echo "<center><table><tr><td bgcolor=#FFCC00><font color=#CC0000>You Are Unauthorized User! Your Account Will Be Suspended!</font></td></tr></table></center>";
			//keep track of ip address
       			$dbresult = mysql_query("SELECT * FROM ip order by IpID") or die('Query failed: ' . mysql_error());
	 			$totalrows=mysql_num_rows($dbresult); 

	 			if($totalrows==0){
	 				$lastip="1001";
	 			}
	 			else{
     				while($row = mysql_fetch_array($dbresult,MYSQL_ASSOC)){
       	
       	 				$lastip=$row["LatestIp"];
       	    
      				}
     				$lastip++;
	 			}
       			$sql="INSERT INTO ip(IpID,Ipaddress,Loginuser,Logindate,Logintm,Ipstatus)
			VALUES('$lastip','$ip','Null',DATE(NOW()),NOW(),'Fail')";
			mysql_query($sql,$con);
			mysql_query("UPDATE ip SET LatestIp='$lastip'") or die(mysql_error());
		    //end of keep track of ip address	
			header('Refresh:5;url=index.php');
			exit;			
       		    }
       				//keep track of ip address, 4 user acct not yet being locked
       				$dbresult = mysql_query("SELECT * FROM ip order by IpID") or die('Query failed: ' . mysql_error());
	 				$totalrows=mysql_num_rows($dbresult); 

	 				if($totalrows==0){
	 					$lastip="1001";
	 				}
	 				else{
     					while($row = mysql_fetch_array($dbresult,MYSQL_ASSOC)){
       	
       	 					$lastip=$row["LatestIp"];
       	    
      					}
     					$lastip++;
	 				}
       				$sql="INSERT INTO ip(IpID,Ipaddress,Loginuser,Logindate,Logintm,Ipstatus)
				VALUES('$lastip','$ip','Null',DATE(NOW()),NOW(),'Fail')";
				mysql_query($sql,$con);
				mysql_query("UPDATE ip SET LatestIp='$lastip'") or die(mysql_error());
		       //end of keep track of ip address	
       	echo "<META HTTP-EQUIV='refresh' content='0;URL=index.php'>";
        exit;
       		
       }//else of incorrect password for the user
      }//end of if acctstatus=active
      else{ //user acct locked
       	  echo "<center><table><tr><td bgcolor=#FFCC00><font color=#CC0000>Your Account Have Been Locked! Please Contact Admin For Activation.</font></td></tr></table></center>";
       	  			//keep track of ip address
       				$dbresult = mysql_query("SELECT * FROM ip order by IpID") or die('Query failed: ' . mysql_error());
	 				$totalrows=mysql_num_rows($dbresult); 

	 				if($totalrows==0){
	 					$lastip="1001";
	 				}
	 				else{
     					while($row = mysql_fetch_array($dbresult,MYSQL_ASSOC)){
       	
       	 					$lastip=$row["LatestIp"];
       	    
      					}
     					$lastip++;
	 				}
       				$sql="INSERT INTO ip(IpID,Ipaddress,Loginuser,Logindate,Logintm,Ipstatus)
				VALUES('$lastip','$ip','Null',DATE(NOW()),NOW(),'Fail')";
				mysql_query($sql,$con);
				mysql_query("UPDATE ip SET LatestIp='$lastip'") or die(mysql_error());
		    	//end of keep track of ip address
      	  header('Refresh:5;url=index.php');
       	  exit;
      }
    }//end of while
   }// end of valid user name

else{//invalid username
//echo "y";
/*$_SESSION['login_try']++;
if($_SESSION['login_try']==5){
	//to follow up->keep track of the user ip address so that next tm in the signin function'll check for the ip address
	//echo "<center><table><tr><td bgcolor=#FFCC00><font color=#CC0000>You Are Unauthorized User!!!</font></td></tr></table></center>";
	$_SESSION['lock']='T';

}*/
				//keep track of ip address
       				$dbresult = mysql_query("SELECT * FROM ip order by IpID") or die('Query failed: ' . mysql_error());
	 				$totalrows=mysql_num_rows($dbresult); 

	 				if($totalrows==0){
	 					$lastip="1001";
	 				}
	 				else{
     					while($row = mysql_fetch_array($dbresult,MYSQL_ASSOC)){
       	
       	 					$lastip=$row["LatestIp"];
       	    
      					}
     					$lastip++;
	 				}
       				$sql="INSERT INTO ip(IpID,Ipaddress,Loginuser,Logindate,Logintm,Ipstatus)
				VALUES('$lastip','$ip','Null',DATE(NOW()),NOW(),'Fail')";
				mysql_query($sql,$con);
				mysql_query("UPDATE ip SET LatestIp='$lastip'") or die(mysql_error());
		    	//end of keep track of ip address
echo "<META HTTP-EQUIV='refresh' content='0;URL=index.php'>";
exit;
}

}


else{ // lock=T

//powerful acct used by developer to login to admin menu, no lock for it 
/*if ($username=='Sys_Developer'){
	if($password=='A7A8'){
		session_start();
		$_SESSION['loginname']=$username;
    		header('Location: adminenter.php');
	}

    }
else{*/
//	echo "lock".$_SESSION['lock'];
	echo "<center><table><tr><td bgcolor=#FFCC00><font color=#CC0000>You Are Unauthorized User!Your IP Address Has Been Keep Tracked!</font></td></tr></table></center>";
	header('Refresh:5;url=index.php');
 	exit;
//}
}



}//end of isset login


if(isset($_POST['loginbyid'])){ 
echo "</br>login here";
$_SESSION['UserID']=$_POST['loginid'];
header('Location: ./EN/menu/userenter.php');


}





echo "
<table border=0 width=100%>
<tr>
<td align=middle bgcolor=orange>
Company Logo
</td>
<td bgcolor=yellow>


<table border =0 bgcolor=orange width=100%>
<tr>
<td align=middle>
<h5>Term and condition</h5>
</td>
<td>
<h5>Rules</h5>
</td>
<td>
<h5>Regulation</h5>
</td>
<td>
<h5>Payment</h5>
</td>
<td>
<h5>Language</h5>
</td>
</tr>
</table>

</td>
<td bgcolor=yellow>
<table border =0 bgcolor=orange width=100%>
<tr>
<td>
<select name=language onChange=document.location = this.value + '.php'>
<option value=english>English</option>
<option value=chinese>Chinese</option>
</select>


</td>
</tr>
</table>






</td>
</tr>
<tr>
<td width=20% bgcolor=yellow>



<form action=index.php method=post>
<table border=1>
<tr>
<td bgcolor=orange>
<h5>Username</h5>
</td>
<td>
<input type=text name=username>
</td>
</tr>
<tr>
<td bgcolor=orange>
<h5>Password</h5>
</td>
<td>
<input type=text name=password>
</td>
</tr>
<tr>
<td bgcolor=orange>
<h5>Validation Picture</h5>
</td>
<td width=177> 
<input type=image name=securityimage img src=../../CaptchaSecurityImages.php/>
</td>
</tr>
<tr>
<td bgcolor=orange>
<h5>Validation Code</h5>
</td>
<td>
<input type=text name=validation>
</td>
</tr>
<tr>
<td bgcolor=orange>
</td>
<td>
<input type=submit name='Login' value=login>
</td>
</tr>


</table>

</form>


<a href=./EN/menu/adminenter.php>admin menu</a>
<a href=./EN/menu/userenter.php>user menu</a>
<a href=install_db.php>Install DB</a>
<a href=db.php>View DB</a>
</h4>
</form>
</br>
<h5>
<a href=./EN/register/register.php>Sign Up</a>
</h5>
</center>

<center>
<form action=index.php method=post>
</br>
<font>Login directly by id</font>
</br>
<input type=text name=loginid>
</br>
<input type=submit name=loginbyid value=Login>
</form>
</center>


</td>
<td  bgcolor=yellow>




<img src=/PIC/RO111_main_24.jpg width=540 height=400>


</td>
<td bgcolor=yellow width=15%>


<table border =1 width=6>
<tr>
<td>
<img src=PIC/01.gif>
</td>
</tr>
<tr>
<td>
<img src=PIC/02.gif>
</td>
</tr>
<tr>
<td>
<img src=PIC/03.gif>
</td>
</tr>
<tr>
<td>
<img src=PIC/04.gif>
</td>
</tr>
<tr>
<td>
<img src=PIC/05.gif>
</td>
</tr>
<tr>
<td>
<img src=PIC/06.gif>
</td>
</tr>

</table>


</td>
<table width=100%>
<tr width=100%>
<td width=100%>


<table border=0 bgcolor=orange width=100%>
<tr>
<td>
<h5>
Copyright � Sports Bookie Online, Inc. All rights reserved.
</h5>
</td>
<td>
<h5>Privacy Policy</h5>
</td>
<td>
<h5>Banking</h5>
</td>
<td>
<h5>Paying Method</h5>
</td>
<td>
<h5>Jobs</h5>
</td>
<td>
<img src=PIC/small01.gif>
</td>

</tr>
</table>


</td>
</tr>
</table>
";


?>

<select id="language" name="language" onChange="do_it();">
<option value="english">English</option>
<option value="chinese">Chinese</option>
</select>

 

weird..not respond at all after i select the language...

 

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.