File name:index.php
<html>
<head>
<script type="text/javascript">
function showUser(str, query)
{
if(document.getElementById("Author").checked==true)
{
query="author";
}else if(document.getElementById("bookname").checked==true)
{
query="bookname";
}else{
document.getElementById("textHint")="please select";
}
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","postback.php?q="+str+"&query_type="+query,true);
xmlhttp.send();
}
</script><title>
Search Books
</title>
</head>
<body>
<form method ="get" >
<div style="background-color:Orange">
<h3>Welcome<?php echo $_GET['username'].", ";
?> Want to search a book?</h3>
Search:<input type="text" name="users" onKeyUp="showUser(this.value)"/><br/>
Search By<br/>
Author<input type="radio" name="query_type" id="Author" onClick="showUser()" checked="checked" style="color: Black"/>or by<input type="radio" name="query_type" id="bookname" onClick="showUser()"/>book name
</div>
</form>
<br />
<div id="txtHint"><b>Person info will be listed here.</b></div>
</body>
</html>
file name: validation.php
<!DOCTYPE html>
<html lang="en">
<?php
$username=$_POST['uname'];
$password=$_POST['pass'];
$conn=mysql_connect('localhost','root','naruto')or die('Error: cannot connect to the MySQL due to this error.<br/>'.mysql_error());
$select_db=mysql_select_db('clc_customer_info')or die('Error: cannot connect to the MySQL due to this error.<br/>'.mysql_error());
$search="select * from `clc_customer_profile` where `Password` = '$password' and `User_Name`='$username'";
$querySQL=mysql_query($search)or die('Error: cannot connect to the MySQL due to this error.<br/>'.mysql_error());
if (mysql_fetch_array($querySQL)>0)
//validate the log-in
{?>
<head>
<meta http-equiv="Refresh" content="5;url=http://localhost:6824/index.php" />
</head>
<body><form action="index.php" method="get"><input type="hidden" name="username" value="<?php $_POST['uname'] ?>"/>
</form>
<div>
<?php echo"proceed to next page in 5 secs<br/>";
}
else
{
echo"input invalid<br/> signing up again in 5 seconds";
?>
<head>
<meta http-equiv="Refresh" content="5;url=http://localhost:6824/log-in.html" />
</head>
<body>
<div>
<?php }
?>
</div>
</body>
</html>
file name:log-in.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>
<body><form id="form1" name="form1" method="post" action="validation.php"><center>
<table width="200" border="1" cellspacing="2" cellpadding="2" bordercolor="#000000" >
<caption>
<table border="0" cellpadding="0"><tr><td bgcolor="#33FF00">register here</td></tr></table>
</caption>
<tr>
<th scope="col" bgcolor="#FFFF00">Username</th>
<th scope="col"><span id="sprytextfield1">
<label>
<input type="text" name="uname" id="uname" />
</label>
<span class="textfieldRequiredMsg">A username is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></th>
</tr>
<tr>
<th scope="row" bgcolor="#0099FF">Password</th>
<td><span id="sprytextfield2">
<label>
<input type="password" name="pass" id="pass" />
</label>
<span class="textfieldRequiredMsg">A password is required.</span></span></td>
</tr>
<tr>
<th colspan="3" scope="row"><label>
<input type="submit" name="submitt" id="submitt" value="Submit" />
<input type="reset" name="clear" id="clear" value="Clear" />
</label></th>
</tr>
</table></center>
</form>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextefield1", "custom");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
//-->
</script>
</body>
</html>
the problem agenda:
from log-in.html the user will log his/her username and password from there the username textbox will be copied to the <input type="hidden" name="username" value="<?php $_POST ?>". Now I want to GET the value of hidden tag and reveal it in index.php
but the problem is I cannot have connections betwween post and get method... because index.php will search items from the database of books. So this will be get method. on the contrary you cannot get the value of the log-in page because we all know that if we use get for log-in, then we will be prone to hacking. Now what should I do to get the hidden tag's value.