-
Notifications
You must be signed in to change notification settings - Fork 7
/
changename.php
executable file
·43 lines (43 loc) · 1.78 KB
/
changename.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
<?php
require_once ('Plans.php');
require ('functions-main.php');
require ("syntax-classes.php");
$dbh = db_connect();
$idcookie = User::id();
// Create the new page
$page = new PlansPage('Preferences', 'planname', PLANSVNAME . ' - Change Name', 'changename.php');
if (!User::logged_in()) {
populate_guest_page($page);
//tell them not able to use page
$page->append(new AlertText("You are not allowed to edit this option as a guest.", false));
interface_disp_page($page);
} else
//allowed to edit
{
populate_page($page, $dbh, $idcookie);
$title = new HeadingText('Change Name', 1);
$page->append($title);
if (isset($_POST['user_name'])) //check to see if form has been submitted, process if so.
{
$user_name = htmlspecialchars($_POST['user_name']); //strip out html chars
set_item($dbh, "accounts", "pseudo", $user_name, "userid", $idcookie); //set pseudoname in database
$message = new InfoText("Name changed to <b>" . stripslashes($user_name) . "</b>.", NULL); //tell user their name has been changed
$page->append($message);
} //if changing name
else { //if not changing name, give form
$old_name = stripslashes(get_item($dbh, "pseudo", "accounts", "userid", $idcookie)); //get old name
/* create the page and form */
$nameform = new Form('changename', 'Change Name');
$page->append($nameform);
$nameform->action = 'changename.php';
$nameform->method = 'POST';
/* add fields to the form */
$item = new TextInput('user_name', $old_name);
$nameform->append($item);
$item = new SubmitInput('Change Name');
$nameform->append($item);
} //else, if not changing name, give form
interface_disp_page($page);
} //if is a valid user
db_disconnect($dbh);
?>