Selaa lähdekoodia

users can now change their email address

pull/16/head
mauirixxx 7 vuotta sitten
vanhempi
commit
7949e3f8c1
2 muutettua tiedostoa jossa 14 lisäystä ja 9 poistoa
  1. +9
    -1
      includes/update-email.php
  2. +5
    -8
      preferences.php

+ 9
- 1
includes/update-email.php Näytä tiedosto

@@ -1,3 +1,11 @@
<?php
echo 'code to verify & sanitize a users updated e-mail address goes here!<br /><br />';
include_once ('verifications.php');
echo 'the useremail variable is: ' . $_POST['useremail'] . '<br />';
echo 'the userid variable is: ' . $_SESSION['userid'] . '<br />';
$updmail = $con->prepare("UPDATE userinfo SET usermail = ? WHERE userid = ?");
$updmail->bind_param("si", $_POST['useremail'], $_SESSION['userid']);
$updmail->execute();
$_SESSION['usermail'] = $_POST['useremail'];
echo 'Email address updated, redirecting.';
header ("Refresh:2; url=preferences.php");
?>

+ 5
- 8
preferences.php Näytä tiedosto

@@ -1,25 +1,22 @@
<?php
$pagetitle = "Account options";
include_once ('header.php');
if (!empty($_POST['usermail'])) {

if (!empty($_POST['useremail'])) {
//this section contains code to update the users e-mail address, maybe via an include?
include_once ('includes/update-email.php');
} else {
//should get rid of this whole else statement, or use it to display an error?
echo 'this should probably be the !empty section instead<br />';
echo 'the post usermail vaiable should be blank: <b>' . $_POST['usermail'] . '</b> <- Is there a blank spot to the left?<br />';
}
echo '<h3>Change e-mail and / or password</h3><br /><br />';
echo '<h3>Change e-mail and / or password</h3>';

// listing all session variables currently set for debugging purposes
echo '<pre>';
var_dump($_SESSION);
echo '</pre><br /><br />';
echo '</pre><br />';
// delete the above 3 lines when done

echo '<form action="preferences.php" method="post"><table border="1">';
echo '<caption>Update e-mail address</caption>';
echo '<tr><td><input type="text" name="usermail" value="' . $_SESSION['usermail'] . '"></td><td><input type="submit" value="Update e-mail"></td></tr>';
echo '<tr><td><input type="text" name="useremail" value="' . $_SESSION['usermail'] . '"></td><td><input type="submit" value="Update e-mail"></td></tr>';
echo '</table></form><br />';
include_once ('footer.php');
?>

Ladataan…
Peruuta
Tallenna