Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- *Edit profile Page
- */
- session_start();
- $con = mysqli_connect("localhost","root","","WebsiteDB");
- if (mysqli_connect_errno())
- {
- echo "MySQLi Connection was not established: " . mysqli_connect_error();
- }
- ?>
- <!DOCTYPE HTML>
- <head>
- <script type="text/javascript" src="./../js/jquery-3.2.1.min.js"></script>
- <script type = "text/javascript" src="./../plugin/tinymce/tinymce.min.js"></script>
- </head>
- <div id="Edit-Profile">
- <form method="POST" action="./editprofile.php">
- <?php
- $name = $_GET["username"];
- $yourroleid = $_SESSION['rid'];
- $yourownuid = $_SESSION['uid'];
- $sqlq = "Select UserNameID, userName, Role, IP_ADD , Notes, Welcome_Note, RoleName FROM UserName INNER JOIN Role ON UserName.Role=Role.RoleID WHERE UsernameID = $name";
- $runq = mysqli_query($con,$sqlq);
- $resultrow = mysqli_fetch_row($runq);
- $usnid = $resultrow[0];
- $usn = $resultrow[1];
- $currentroleid = $resultrow[2];
- $ipadd= $resultrow[3];
- $notes = $resultrow[4];
- $Welcomenote = $resultrow[5];
- $rank = $resultrow[6];
- $checkifexist = mysqli_num_rows($runq);
- /**
- Obtaining Roles
- */
- //Connect to our MySQL database using the PDO extension.
- $pdo = new PDO('mysql:host=localhost;dbname=WebsiteDB', 'root', '');
- $obtainallroles = "Select * FROM Role";
- //Prepare the select statement.
- $stmt = $pdo->prepare($obtainallroles);
- //Execute the statement.
- $stmt->execute();
- //Retrieve the rows using fetchAll.
- $allroles = $stmt->fetchAll();
- if ($checkifexist == 0)
- {
- header("Location: ./editprofile.php?username=". $yourownuid); //checks if user exist, if not, redirect to your own page
- die();
- }
- ?>
- <?php if ($yourroleid == 1) : ?> <!-- If SysOP -->
- <p>Username: <?php echo $usn;?></p>
- <p>IP Address: <?php echo $ipadd;?></p>
- <p>Country:</p>
- <!-- Modified an online script to loop through , ensures that the dropdown shows your current rank! -->
- <p>Rank:
- <select name="Rank"><?php foreach($allroles as $rn): ?>
- <?php if ($currentroleid != $rn['RoleID']) : ?>
- <option value="<?= $rn['RoleID']; ?>"><?= $rn['RoleName']; ?></option>
- <?php else:?>
- <option selected="selected" value="<?= $rn['RoleID']; ?>"><?= $rn['RoleName']; ?></option>
- <?php endif; ?>
- <?php endforeach; ?>
- </select> </p>
- <p>Password: <input type = "password" class="input" placeholder="Enter your new Password here" name="pw1"></br>
- <input type = "password" class="input" placeholder="Enter it again" name="pw2"></br>
- <input type="checkbox"></p>
- <p>Profile Note: </p>
- <script type = "text/javascript">
- tinymce.init({
- selector: 'textarea',
- branding: false,
- // change this value according to your HTML
- height : 300,
- width:700,
- });</script>
- <textarea id = "test"><?php echo $notes; ?></textarea>
- <p>Welcome Page:
- <textarea id = "test"><?php echo $Welcomenote; ?></textarea>
- </p>
- <div id="EditButton">
- <button type="submit" name="btnEdit" id="Edit1" value="Edit">Edit</button>
- </div>
- <?php elseif ($yourroleid == 2): ?> <!-- else if Administrator -->
- <?php if ($currentroleid == 1 OR $currentroleid == $yourroleid) : ?>
- <!--If Userpage is an admin or SysOP - Only SysOPs can edit other SysOPs and Admins, Admins can only edit classes below them! Admins will not be able to view notes for other Admins or SysOP-->
- <p>Username: <?php echo $usn;?></p>
- <p>IP Address: <?php echo $ipadd;?></p>
- <p>Country:</p>
- <!-- Modified an online script to loop through , ensures that the dropdown shows your current rank! -->
- <p>Rank: <?php echo $rank; ?></p>
- <p>Welcome Page: <?php echo $Welcomenote; ?></p>
- <div id="EditButton">
- <button type="submit" name="btnEdit" id="Edit1" value="Edit">Edit</button>
- </div>
- <?php else: ?>
- <p>Username: <?php echo $usn;?></p>
- <p>IP Address: <?php echo $ipadd;?></p>
- <p>Country:</p>
- <!-- Modified an online script to loop through , ensures that the dropdown shows your current rank! -->
- <p>Rank:
- <select name="Rank"><?php foreach($allroles as $rn): ?>
- <?php if ($currentroleid != $rn['RoleID']) : ?>
- <option value="<?= $rn['RoleID']; ?>"><?= $rn['RoleName']; ?></option>
- <?php else:?>
- <option selected="selected" value="<?= $rn['RoleID']; ?>"><?= $rn['RoleName']; ?></option>
- <?php endif; ?>
- <?php endforeach; ?>
- </select> </p>
- <p>Profile Note: <?php echo $notes; ?></p>
- <p>Welcome Page: <?php echo $Welcomenote; ?></p>
- <div id="EditButton">
- <button type="submit" name="btnEdit" id="Edit1" value="Edit">Edit</button>
- </div>
- <?php endif; ?>
- <?php elseif ($name == $yourownuid): ?> <!-- else if you are logged in as your own user and browsing your own page -->
- print "self";
- <?php else: ?>
- <?php endif; ?>
- <?php
- if (isset($_POST['btnEdit']))
- {
- echo "good job";
- }
- else
- {
- echo "bad";
- }
- ?>
- </form>
- </div>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement