Académique Documents
Professionnel Documents
Culture Documents
name="firstname" name="lastname"
<tr> <td>IPE</td> <td>MC JR college</td> <td>2007</td> <td>97.6%</td> </tr> </table></br></br> <b>Soft Skills</b> <ul> <li><b>operating system</b> :</br> <input type="checkbox" name="c1" value="Windows XP"checked/>windows XP(sp2)</br> <input type="checkbox" name="c2" value="unix"/> unix </br> </li> <li><b>languages :</b></br> <input type="checkbox" value="C"checked />C <input type="checkbox" value="C++" checked/>c++ <input type="checkbox" value="core java" />java </li> <li><b>web technologies</b>:</br> <input type="checkbox" value="java scripts"checked/> java scripts </li> </ul>
name="choice6"
<b>Hobbies:</b></br> <input type="checkbox" name="c7" cricket"checked/> playing cricket</br> <input type="checkbox" name="c8" cricket"/> playing chess</br> <input type="checkbox" name="c9" puzzles"checked/> solving puzzles</br></br> </br>
value="playing
value="playing
valu e="solving
<b>Declaration:</b> <p>I here by declare that the information is true to the best of my knowledge </p> <p>K.Dinesh</p>
above
stated
<p><h1>Click here to submit details</h1></p> <input type="submit" value="clickme"/> </form> </body> </html>
Details.php
<?php print_r('<b>FirstName</b> :'.$_GET['firstname']); print_r('<br>'); print_r('<b>LastName</b> :'.$_GET['lastname']); print_r('<br>'); print_r('<b>Date of birth</b> :'.$_GET['s1']); print_r('-'.$_GET['s2']); print_r('-'.$_GET['s3']); print_r('<br>'); print_r('<b>Gender</b> :'.$_GET['gender']); print_r('<br>'); print_r('<b>Address</b> :'.$_GET['address']); print_r('<b>Educational Qualifications</b> :'.$_POST[u]); print_r('<br>'); print_r('<b>SoftSkills:</br> 1.operating systems</b> :'.$_GET[c1]); print_r(','.$_GET[c2]); print_r('<b></br> 2.Languages</b> :'.$_GET[choice3]); print_r(','.$_GET[choice4]); print_r(','.$_GET[choice5]); print_r('<b></br> 3.Web Technologies</b> :'.$_GET[choice6]); print_r('<b></br>Hobbies </b> :'.$_GET[c7]); print_r(','.$_GET[c8]); print_r(','.$_GET[c9]); ?>
encrypt1.php
<?php $Str_message=$_GET["h"]; function encrypt_decrypt($Str_message) { $Len_Str_message=strlen($Str_message); $Str_Encrypted_message="";
for($position=0;$position<$Len_Str_message;$position++) { $key_to_use=(($Len_Str_message+$position)+1); $key_to_use=(255+$key_t o_use)%255; $byte_to_be_encrypted=substr($Str_message,$position,1); $Ascii_num_byte_to_encrypt=ord($byte_to_be_encrypted); $xored_byte=$Ascii_num_byte_to_encrypt^$key_to_use; $Encrypted_byte=chr($xored_byte); $Str_Encrypted_message.=$ Encrypted_byte; } return $Str_Encrypted_message; } $t=encrypt_decrypt($Str_message); $_GET["h"]=$t; include("encrypt2.php"); ?>
if(preg_match("/\d{4}$/",$_POST["zip"])==0) { $errzip='<p>zip must be 4 digits</p>'; } if(preg_match("/[0-9]{4}-[0-9]{1,2}-[09]{1,2}$/",$_POST["date"])==0) { $errdate='<p>date must comply with this mask yyyy -mmdd</p>'; } if(preg_match("/[0-9a-zA-Z]{5,}$/",$_POST["user"])==0) { $erruser='<p>user must be bigg er than 5 characters and contain only digits , letters, and underscore</p>'; } if(preg_match("/^.*(?={8,})(?=.*[0 -9])(?=.*[a-z])(?=.*[AZ])(?.*[A-Z]).*$/",$_POST["pass"])==0) { $errpass='<p>password must be atleast 8 characters and must contain atleast one lower case letter,one uppercase letter and one digit</p>'; } } ?> </body> <center> <form name="main" action="<?php $PHP_SELF?>" method="post"> <input type="hidden" name="ac" value="login"> <table width="500" border="0" cellpadding="4" cellspa cing="0" border-color="#000000" bgcolor="#EDEFF1"> <tr align="center"> <td colspan="2"> <strong>Field verification </strong> </td> </tr>
<tr> <td> full name:</td> <td> <input name="name" type="text" size="50" maxlength="100" value=" <?php echo $_POST['name']; ?>"/> <?php if(isset($errname)) echo $errname;
?> </td> </tr> <tr> <td> ADDRESS:</td> <td> <input name="address" type="text" size="50" maxlength="250" value="<?php echo $_POST['address']; ?>"></input> <?php if(isset($erraddress)) echo $erraddress; ?> </td> </tr> <tr> <td> Email:</td> <td> <input name="email" type="text" size="50" maxlength="100" value="<?php echo $_POST['email']; ?>"></input> <?php if(isset($erremail)) echo $erremail; ?> </td> </tr> <tr> <td> Zip:</td> <td> <input name="zip" type="text" size="50" maxlength="100" value="<?php echo $_POST['zip']; ?>"></input> <?php if(isset($errzip)) echo $errzip; ?> </td> </tr> <tr> <td>user:</td> <td> <input name="user" type="text" size="50" maxlength="100" value="<?php echo $_POST['user']; ?>"></input> <?php if(isset($erruser)) echo $erruser; ?> </td> </tr> <tr>
<td>phone:</td> <td> <input name="phone" type="text" size="50" maxlength="100" value="<?php echo $_POST['phone']; ?>"></input> <?php if(isset($errphone)) echo $errphone; ?> </td> </tr> <tr> <td> passport:</td> <td> <input name="passport" type="text" size= "50" maxlength="100" value="<?php echo $_POST['passport']; ?>"></input> <?php if(isset($errpassport)) echo $errpassport; ?> </td> </tr> <tr> <td> date:</td> <td> <input name="date" type="text" size="50" maxlength="100" value="<?php e cho $_POST['date']; ?>"></input> <?php if(isset($errdate)) echo $errdate; ?> </td> </tr> <tr> <td> pass:</td> <td> <input name="pass" type="password" size="50" maxlength="100" value="<?php echo $_POST['pass']; ?>"></input> <?php if(isset($errpass)) echo $errpass; ?> </td> </tr> </table> <input type="submit" method="post" value="submit"></input> </form>
</html>
4.Write a php script for login validation.If valid user,print some appropriate message
index.php
<html> <body> <form action="login1.php" method="GET"> <table border="4" align="center"> <tr> <td><b>login</b></td><td><input type="text"/></td> </tr></br>
name="login"
<tr><td><b>password</b></td> <td><input name="password" type="password"/> </td></tr> <tr> <td><input type="submit" name="submit" value="login" /></td> </tr> </table> </form> </body> </html>
login1.php
<?php $log=$_REQUEST["login"]; $pass=$_REQUEST["password"]; echo $log; echo $pass; $con = mysql_connect("localhost","root","welcome"); if (!$con) { die('Could not connect:'.mysql_error()); } $db=mysql_select_db("dinesh"); if(!$db) { die("can't select database"); }
else { $qry="select* from members where login='".$_GET['login']."'and password='".$_GET['password']."' "; $result=mysql_query($qry); echo $result; $num=mysql_num_rows($result); echo $num;
if($result) { if($num==1) { header("location:home.php"); exit(); } else { header("location:index.php"); exit(); } } else { die("query failed"); } }//end of 1st else; ?>
home.php
<?php echo "login successful"; ?>
5.Write a php script which takes as input table name and prints the table entries
table.php
<html> <body> <form action="login.php"> <b>Enter table name to know the values in it</b></br> <input type="text" name="t_name" /> <input type="submit" value="press to see table from "dinesh" database" /> </form> </body> </html>
login.php
<?php $table=$_REQUEST["t_name"];//getting input table name $con = mysql_connect("localhost","root","welcome"); if (!$con) { die('Could not connect:'.mysql_error()); } $db=mysql_select_db("dinesh"); if(!$db) { die("can't select database"); } $query="select * from {$table}"; $result=mysql_query($query); if(!$result) { die("query failed"); } $numrows=mysql_num_rows($result); $field_num=mysql_num_fields($result); while($row=mysql_fetch_row($result)) { foreach($row as $cell) { echo "$cell"; } echo "</br>"; } ?>
$QueryResult=@mysqli_query($this ->DBConnect,$SQLstring)Or die("<p>Unable to perform the query </p>"."<p>Error code " . mysqli_errno($this ->DBConnect).":". mysqli_error($this->DBConnect)) . "</p>"; } public function getHits() { $SQLstring = "SELECT * FROM id=1"; $QueryResult=$this->DBConnect>query($SQLstring) Or die("<p>Unable to perform the query.</p>". "<p>Error code " . mysqli_errno($this ->DBConnect) . ": " . mysqli_error($DBConnect)) . "</p>"; $Row = $QueryResult->fetch_row(); $this->Hits = $Row[1]; $this->Hits = $this->Hits + 1; echo "<p>This page has received " . $this ->Hits . " hits.</p>"; } } ?>
$this ->TableName
WHERE
CountVisits.php
<html> <body> <h3>Hit Counter</h3> <?php $Database = "cse440"; $Table = "hits"; if (class_exists("HitCounter")) { $Counter = new HitCounter(); $Counter->setDatabase($Database); } else { exit("<p>The HitCounter class available!</p>"); } $Counter->setTable($Table); $Counter->getHits(); $Counter->setHits(); ?> </body> </html>
is
not