my code wont insert data from form into the database
Here is the code
<?php
include("connect1.php");
if (!empty($_POST['email']) && !empty($_POST['password']) && !empty($_POST['confirm']) && !empty($_POST['submit']))
{
// Declare Variables
$Email = mysql_real_escape_string($_POST['email']);
$Password = mysql_real_escape_string($_POST['password']);
$Confirm = mysql_real_escape_string($_POST['confirm']);
// Encrypt passwords with md5 encryption
$Password = md5($Password);
$Confirm = md5($Confirm);
if($Password != $Confirm)
{
echo "<br>The two passwords did not match<br>";
}
else
{
// Check if the email already exists in database
$query = "SELECT * FROM users WHERE Email = '$Email' ";
$results = mysql_num_rows(mysql_query($query));
if ($results > 0)
{
echo "sorry email already exists";
}
else
{
// Insert information to the database
mysql_query("UPDATE users SET Password='$Password' WHERE Email='$Email'");
//Send them to login
header("Location:http://dragonofsun.com/success.html");
}
}//else
}//if
?>
<!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>Sign up page</title>
<style type="text/css">
body {
background-color: #000000;
color: #ffffff;
}
#center_div {
vertical-align: middle;
}
a:link, a:hover, a:active, a:visited {
color: gold;
}
.style1 {
font-size: larger;
color: #FFD700;
}
</style>
</head>
<body>
<p align="center" class="style1">Realm of the Sun Dragon sign up form</p>
<table align="center" cellpadding="10px"><tr><td> Please enter your email: <form action="signup.php" method="POST" >
<input type="text" name="email"></td></tr>
<tr><td>
Please enter your password:<br>
<input type="password" name="password">
</td></tr>
<tr><td>Please Confirm that Password:<br>
<input type="password" name="confirm"></td></tr>
<tr><td><input type="submit" name="submit" value="Sign Up"></form></td></tr></table>
<br /><br />
<center><font face=Arial>Copyright © 2010, <a target=_blank href="http://derekvanderven.com"> by Derek Van Derven</a></font></center></body></html>
</p>
</body>
</html>
View full post on Webmaster-Talk.com
code, Data, Database, Form, from, insert, into, Won't