Assignment II

Gigin Paulose

IT 202

Prof James Mchugh

Registration Form (register.html)

Registration Form (HTML Code)

<!DOCTYPE html>

style>

label { width: 150px; float: left; background: yellow;font-size:12pt ;}

fieldset {margin:auto; margin-top:70px; width: 40%; moz-border-radius:30px;border-radius:30px;webkit-border-radius:30px; }

</style>

script

functionchkpwd()

{

p1=document.getElementById("password1").value

p2=document.getElementById("password2").value

if(p1 != p2){

//if dont match erase value in p2 empty

document.getElementById("password2" ).value=""

document.getElementById("password2" ).focus()

document.getElementById("warn" ).innerHTML=" <b> Password Dont Match</b>"

}

if(p1==p2){document.getElementById("warn" ).innerHTML=""}

}

function pwdtext1()

{

if (document.getElementById("change" ).checked)

{ document.getElementById("password1" ).type="text";}

else

{ document.getElementById("password1" ).type="password";}

}

function pwdtext2()

{

if (document.getElementById("change2" ).checked)

{ document.getElementById("password2" ).type="text";}

else

{ document.getElementById("password2" ).type="password";}

}

</script>

<BODY BGCOLOR="#00FFFF" text="#FF0000" link="##ff0000" alink="#ff0000" >

<form action="check.php">

fieldset

legend>Registration form </legend>

center

<label for ="password1" > Instructor password </label</center>

<input type=password name="password1"id="password1" required autofocus="on" autocomplete="off" placeholder="Enter the Password"<input type=checkbox name"change" id="change" onclick="pwdtext1()">check Password<brbr

<label for ="password2" > Confirm password </label>

<input type=password name="password2"id="password2" required autocomplete="off" placeholder="Comfirm Password" onblur = "chkpwd()" <input type=checkbox name"change2" id="change2" onclick="pwdtext2()">check Password <span id = "warn" font:20px</span</center<brbr

<label for ="uname" >Student Username</label>

<input type=text name="uname"id="uname" autocomplete="off" placeholder="Enter the username" <brbr

<label for ="email" > Email</label>

<input type=text name="email"id="email" autocomplete="off" placeholder="Enter your email" <input type=checkbox name="ckemail" id="ckemail">email details<brbr

<label for ="fullname" > Full Name</label>

<input type=text name="fullname"id="fullname" autocomplete="off" placeholder="Enter your full name" <brbr

<label for ="address" > Address</label>

<input type=text name="address"id="address" autocomplete="off" placeholder="Enter your address" <brbr

<label for ="major" > Major</label>

<input type=text name="major"id="major" autocomplete="off" placeholder="Enter your major" <brbr

<label for ="phone" > Phone Number</label>

<input type=text name="phone"id="phone" autocomplete="off" placeholder="Enter your phone number" <brbr

</center>

<input type=submit<br

</form>

</fieldset

<h1<center<a href="grade.html">Click Here For Grades.html</a</h1<brbr

center<a href="images/Gigin-Web-Experience2.PNG">MY Experience </a<brbr

center<a href="register.txt">My PHP Code for Register</a<brbr</center>

</body>

</html>

Registration Form (PHP Code)

<?php

//echo "<br>hello<br>";

include ("account.php") ;

( $dbh = mysql_connect ( $hostname, $username, $password ) )

or die ( "Unable to connect to MySQL database" );

print "Connected to MySQL<brbr>";

mysql_select_db( $project );

$uname = $_GET["uname"];

$uname= mysql_real_escape_string($uname);

$email= $_GET["email"];

$email= mysql_real_escape_string( $email);

$fullname= $_GET["fullname"];

$fullname= mysql_real_escape_string($fullname);

$phone= $_GET["phone"];

$phone= mysql_real_escape_string($phone);

$address= $_GET["address"];

$address= mysql_real_escape_string($address);

$major = $_GET["major"];

$major= mysql_real_escape_string($major);

$time= date('Y-m-d H:i:s');

include ("function_inc.php");

$count =REGISTERED_count($uname,$email);

if($count=="555")

{die("The Username ' $uname ' already taken GOOD BYE");};

if($count=="777")

{die("Email '$email ' Already infile GOOD BYE");};

$s= "insert into REGISTERED values('$uname', '$email', '$fullname', '$phone','$address',now(),'$major')";

( $t = mysql_query ( $s ) ) or die ( mysql_error() );

print " Registered successfully Dear $fullnamebr/>";

print " your username will be :$unamebr/>";

print " Email: $email<br/>";

print " Phone No :$phone<br/>";

print " Address :$address<br/>";

print " Major :$major<br/>";

print " Time Of register: $time<br/>";

print " Thank You!br/>";

if(isset($_GET["ckemail"]))

{

$to = $email;

$subject="Registration Info for $uname";

$message="Dear $fullname,

Username: $uname

Address : $address

Email : $email

Phone : $phone

Major: $major

You successfully Registered ! Welcome Aboard and Good Luck with your course of study !";

mail ($to , $subject , $message);

print" $to $subject $message";

print "DetailsEmailed to $email ";

};

?>

Grades Form (grade.html)

Grades Form (HTML Code)

<!DOCTYPE html>

style>

label { width: 150px; float: left; background: yellow; }

fieldset {margin:auto; margin-top:70px; width: 60%; moz-border-radius:30px;border-radius:30px;webkit-border-radius:30px;}

</style>

<BODY BGCOLOR="#00FFFF" text="#000000" link="##ff0000" alink="#ff0000" >

form action = "grade.php"

oninput = "y.value = x.value;

v.value = u.value;" >

fieldset style = "border:#0000ff 2px solid;">

<legend style="color:#0000ff; font:20px;">Grades form </legend>

fieldset style = "border:#F00 2px solid;">

<label for ="password" > Password </label>

<input type=password name="password"id="password" required autofocus="on" autocomplete="off" placeholder="Enter the Password"<brbr

<label for ="uname" > Student Username</label>

<input type=text name="uname"id="uname" placeholder="Enter the username" onclick="chkpwd()"<brbr

<label for ="course" >Course</label>

<input type=text name="course"id="course" placeholder="Enter your course" >

</fieldset

fieldset style = "border:#F00 2px solid;"<br

<label for ="x" > A1 </label>

input name="x" id = "x" type="range" value="0" step=1 min=0 max=50>

<input type=checkbox name= "A1ck" id="A1ck">

<input type=date name="A1S"id="A1S" placeholder="Enter the data"> A1Sbr

<output name="y" </output<br

<label for ="u" > A2 </label>

input name="u" type="range" id ="u" value="0" step=1 min=0 max=50>

<input type=checkbox name= "A2ck" id="A2ck">

<input type=date name="A2S"id="A2S" placeholder="Enter the data"> A2Sbr

<output name="v" </output<br

br

<label for ="PARTIC" > AdditivePartic Pts </label>

<input type=text name="PARTIC" id="PARTIC"<brbr

</fieldsetbr

center<input type=submit<br

</fieldset

</form>

<a href="grade.txt">Click here for PHP Code for Grades</a<brbr

</body>

</html>

Grades Form (PHP Code)

<?php

include ("account.php") ;

( $dbh = mysql_connect ( $hostname, $username, $password ) )

or die ( "Unable to connect to MySQL database" );

print "Connected to MySQL<brbr/>";

mysql_select_db( $project );

$uname = $_GET["uname"];

$uname = mysql_real_escape_string($uname);

$course = $_GET["course"];

$course= mysql_real_escape_string($course);

$A1 = $_GET["x"];

$A1= mysql_real_escape_string($A1);

$A1S = $_GET["A1S"];

$A1S= mysql_real_escape_string($A1S);

$A2 = $_GET["u"];

$A2= mysql_real_escape_string($A2);

$A2S = $_GET["A2S"];

$A2S = mysql_real_escape_string($A2S);

$PARTIC = $_GET["PARTIC"];

$PARTIC = mysql_real_escape_string($PARTIC);

$x = $_GET["password"];

// checking password hashed

$sts="select * from SECRET where hashed= sha1('$x')";

$tot=mysql_query($sts);

(mysql_num_rows($tot)!=0)or die("Password is wrong! please check your password BYE");

include ("function_inc.php");

// If $username not REGISTERED then exit & message

$count=REGISTERED_count($uname);

if($count=="0"){die("The Username ' $uname ' is not registered. First register before trying to grade. GOOD BYE");};

// username is there but no course

$onlyname=GRADES_count ($uname,$course);

if ($onlyname=="0"){

$newrow = "Insert into GRADES values('$uname', '$course','0', '0', '0', '0', '0', '0', '0')";

( $row = mysql_query ( $newrow ) ) or die ( mysql_error() );

print "New Row for the course $course created";}

// both username and course are there.

$boththere=GRADES_count ($uname,$course);

if ($boththere=="1")

{

if(isset($_GET["A1ck"]))

{

$upa1 = "UPDATE `GRADES` SET `A1` = '$A1', `A1S` = '$A1S' WHERE `username` = '$uname' AND `course` = '$course'";

($uprow = mysql_query($upa1)) or die (mysql_error());

print "A1 n A1S updatetdbr/>";

}

if(isset($_GET["A2ck"]))

{

$upa2 = "UPDATE `GRADES` SET `A2` = '$A2', `A2S` = '$A2S' WHERE `username` = '$uname' AND `course` = '$course'";

($uprow = mysql_query($upa2)) or die (mysql_error());

print "A2 updatetdbr/>";

}

};

//partic

$particGrade=$_GET["PARTIC"];

if($particGrade>=0)

{

$upa3 = "UPDATE `GRADES` SET `PARTIC` = `PARTIC`+'$particGrade' WHERE `username` = '$uname' AND `course` = '$course'";

($UpPar = mysql_query($upa3)) or die (mysql_error());

print "Partic grade added <br/>";

};

// updating total and per of 150

$total="UPDATE `GRADES` SET `TOTAL` = `A1`+`A2`+`PARTIC` WHERE `username` = '$uname' AND `course` = '$course'";

($stot = mysql_query($total)) or die (mysql_error());

$percent="UPDATE `GRADES` SET `PERCENTof150` =100*`TOTAL`/150 WHERE `username` = '$uname' AND `course` = '$course'";

($upPer = mysql_query($percent)) or die (mysql_error());

print"TOTAL & PERCENTof150 <br/>";

?>

Snapshot of a results of JavaScript test for mismatched passwords

Snapshot of the DB table for the hashed passwords

Snapshot of before and after for a GRADES update including the update data.

Before update

Html update to update

After update

Snapshot of REGISTERED table after inserting an entry [just a sample of the table rows]

Before

After