Jump to content


fiveworlds

Member Since 06 Dec 2012
Offline Last Active Today, 01:03 AM
***--

Topics I've Started

Czochralski process

22 January 2017 - 09:01 PM

The Natural History Museum in London has an exhibit on quartz crystals and their use in silicon growth. Does anybody here know more about the process??


C Https Socket programming

19 January 2017 - 02:58 PM

Currently trying to learn some C in my spare time. I wanted to try creating a https server with winsock. I am not sure if it is possible in pure C I found a tutorial on how to create a telnet server in C http://www.binarytid...mming-tutorial/ which was helpful but doesn't work over http or https


Long hdmi connector

9 January 2017 - 11:48 PM

I am looking for a hdmi cable with a long connector. I got a hdmi cable for my brother for christmas to connect the playstation to his laptop but the connector wasn't long enough to make contact with the pins on the laptop.


Javascript XHR SPA forms.

23 December 2016 - 07:49 PM

I am trying to write a function which will send data to my server, get a response and set secure cookies without having to reload the page. I'm not sure if I am using it correctly though. Everything is fine apart from trying to upload files to the server. I looked it up on stackoverflow http://stackoverflow...-xmlhttprequest and one response mentioned I should use FormData https://developer.mo...rmData/FormData and parse it as raw data on the server http://php.net/manua...rawpostdata.php but I'm not sure how to do that properly.
 

<script>
function sendform(data,action,method,enctype){
  var xhr = new XMLHttpRequest();
  xhr.open(method, action, true);
  xhr.setRequestHeader("Content-type", enctype);
  xhr.credentials = true;
  xhr.send(data);
  xhr.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        document.getElementById("test").innerHTML = this.responseText;
        return false;       
    }
  }
}
function setcookie(id) {
    form = document.getElementById(id);
    action = form.action;
    method = form.method;
    enctype = form.enctype;
    var data = "";
    for(var i=0, inputs = form.getElementsByTagName("input"); i<inputs.length; i=i+1) {
        if(!(inputs[i].type === "checkbox" && inputs[i].checked!="checked")||(inputs[i].type === "radio" && inputs[i].checked!="checked")){
            data = data+inputs[i].name+"="+inputs[i].value +"&";
        }
    }
    for(var i=0, inputs = form.getElementsByTagName("textarea"); i<inputs.length; i=i+1) {
        data = data+inputs[i].name+"="+inputs[i].value +"&";       
    }
   
    for(var i=0, inputs = form.getElementsByTagName("select"); i<inputs.length; i=i+1) {
        data = data+inputs[i].name+"="+inputs[i].options[inputs[i].selectedIndex].value +"&";       
    }
    sendform(data,action,method,enctype);
   
    return false;
   
}
   
function validatepassword(){
    document.getElementById("test").innerHTML = document.getElementById("cpassword").value;
    if(document.getElementById("password").value===document.getElementById("cpassword").value){
        document.getElementById("validatepassword").style.display = "none";
        document.getElementById("password").style.border = "none";
        document.getElementById("cpassword").style.border = "none";
    }else if(document.getElementById("cpassword").value===""){
       
    }
    else{
        document.getElementById("validatepassword").style.display = "initial";
        document.getElementById("password").style.border = "2px solid red";
        document.getElementById("cpassword").style.border = "2px solid red";
    }
}
</script>
<script type="text/javascript" src="countries.js"></script>
<div id="test"></div>
<form method="post" enctype="application/x-www-form-urlencoded" action="cookie.php" id="login" onsubmit="return setcookie(this.id)">
    Username:<input id="username" type="text" name="username" /><br/>
    Password:<input id="password" onblur="validatepassword()" type="password" name="password" /><br/>
    Confirm Password:<input id="cpassword" onblur="validatepassword()" type="password" name="cpassword" /><br/>
    <label id="validatepassword" style="display:none">The passwords don't match</label><br/>
    Select Country:   <select onchange="print_state('state',this.selectedIndex);" id="country" name ="country"></select><br/>
    City/District/State: <select name ="state" id ="state"></select>
   
    <textarea name="comments" ></textarea>
    <button type="submit" >Submit</button>
</form>
<script language="javascript">print_country("country");</script>

 
 

<?php
$cookie_name = "username";
$cookie_value = "John Doe";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/", "127.0.0.1",true,true);
echo $_POST["password"];
?>​

Fun Comp Sci \ Engineering project

17 December 2016 - 05:42 AM

A fun recent completed project of mine I thought would be fun for people here. Convert a manual car to automatic using arduino or an alternative. A typical car runs on a 12volt battery. There will be either 4 buttons gear up, gear down, reverse and clutch alternatively you may leave out the clutch.