Jump to content

[SOLVED] Full email not inserting properly into database


BrianM

Recommended Posts

Everything worked out great, surprisingly, since this is my first time writing my own PHP registration form that inserts information into a database... until I took a closer look at the `email` field in the database. The problem is, it wont display the entire email which is typed in the form. Say I type my email (medley.brian@yahoo.com), it will only insert 'medley.brian' into the `email` field, leaving off @yahoo.com ... is there anything I should add to my code to have the email insert properly into the database?

 

Here is what I have.

 

Registration page:

<!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>Game Zero - Community</title>
</head>
<?php

mysql_connect('localhost', 'brian', '*password*')
or die(mysql_error());
mysql_select_db('gamezero')
or die(mysql_error());

if (isset($_POST['register'])) {
if (!$_POST['firstName'] | !$_POST['lastName'] | !$_POST['email'] |!$_POST['password'] | !$_POST['gender']) {
	echo 'You have failed to complete all required fields.';
	}
$email_check = $_POST['email'];
$check_one = mysql_query("SELECT email FROM gamezero_members WHERE email = '$email_check'")
	or die(mysql_error());
$check_two = mysql_num_rows($check_one);
if ($check_two != 0) {
	echo ''.$_POST['email'].' is already a registered email address.';
	}
if ($_POST['password'] != $_POST['password_two']) {
	echo 'Your passwords did not match.';
	}
$_POST['password'] = md5($_POST['password']);
$insert = "INSERT INTO gamezero_members (firstName, lastName, email, password, gender) VALUES ('".$_POST['firstName']."', '".$_POST['lastName']."', '".$_POST['email']."', '".$_POST['password']."', '".$_POST['gender']."')";
$add_member = mysql_query($insert);

?>

Registration complete!

<?php

} else {

?>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table>
<tr><td>First Name:</td><td>
<input type="text" name="firstName" maxlength="60" />
</td></tr>
<tr><td>Last Name:</td><td>
<input type="text" name="lastName" maxlength="60" />
</td></tr>
<tr><td>Email:</td><td>
<input type="text" name="email" maxlength="60" />
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="password" maxlength="60" />
</td></tr>
<tr><td>Password Confirm:</td><td>
<input type="password" name="password_two" maxlength="60" />
</td></tr>
<tr><td>Gender:</td><td>
<input type="radio" name="gender" value="Male" /> Male <input type="radio" name="gender" value="Female" /> Female
</td></tr>
<tr><th>
<input type="submit" name="register" value="Register" />
</th></tr>
</table>
</form>
</body>
</html>
<?php

}

?>

 

Database structure:

CREATE TABLE `gamezero_members` (
`ID` tinyint NOT NULL auto_increment,
`firstName` varchar(60) NOT NULL,
`lastName` varchar(60) NOT NULL,
`email` varchar(60) NOT NULL,
`password` varchar(60) NOT NULL,
`gender` varchar(6) NOT NULL,
PRIMARY KEY (`ID`)
);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.