“No problem can be solved from the same level of consciousness that created it.” Albert Einstein (1879-1955)
Monday, 20 July 2015
Tuesday, 7 July 2015
Get SQL Data using PHP and Display using HTML
getSqlData.php
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
$conn = new mysqli("localhost", "root", "root", "World");
$result = $conn->query("SELECT Code, Name, Region FROM Country");
$outp = "[";
while($rs = $result->fetch_array(MYSQLI_ASSOC))
{
if ($outp != "[")
$outp .= ",";
$outp .= '{"Code":"'. $rs["Code"] . '",';
$outp .= '"Name":"' . $rs["Name"] . '",';
$outp .= '"Region":"' . $rs["Region"] . '"}';
}
$outp .="]";
$conn->close();
echo($outp);
?>
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div id="id01"></div>
<script>
var xmlhttp = new XMLHttpRequest();
var url = "http://localhost/SampleWebSite/getSqlData.php";
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
myFunction(xmlhttp.responseText);
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
function myFunction(response)
{
var arr = JSON.parse(response);
var i;
var out = "<table>";
for(i = 0; i < arr.length; i++)
{
out += "<tr>"+
"<td>" + arr[i].Code + "</td>" +
"<td>" + arr[i].Name + "</td>" +
"<td>" + arr[i].Region + "</td>"+
"</tr>";
}
out += "</table>";
document.getElementById("id01").innerHTML = out;
}
</script>
</body>
</html>
Sunday, 5 July 2015
No 'Access-Control-Allow-Origin' Header is Present on the Requested Resource
Add the following headers to the HTML file:
<!DOCTYPE html>
<html>
<head>
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
?>
.
.
.
<!DOCTYPE html>
<html>
<head>
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
?>
.
.
.
Call PHP Method with Parameter from HTML
<?php
if (isset($_POST['getData']) and isset($_POST['country']))
{
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "World";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT code, name FROM country where name='" . $_POST['country'] . "';";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row["code"]. " - " . $row["name"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<form action="" method="post">
Country: <input type="text" name="country">
<input type="submit" name ="getData" value="send"></input>
</form>
</body>
</html>
if (isset($_POST['getData']) and isset($_POST['country']))
{
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "World";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT code, name FROM country where name='" . $_POST['country'] . "';";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row["code"]. " - " . $row["name"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<form action="" method="post">
Country: <input type="text" name="country">
<input type="submit" name ="getData" value="send"></input>
</form>
</body>
</html>
Tuesday, 23 June 2015
Receive Yahoo Emails in Outlook 2013 using IMAP
- File > Add Account
- Manual setup or additional server types > Next
- IMAP > Next
- Account Settings:
- Your Name: name show when sending email
- Email address: Yahoo Mail address
- Account Type: IMAP
- Server information: match the Yahoo Mail IMAP settings
- User Name: Yahoo ID
- Password: Yahoo account password
- Require logon using Secure Password Authentication: OFF
- More Settings > Outgoing Server tab
- My outgoing server (SMTP) requires authentication: ON
- Use same settings as my incoming mail server: ON
- Advanced tab settings:
- Incoming server (POP3)
- imap.mail.yahoo.com
- port: 993
- encrypted connection: SSL
- Outgoing server (SMTP)
- smtp.mail.yahoo.com
- port: 587
- encryption type: TLS
- Restart Outlook
- Send/Receive All Folders to sync
Wednesday, 1 April 2015
Tuesday, 3 February 2015
C# and JQuery Mobile Login Popup Form
DEFAULT.ASPX
DEFAULT.ASPX.CS
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
- <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
- <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
- <script>
- function runme() {
- $.ajax({
- type: "POST",
- url: "default.aspx/checkLogin",
- contentType: "application/json; charset=utf-8",
- data: "{'username':'" + $('#un').val() + "','password':'" + $('#pw').val() + "'}",
- dataType: "json",
- success: function (response) {
- var names = response.d;
- alert(names);
- },
- failure: function (response) {
- alert(response.d);
- }
- });
- }
- </script>
- </head>
- <body>
- <form id="form1" runat="server">
- <a href="#popupLogin" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-icon="check" data-theme="a" data-transition="pop">Sign in</a>
- <div data-role="popup" id="popupMenu" data-theme="a">
- <div data-role="popup" id="popupLogin" data-theme="a" class="ui-corner-all">
- <div style="padding: 10px 20px;">
- <h3>Please sign in</h3>
- <label for="un" class="ui-hidden-accessible">Username:</label>
- <input name="user" id="un" value="" placeholder="username" data-theme="a" type="text" />
- <label for="pw" class="ui-hidden-accessible">Password:</label>
- <input name="pass" id="pw" value="" placeholder="password" data-theme="a" type="password" />
- <button data-theme="b" data-icon="check" onclick="runme()">Sign in</button>
- </div>
- </div>
- </div>
- </form>
- </body>
- </html>
DEFAULT.ASPX.CS
- [WebMethod]
- public static string checkLogin(string username, string password)
- {
- Dictionary<string, string> name = new Dictionary<string, string>();
- name.Add(username, password);
- string myJsonString = (new JavaScriptSerializer()).Serialize(name);
- return myJsonString;
- }
Subscribe to:
Posts (Atom)
Analysis Service in Power BI Report Server
We couldn’t connect to the Analysis Services server. Make sure you’ve entered the connection string correctly... link
-
//convert BASE64 string to Byte{} array function base64ToArrayBuffer(base64) { var binaryString = window.atob(base64); var binar...
-
var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter(); htmlToPdf.PageFooterHtml = @"<div style='text-align:right; font-s...
-
static void Main(string[] args) { // create a dummy list List<string> data = GetTheListOfData(); // split the lis...