Skip to content

Commit 62e5213

Browse files
committed
added email validation
1 parent c02fa42 commit 62e5213

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

web/add/user/index.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
$v_lname = escapeshellarg($_POST['v_lname']);
3737
if (empty($_POST['v_notify'])) $v_notify = 'off';
3838

39+
// Validate email
40+
if (!filter_var($_POST['v_email'], FILTER_VALIDATE_EMAIL)) {
41+
$_SESSION['error_msg'] = 'Please enter valid email address.';
42+
}
43+
3944
// Check for errors
4045
if (!empty($errors[0])) {
4146
foreach ($errors as $i => $error) {
@@ -46,7 +51,9 @@
4651
}
4752
}
4853
$_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank.";
49-
} else {
54+
}
55+
56+
if (empty($_SESSION['error_msg'])) {
5057
exec (VESTA_CMD."v_add_user ".$v_username." ".$v_password." ".$v_email." ".$v_package." ".$v_fname." ".$v_lname, $output, $return_var);
5158
if ($return_var != 0) {
5259
$error = implode('<br>', $output);
@@ -67,7 +74,7 @@
6774
$mailtext .= "https://".$_SERVER['HTTP_HOST']."/login/\n";
6875
$mailtext .= "username: ".$_POST['v_username']."\n";
6976
$mailtext .= "password: ".$_POST['v_password']."\n\n";
70-
$mailtext .= "Have a nice day,\nThe VestaCP Team\n";
77+
$mailtext .= "--\nVesta Control Panel\n";
7178
send_email($to, $subject, $mailtext, $from);
7279
}
7380

0 commit comments

Comments
 (0)