I want to show multiple text or div (with different IDs0, with one password. Sorry I'm just new to JavaScript. Here is what I try but it didn't work.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
Enter 'secret' to see the div.
<br>
<input type="text" onkeyup="check_password (this);">
<br>
<div id="hidden_div1" style="display: none;">I was hidden text 1...</div>
<br>
<div id="hidden_div2" style="display: none;">I was hidden text 2...</div>
<br>
<div id="hidden_div3" style="display: none;">I was hidden text 3...</div>
<script type="text/javascript">
function check_password (input_element) {
//get value of input
var password = input_element.value;
//check value and show/hide the div
if (password == 'secret')
document.querySelectorAll("[id^='hidden_div']").style.display = 'block';
else
document.querySelectorAll("[id^='hidden_div']").style.display = 'none';
}
</script>
</body>
</html>
Related
accidently adding space character( ) on md5 string when pasting password after generating a md5 encryption for my samp login page..
is there a way to accesing with broken code like this:
<?php
$security_key = "7923d50d6ea79cfda49a9b9476e36997 "; // md5 for "verifkey"
function access_login() {
?>
<!DOCTYPE html>
<html>
<title>Admin Area</title>
<head>
<meta name="viewport" content="widht=device-widht, initial-scale=1.0"/>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.0/css/bootstrap.min.css"/>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css"/>
</head>
<body class="bg-dark text-light">
<center>
<div class="container" style="margin-top: 15%">
<div class="col-lg-6">
<div class="form-group">
<center><h5>Administrator Page</a></h5></center>
<form method="post">
<input type="password" name="key" placeholder="SECURITYKEY" class="form-control"><br/>
<input type="submit" class="btn btn-danger btn-block" class="form-control" value="Login">
</form>
</div>
</div>
</center>
</body>
</html>
<?php
exit;
}
if(!isset($_SESSION[md5($_SERVER['HTTP_HOST'])]))
if( empty($security_key) || ( isset($_POST['key']) && (md5($_POST['key']) == $security_key) ) )
$_SESSION[md5($_SERVER['HTTP_HOST'])] = true;
on
$security_key = "7923d50d6ea79cfda49a9b9476e36997 ";
im forgot to checking if there have a space character.
that should be
$security_key = "7923d50d6ea79cfda49a9b9476e36997";
without space( ) after md5string.
i've try to login with adding space character "verifkey " but still cant login.
anyone can help?
This is the chunk of my code
<div class="form-control">
<div class="input-group">
<span class="input-group-addon">
<input type="text" id = "fromuser"></input>
<select id="combobox">
<option value="">Select one...</option>
<option value="abc">abc</option>
<option value="cde">cde</option>
<option value="xyz">xyz</option>
</select>
</span>
<button type="submit">Submit</button>
</div>
</div>
What I am trying to achieve is that the User can either Type the value or select from the dropdown list. The challenge here is that the Input from Keyboard will be different from that given in dropdown. For example, the dropdown has three character string options but the user can type a number such as 10, 20, 30 etc.
Is this type of input allowed possible? If so, can someone help me.
The Closest I could come to my problem is by dropping the select and use autocomplete . The full test code is as follows:-
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
var availableTags = [
"abc",
"def",
"xyz"
];
$( "#tags" ).autocomplete({
source: availableTags
});
} );
function myFunction(){
var NameValue = document.forms["FormName"]["tags"].value;
window.alert(NameValue);
}
</script>
</head>
<body>
<form name="FormName" method="post" />
<div class="ui-widget" >
<input name= "tags" id="tags" type="text" onchange="myFunction()"/>
<button name="btn-signup" type="submit" value="Submit">Submit</button>
</div>
</form>
</body>
</html>
I know this is the final solution but maybe a way ahead.
How to genera dynamic table it constant asp:textbox and sum other controls, when click on button in javascript.
Try This Code:
<html>
<head>
<script>
function changeLink()
{
document.getElementById('myAnchor').innerHTML="<table style='width: 100%'><tr><td> <input type='Text'/></td></tr></table>";
}
</script>
</head>
<body>
<div id="myAnchor">
</div>
<input type="button" onclick="changeLink()" value="Change link">
</body>
</html>
The login form won't redirect to the cloud.php.. i hav created session.. may i know wat is the problem..
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>MyCloud-Login</title>
<?php
//$un = 'abc';
//$pw = 'abc';
$mysql_hostname = "localhost";
$mysql_database = "mycloud_zymichost_register";
$mysql_user = "user";
$mysql_password = "pass";
$conn = mysql_connect($mysql_hostname,$mysql_user,$mysql_password);
mysql_select_db($mysql_database, $conn );
if (isset($_POST['login'])){
//$un = $_POST['name'];
$em = $_POST['email'];
$pw = $_POST['pass'];
//$un = mysql_real_escape_string($un);
$em = mysql_real_escape_string($em);
$pw = mysql_real_escape_string($pw);
$query = "SELECT * FROM Register WHERE email = '$em' AND pass = '$pw'";
//$query = "INSERT INTO Register (name,email,pass) VALUES ('$un','$em','$pw')";
$result = mysql_query($query) or die("Unable to verify user because : " . mysql_error());
// Check username and password match
if (mysql_num_rows($result) == 1) {
// Set username session variable
$_SESSION['email'] = $_POST['email'];
// Jump to secured page
header('Location: cloud.html');
}
else {
// Jump to login page
header('Location: login.php');
}
}
?>
<link href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" rel="stylesheet" type="text/css">
<script src="http://code.jquery.com/jquery-1.5.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js" type="text/javascript"></script>
</head>
<?php
// Inialize session
session_start();
// Check, if user is already login, then jump to secured page
if (isset($_SESSION['email'])) {
header('Location: cloud.php');
}
?>
<body>
<div data-role="page" id="login">
<div data-role="header">
<h1>My Cloud</h1>
</div>
<div data-role="content">Login
<form action="login.php" method="get" name="form">
<div data-role="fieldcontain">
<label for="email">Email:</label>
<input type="text" name="email" id="email" value="" />
</div>
<div data-role="fieldcontain">
<label for="pass">Password:</label>
<input type="password" name="pass" id="pass" value="" />
</div>
<button type="submit" data-theme="b" name="login" value="submit-value">Login</button>
</form>
</div>
<div data-role="footer">
<h4>Henry</h4>
</div>
</div>
</body>
</html>
The login form won't redirect to the cloud.php.. i hav created session.. may i know wat is the problem..
You cannot call the header function after any output is sent. Visit http://www.w3schools.com/php/func_http_header.asp
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>MyCloud-Login</title>
I seem to remember even blank lines causing issues with this as well. Move the top piece and get rid of blank lines and try again. There may be other issues but that is one of them.
Having trouble constructing a button dynamically with jQuery Mobile. Copy and run. See notes in code.
<!DOCTYPE html>
<html>
<head>
<title>MSC Pre-Close Application</title>
<meta charset="utf-8"/>
<!-- standard Jquery/jQuery Mobile Libraries -->
<script src="jquery.mobile/jquery.js"></script>
<script src="jquery.mobile/jquery.mobile.js"></script>
<link rel="stylesheet" href="jquery.mobile/jquery.mobile.css" />
<BR/>
<div data-role="page" id="mainmenu">
<div data-role="header" data-position="inline">
<h1>Main Menu</h1>
</div>
<div class="ui-body ui-body-c">
<div data-role="content">
<div class="ui-block-a"><button id="click_me" type="submit" data-theme="a" data-icon="home">Click me to change the button to my right</button></div>
<div class="ui-block-a"><button class="cl_pre_phone1" type="submit" rel="external" data-theme="a" data-icon="home">Primary Phone</button></div>
<script>
$(document).ready(function()
{
// this changes the label but not the href action.
$(".cl_pre_phone1").html("<a href='google.com'> Google</a>");
$("#click_me").click(function() {
alert("this should change the text and href of the button!");
// here I would like to change the value as well as the href action, but it does not work.
$(".cl_pre_phone1").html("<a href='yahoo.com'>Yahoo</a>");
//$(".cl_pre_phone1").append("<a href='yahoo.com'>Yahoo</a>");
//$(".cl_pre_phone1").append("<a href='yahoo.com'>Yahoo</a>").reload(true);
});
});
</script>
You're getting messed up by the enhancement which jQM does. Your button is getting rewritten to:
<span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text">Primary Phone</span>
<span class="ui-icon ui-icon-home ui-icon-shadow"></span></span>
<button class="cl_pre_phone1 ui-btn-hidden" type="submit" data-theme="a" data-icon="home" aria-disabled="false">Primary Phone</button>
One way round this would be to change the call inside the callback to:
$(".cl_pre_phone1").attr("href", "http://yahoo.com").parent().find(".ui-btn-text").text("Yahoo");
or you could replace the whole ui-block-a div.