Posted: Mon Aug 21, 2006 12:24 am
if noone can help fix the code, does any know where to look?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
if ($users_current_email == $users_changed_email){
// update all information
}else{
//check if email exists
}
if ($users_changed_email exists){
// throw error
}else{
//update
}Code: Select all
if ($users_current_email == $users_changed_email){
$sql = mysql_query("UPDATE `users` SET email_address = '{$email_address}' WHERE userid = '{$userid}' ");
$sql = mysql_query("UPDATE `basic` SET gender = '($gender)' WHERE userid = '($userid)'");
$sql = mysql_query("UPDATE `basic` SET month = '($month)' WHERE userid = '($userid)'");
$sql = mysql_query("UPDATE `basic` SET day = '($day)' WHERE userid = '($userid)'");
$sql = mysql_query("UPDATE `basic` SET year = '($year)' WHERE userid = '($userid)'");
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
echo mysql_error();
} else {
echo 'E-Mail updated! This is your new login, so remember it! '.$email_address.'';
}
}else{
$sql_email_check = mysql_query("SELECT username FROM users WHERE email_address='$email_address'");
$email_check = mysql_num_rows($sql_email_check);
$check = mysql_fetch_array($sql_email_check);
if($check['user']!=$username){
echo "Please fix the following errors: <br />";
echo "<strong>Your email address has already been used by another member in our database. Please use a different email address!<br />";
exit(); }
}
if ($users_changed_email exists){
// throw error
}else{
//update
}Code: Select all
if ($users_current_email == $users_changed_email){
// update all information
}else{
//check if email exists
}
if ($users_changed_email exists){
// throw error
}else{
//update
}Code: Select all
$email_address = $users_current_emailCode: Select all
<?php
if (isset($_POST['check_some_filed_other_than_submit']))
{
// Form was posted
// Edit this post var to be the same name as the form field for user_email
$user_email = $_POST['email_form_field'];
// Edit this post var to be the same name as the form field for user_name
$user_name = $_POST['username_form_field'];
// Change the field names to be the what you need them to be
$sql = "SELECT COUNT(`user_id`) AS check_count
FROM `user_table`
WHERE `user_email` = '$user_email'
AND `user_name` != '$user_name'";
if (!$result = mysql_query($sql))
{
die('Could not get count to check email against: ' . mysql_error());
}
// Use the query return value ...
while ($row = mysql_fetch_array($result))
{
$check_count = $row['check_count'];
}
// ...to check if that email exists in the database already
if ($check_count <> 0)
{
// If we get here then the supplied email address exists
// in the database for some other persons record.
// That means we need to error out of the script somehow
// Pick your poison, for now I am just going to die
die('The email address you entered is already is use in the system, please enter another one');
}
else
{
// If we are here, then the email address does not exist in the system
// But it could already be in there for this user, so we need to check
// that, and if so, handle it appropriately
// But this is up to you so take care of that on your own
}
}
?>Code: Select all
# grab the POST variables from the HTML form
$email_address = $_POST['email_address'];
# Any escaped characters?
$email_address = stripslashes($email_address);
# does this user already exist in the database?
$sql_email_check = mysql_query("SELECT username FROM users WHERE email_address='$email_address'");
$email_check = mysql_num_rows($sql_email_check);
$check = mysql_fetch_array($sql_email_check);
if($check['user']!=$username){
echo "Please fix the following errors: <br />";
echo "<strong>Your email address has already been used by another member in our database. Please use a different email address!<br />";
exit(); }