-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp-user-add.php
51 lines (31 loc) · 1.36 KB
/
php-user-add.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php include 'begin.php'; ?>
<?
$count = mysql_num_rows(mysql_query("SELECT * FROM users WHERE email ='".$_POST['add_user_email']."'"));
if (isset($_POST['add_user_hourly']) && $_POST['add_user_hourly'] == 'on'){
$hourly_user = 1;
}else{
$hourly_user = 0;
}
if ($count == 0){
$datestamp = date('Ymd');
mysql_query("INSERT INTO users (email, password, hourly, manager, createdon) VALUES ('".$_POST['add_user_email']."', '".$_POST['add_user_password']."','".$hourly_user."', '".$_POST['add_user_manager']."', '".$datestamp."')");
//pull fresh id
$result_id = mysql_query("SELECT id FROM users WHERE createdon = '".$datestamp."'");
$row_id = mysql_fetch_array($result_id);
$user_id = $row_id['id'];
mysql_close($con);
echo 'You should recieve a registration email.';
$to = $_POST['add_user_email'];
$subject = 'Mojostuff.com - Mojo Internals Registration';
$message = 'Welcome to mojostuff.com/mi!'. "\r\n". "\r\n";
$message.= 'Username: '.$_POST['add_user_email']. "\r\n";
$message.= 'Password: '.$_POST['add_user_password']. "\r\n";
$message.= 'Password: '.$_POST['add_user_manager']. "\r\n";
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}else{
echo 'User "'.$_POST['add_user_email'].'" already exists.';
}
?>