Login     Sign up
rambo99 (@rambo99)
76 months ago
645 Views

Hi can some one help give me some code for change email for acc user,i test this code not work.

function emailchange() {
c('
<form method="post" name="form1" action="'.url('account/emailpost').'" >

                <p>
                '.label(t('Current email')).'
                <input type="email" name="email" />
                </p>
                <p>
                '.label(t('New email')).'
                <input type="email" name="email1" />
                </p>
                <p>
                '.label(t('Re-type new email')).'
                <input type="email" name="email2" />
                </p>

                <p>
                <input class="button" type="submit" value="'.t('Save').'" />
                </p>

                </form>');
}

function emailpost() {
    global $client;
    $oemail = ($_POST['email'].'jcow');
    $res = sql_query("select * from ".tb()."accounts where id='{$client['id']}' and email='{$oemail}'");
    $row = sql_fetch_array($res);
    if (!$row['id']) {
        sys_back(t('Wrong email'));
    }
    if (!strlen($_POST['email1'])) {
        sys_back('Please type a new email');
    }
    if ($_POST['email1'] != $_POST['email2']) {
        sys_back('Please re-type new email');
    }
    $password = md5($_POST['email1'].'jcow');
    sql_query("update ".tb()."accounts set email='$email' where id='{$client['id']}'");
    redirect('account/emailchange',1);
}
1 people followed this question
0

function emailpost() {
global $client;
$old_email = $_POST['email'];
$new_email = $_POST['email1'];
if (!strlen($_POST['email'])) {
sys_back('Please type your old new email');
}
if (!filter_var($old_email, FILTER_VALIDATE_EMAIL)) {
sys_back(t('{1} is not a valid email address',$old_email));
}
if (!strlen($_POST['email1'])) {
sys_back('Please type a new email');
}
if (!filter_var($new_email, FILTER_VALIDATE_EMAIL)) {
sys_back(t('{1} is not a valid email address',$old_email));
}
if ($_POST['email1'] != $_POST['email2']) {
sys_back('Please re-type new email');
}
$res = sql_query("select * from ".tb()."accounts where id='{$client['id']}' and email='{$old_email}'");
$row = sql_fetch_array($res);
if (!$row['id']) {
sys_back(t('Wrong email'));
}
sql_query("update ".tb()."accounts set email='$new_email' where id='{$client['id']}'");
redirect('account/emailchange',1);
}

Jcow Master @falcone
76 months ago
@falcone thank falcone,the code it works very well
76 months ago