Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * This page changes the user's email address.
- */
- session_start();
- // ignore ereg warning
- error_reporting(E_ALL ^ E_DEPRECATED);
- $uname = $_SESSION['name'];
- $newmail = $_POST['newemail'];
- $emailvalid = true;
- // DB connection info
- $servername = "tund.cefns.nau.edu";
- $username = "mlb652script";
- $password = "ChelseaFC123";
- $dbname = "mlb652";
- // Making connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Checking connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- // Sql query to change email
- $sql = "UPDATE users SET email = '$newmail' where username = '$uname'";
- // Make sure email isn't empty
- if (empty($newmail)) {
- $emailvalid = false;
- }
- // Make sure it is actually an email
- if (!ereg('^[A-Za-z][a-zA-Z0-9_\-\.]*@[a-zA-z0-9\-]+\.[a-zA-Z0-9\-\.]+$', $newmail)) {
- $emailvalid = false;
- }
- if ($emailvalid == true) {
- // Run query
- if ($conn->query($sql) === TRUE) {
- echo "Record updated successfully";
- } else {
- echo "Error updating record: " . $conn->error;
- }
- // Redirect back to user page
- header("Location: http://cefns.nau.edu/~mlb652/userpage.php");
- }
- ?>
- <HTML>
- <head>
- <link href='https://fonts.googleapis.com/css?family=Muli' rel='stylesheet' type='text/css'>
- <link rel="stylesheet" type="text/css" href="main_style.css">
- <link rel="stylesheet" type="text/css" href="article_style.css">
- <title>Gameplay</title>
- </head>
- <!-- Begin top bar used to display page title -->
- <div id="pagecontainer">
- <div class="topbar">
- <h1>
- <a href="index.php">
- <img src="./images/altmid.png" alt="Alt-Mid Banner" title="Alt-Mid"/>
- </a>
- </h1>
- </div>
- <!-- end top bar -->
- <!-- Begin Sidebar -->
- <div class="Sidebar">
- <h1>User Page</h1>
- <p>Welcome to your user page, here you can edit your details or delete your account.</p>
- <div id="logo">
- <a href="mysql_connect_test.php">
- <img src="./images/log.png">
- </a>
- </div>
- </div>
- <!-- End Sidebar -->
- <!-- Begin top menu table -->
- <div>
- <section class="topmenu">
- <div class="top_opt">
- <img src="./images/pronews.png" alt="Pro News" title="Pro News"/>
- </div>
- <div class="top_opt">
- <a href="gameplay.php">
- <img src="./images/gameplay.png" alt="Gameplay" title="Gameplay"/>
- </a>
- </div>
- <div class="top_opt">
- <a href="community.php">
- <img src="./images/community.png" alt="Community" title="Community"/>
- </a>
- </div>
- </section>
- </div>
- <!-- End top menu table -->
- <!-- Begin Article -->
- <section class ="columns">
- <div class ="article">
- <!-- Forms to allow the user to change password or email -->
- <h1>Email not valid, try again.</h1><br><br>
- <form action="emailchange.php" method="POST">
- <input type="text" name="newemail" id="newemail" size='50' maxlength='75'>
- <input type="submit" value="Change">
- </form>
- <br><br>
- </div>
- </section>
- <div class="footer">
- <div class="contact">
- Email: mlb652@nau.edu<br>
- Phone: +44123456789<br>
- Mail: 10 Downing Street, London, SW1A 2AA
- </div>
- <div class="logout">
- <?php
- // If the user currently has a session then display a logout button so the user can end it.
- if (isset($_SESSION['name'])) {
- echo "<form action='logout.php' method='POST'>
- <input type='submit' value='Logout'>
- </form>";
- }
- ?>
- </div>
- <div class="notifications">
- <?php
- // Displays the user name in the notifications window if a session exists.
- if (isset($_SESSION['name'])) {
- echo "Welcome ";
- echo $_SESSION['name'];
- echo "!";
- }
- else{
- echo "0 New Notifications!";
- }
- ?>
- </div>
- </div>
- </div>
- </div>
- </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement