Boolean variable not working on Button click in php
-
Pls help me in solving my problem. For the last two days I am trying to solve it but couldn’t do it. Can’t figure out where I am wrong. Pls help
PROBLEM – A
I am trying to call procedures (Proc-A and Proc-B) which will run when two different buttons are
clicked in php. These buttons are “Signin and Sign up”.
Things which i am following is like :
1. Two variables : $flagIn and $flagUpVariables Initialize : $flagIn = false and
$flagUp = false2. Two buttons :
a. Sign In Button – boolean variable $flagIn
– on click $flagIn = true and $flagup = falseb. Sign Up Button – boolean variable $flagUp
– on click $flagIn = false and $flagup = true3. When $flagIn = true -> Proc-A will be called and
When $flagUp = true -> Proc-B will be calledPROBLEM – B
“<link rel=”stylesheet” type=”text/css” href=”css/logstyle.css” />” => Not working ??
Hope this will help you in knowing the logic which i am trying to apply.
———————————————————————–
Following is the code :
‘
<?php
//Variables Initialize
$flagIn = 1;
$flagUp = 1;if (is_bool($flagIn) == true) {
if (isset($_POST[‘btnsubmit’])){ //Proc-A
//form was submitted
$username = $_POST[“txtuname”];
$password = $_POST[“txtupwd”];if ($username == “sss” && $password == “123”) {
//successful login
redirect_to(“blank.html”);
//$message = “Successful Login”;
}
else {
$username = $_POST[“txtuname”];
//$message = “Please Login…”;
}
} else {
//$message = “Please log in”;
}
} elseif (is_bool($flagUp) == true){
echo “Second Function called.”; //Proc-B
}?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel=”stylesheet” type=”text/css” href=”css/logstyle.css” />
</head>
<body>
<center>
<form action=”sample.php” method=”post”>
<div style=”width:940px; margin-left:8%; float:left; height:260px; background-color: #fff; border: 1px solid red”>
<!– Left Side Panel – Existing Users –>
<div style=”float: left; width:350px; height:100%; background-color: #fff; border: 0px solid red”>
<div style=”text-align:left; margin-left:20px; padding-top: 10px; padding-bottom:20px; margin: 10px, 0, 50px, 0; width:100%;”>
<label>Login to your account</label><label>Email Address </label> <input type=”text” name=”txtuname” value=”” style=”height:30px;width:250px” />
<label>Password </label> <input type=”password” name=”txtupwd” value=”” style=”height:30px;width:150px” />
<!– Button1 –>
<input type=”submit” name=”btnsignin” value=”Sign in” style=”font:18px sans-serif bold; width:80px; height:30px” /></div>
</div>
<!– Right Side Panel – New Users –>
<div style=”margin-left:35px; float: left; width:450px; height:100%; background-color: #EAF3F9; border: 0px solid blue”>
<div style=”text-align:left; margin-left:10px; padding-top: 10px; padding-bottom:20px; margin: 10px, 0, 50px, 0; width:100%;”>
<label >New user</label><div style=”float:left; width:46%; height:60px; border: 0px solid red”>
<label style=”font:15px sans-serif;”>Your Name </label> <input type=”text” name=”name” placeholder=”Your Name” value=”” style=”height:30px; width:200px; font-size: 15px” /></div>
<div style=”float:left; margin-left:10px; width:46%; height:60px; border: 0px solid red”>
<label style=”font:15px sans-serif;”>e-Mail ID </label> <input type=”text” name=”email” placeholder=”Full Email Address” value=”” style=”height:30px; width:200px; font-size: 15px” /></div>
<div style=”float:left; margin-top:10px; width:46%; height:60px; border: 0px solid red”>
<label style=”font:15px sans-serif;”>Password </label> <input type=”text” name=”password1″ placeholder=”Enter your Password” value=”” style=”height:30px; width:200px; font-size: 15px” /></div>
<!– Button2 –>
<div style=”float:left; margin-top:10px; width:95%; height:40px; border: 0px solid red”>
<input type=”submit” name=”btnsignup” value=”Sign up” style=”font:18px sans-serif bold; width:100%; height:40px” /></div>
</div>
</div>
</div>
<?php
if (isset($_POST[‘btnsignin’])) {
$flagIn = 0; //True
$flagUp = 1; //False
echo ‘Sign in Clicked’;
} elseif (isset ($_POST[‘btnsignup’])){
$flagIn = 1; //False
$flagUp = 0; //True
echo ‘Sign up Clicked’;
} else {}
?></form>
</center>
</body>
</html>‘
The topic ‘Boolean variable not working on Button click in php’ is closed to new replies.