<form name="form1" method="POST" action="#" onSubmit="return check();">
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("shg", $con);
$result = mysql_query("SELECT * FROM consumer");
$email=$_POST['myusername'];
$password=$_POST['mypassword'];
$query="select * from consumer where email='$email' and password='$password'";
$result=mysql_query($query);
if(mysql_num_rows($result)==1)
{
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
session_register("myusername");
session_register("mypassword");
}
$query="select * from consumer where email='$_POST[myusername]'";
$res = @mysql_query($query);
while($row = mysql_fetch_array($res))
{
echo "<TABLE BORDER='0' ALIGN='CENTER' WIDTH='95%'>";
echo"<h2>Consumer Registration</h2>";
echo"<h3><b>";
echo"<tr>";
echo"<td>Title</td>";
echo"<td>";
printf("<input type='text' name='t1' value=\"$row[title]\">\n");
echo"</td></tr>";
echo"<tr>";
echo"<td>Firstname</td>";
echo"<td>";
printf("<input type='text' name='n1' value=\"$row[firstname]\">\n");
echo"</td></tr>";
echo"<tr>";
echo"<td>Lastname</td>";
echo"<td>";
printf("<input type='text' name='n2' value=\"$row[lastname]\">\n");
echo"</td></tr>";
echo"<tr>";
echo"<td>Password</td>";
echo"<td>";
printf("<input type='text' name='p1' value=\"$row[password]\">\n");
echo"</td></tr>";
echo"<tr>";
echo"<td>Confirm Password</td>";
echo"<td>";
printf("<input type='text' name='p2' value=\"$row[confirmpassword]\">\n");
echo"</td></tr>";
echo"<tr>";
echo"<td>Title</td>";
echo"<td>";
printf("<input type='text' name='n3' value=\"$row[title1]\">\n");
echo"</td></tr>";
echo"<tr>";
echo"<td>Organisation</td>";
echo"<td>";
printf("<input type='text' name='n4' value=\"$row[organisation]\">\n");
echo"</td></tr>";
echo"<tr>";
echo"<td>Address1</td>";
echo"<td>";
printf("<input type='text' name='n5' value=\"$row[address1]\">\n");
echo"</td></tr>";
echo"<tr>";
echo"<td>Address2</td>";
echo"<td>";
printf("<input type='text' name='n6' value=\"$row[address2]\">\n");
echo"</td></tr>";
echo"<tr>";
echo"<td>City</td>";
echo"<td>";
printf("<input type='text' name='n7' value=\"$row[city]\">\n");
echo"</td></tr>";
echo"<td>State</td>";
echo"<td>";
printf("<input type='text' name='s1' value=\"$row[state]\">\n");
echo"</td></tr>";
echo"<td>Zip</td>";
echo"<td>";
printf("<input type='text' name='z1' value=\"$row[zip]\">\n");
echo"</td></tr>";
echo"<td>Country</td>";
echo"<td>";
printf("<input type='text' name='c1' value=\"$row[country]\">\n");
echo"</td></tr>";
echo"<td>Fax</td>";
echo"<td>";
printf("<input type='text' name='fa1' value=\"$row[fax]\">\n");
echo"</td></tr>";
echo"<td>E-mail</td>";
echo"<td>";
printf("<input type='text' name='e1' value=\"$row[email]\">\n");
echo"</td></tr>";
}
}
mysql_close($con);
?>
<?php
//including the database connection file
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("shg", $con);
$result = mysql_query("SELECT * FROM consumer where email='$_POST[myusername]'");
if($_POST['update'])
{
$title= $_POST['t1'];
$firstname=$_POST['n1'];
$lastname=$_POST['n2'];
$password=$_POST['p1'];
$confirmpassword=$_POST['p2'];
$title1=$_POST['n3'];
$organisation=$_POST['n4'];
$address1=$_POST['n5'];
$address2=$_POST['n6'];
$city=$_POST['n7'];
$state=$_POST['s1'];
$zip=$_POST['z1'];
$country=$_POST['c1'];
$fax=$_POST['fa1'];
$email=$_POST['e1'];
$result="update consumer set title='$_POST[t1]',firstname='$_POST[n1]',lastname='$_POST[n2]',password='$_POST[p1]',confirmpassword='$_POST[p2]',title1='$_POST[n3]',organisation='$_POST[n4]',address1='$_POST[n5]',address2='$_POST[n6]',city='$_POST[n7]',state='$_POST[s1]',zip='$_POST[z1]',country='$_POST[c1]',fax='$_POST[fa1]',email='$_POST[e1]' WHERE email='$_POST[e1]'";
}
mysql_close($con);
?>
<body>
<input type="submit" name="update" value="update" /></td></tr>
</body>
infoitmanoj 0 Light Poster
Octet 45 Newbie Poster Featured Poster
infoitmanoj 0 Light Poster
cmps 26 Light Poster
Octet 45 Newbie Poster Featured Poster
TonyG_cyprus 36 Newbie Poster
TonyG_cyprus 36 Newbie Poster
veedeoo 474 Junior Poster Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.