Compare commits

...

4 Commits

4 changed files with 43 additions and 9 deletions

View File

@@ -7,9 +7,11 @@
<body>
<div id="root">
<h1>Link Shortener</h1>
<form id="form" action="result.js">
<form id="form" method="GET" action="result.php" onsubmit="return validate()">
<!-- <form id="form"> -->
<label for="url">URL:</label><span class="mandatory">*</span>
<input type="text" name="url" id="URL" value="example.com" required><br><br>
<input type="text" name="url" id="URL" value="https://example.com" required><br><br>
<label for="labels">GLink:</label><span class="mandatory">*</span>
<label for="GLink" id="labels" class="glink">glink.zip/</label><input type="text" name="glink" id="GLink" class="glink" value="exampleWebsite" required>

View File

@@ -1,7 +1,7 @@
const submit = document.getElementById("button");
submit.addEventListener('click', validate);
function validate(e) {
e.preventDefault();
//const submit = document.getElementById("button");
//submit.addEventListener('click', validate);
function validate() {
// e.preventDefault();
const url = document.getElementById("URL");
const glink = document.getElementById("GLink");
@@ -48,7 +48,13 @@ function validate(e) {
error.setAttribute('aria-hidden', true);
error.setAttribute('aria-invalid', false);
console.log("Valid");
return valid;
return valid;
/* var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET','result.php',true);
xmlhttp.send();
console.log(xmlhttp.responseText);*/
} else {
/*flag*/
@@ -62,6 +68,7 @@ function validate(e) {
url.classList.add("invalid");
error.setAttribute('aria-hidden', false);
error.setAttribute('aria-invalid', true);
return false;
}
}

View File

@@ -1,3 +1,5 @@
console.log('Beginning database execution');
const cassandra = require('cassandra-driver');
const client = new cassandra.Client({
@@ -5,4 +7,8 @@ const client = new cassandra.Client({
keyspace: 'glink',
});
const query =
const query = 'SELECT name FROM data WHERE id = ?';
console.log(query);
client.execute(query, [5]).then(result => console.log('User name is %s',result.rows[0].name));

19
result.php Normal file
View File

@@ -0,0 +1,19 @@
<?php
ini_set('display_errors', 1);
use Casssandra;
$cluster = Cassandra::cluster()->build();
$keyspace = 'glink';
$session = $cluster->connect($keyspace);
$statement = new Cassandra\SimpleStatement('SELECT name FROM data WHERE id=5');
$future = $session->executeAsync($statement);
$result = $future->get();
foreach ($result as $row) {
printf("The name is %s",$row['name']);
}
?>