MySQL Insert...
Posted: Wed Aug 06, 2008 1:43 pm
I was wondering how I could check if values have been inserted into the database table successfully?
Also, my register code doesn't seem to work as it comes up with the blue error below the insert statement...
This is really annoying me now.
Thanks in advance for the help.
Also, my register code doesn't seem to work as it comes up with the blue error below the insert statement...
Code: Select all
<?php
require_once('include.php');
$error = '';
$form = $_POST['submit'];
$username = mysql_real_escape_string( $_POST['username'] );
$password = mysql_real_escape_string( $_POST['password'] );
$email = mysql_real_escape_string( $_POST['email'] );
if( isset($form) ) {
if( isset($username) && isset($MD5password) && $username !== '' && $password !== '' ) {
$MD5password = md5( $password );
$MD52password = md5( $MD5password );
$sql = mysql_query("INSERT INTO example
(username, password, email) VALUES('$username', '$MD52password', '$email' ) ");
} else { $error = 'All information is not filled out correctly';}
}
?>
<!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=iso-8859-1" />
<title>Register</title>
</head>
<body>
<form action="<?php $PHP_SELF; ?>" method="post" >
Username:
<input name="username" type="text" value="<?php echo "$username";?>" /><br />
Password:
<input name="password" type="password" /><br />
Email:
<input name="email" type="text" value="<?php echo "$email";?>" /><br />
<input name="submit" type="submit" value="Register" />
</form>
<?php
echo "<br /><span style=\"color:blue\">$error</span>";
?>
</body>
</html>Thanks in advance for the help.