Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Change Profile</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- </head>
- <body>
- <div class="profileForm">
- <?php
- if(file_exists('data.txt')){
- $result= file('data.txt');}
- foreach ($result as $value) {
- $columns= explode('!', $value);
- }
- $upload = "upload/";
- $upload = $upload . basename( $_FILES['uploaded']['name']) ;
- $error = false;
- if ($uploaded_size > 268435456) {
- $error = true;
- }
- if ($error) {
- echo "Your file is too big or invalid type.";
- }
- if (file_exists($target)) {
- echo "The file $filename exists<br>";
- $error = true;
- exit;
- }
- else {
- if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $upload)) {
- echo "The file ".basename( $_FILES['uploaded']['name']). " has been uploaded";
- }
- else {
- echo "Your file was not uploaded.";
- }
- }
- $dir = "upload/";
- chdir($dir);
- array_multisort(array_map('filemtime', ($files = glob("*.*"))), SORT_DESC, $files);
- foreach($files as $filename) {
- echo "<br>";
- break;
- }
- $images = $filename;
- ?>
- <form enctype="multipart/form-data" action="ChangeProfile.php" method="POST">
- <span class="left">Profile picture:</span>
- <img src="upload/<?php echo $images;?>" width="80px" height="80px">
- <input type="file" name="uploaded" />
- <input type="submit" value="submit" />
- </form>
- <form method="POST">
- <br>
- <label class="left" for="regName">User Name:</label>
- <span><?php echo $columns[0]; ?></span>
- <br>
- <label class="left" for="passF">Password:</label>
- <input type="password" name="regPass1" value="<?php echo $columns[1]; ?>" />
- <br>
- <label class="left" for="passF">Repeat Password:</label>
- <input type="password" name="regPass2" value="" />
- <br>
- <label class="left" for="question">Secret Queston:</label>
- <input type="text" name="question" value="<?php echo $columns[2]; ?>" />
- <br>
- <label class="left" for="answer">Secret Answer:</label>
- <input type="text" name="answer" value="<?php echo $columns[3]; ?>" />
- <br>
- <label class="left" for="email">Email:</label>
- <input type="text" name="email" value="<?php echo $columns[4]; ?>" />
- <br>
- <label class="left" for="fName">First Name:</label>
- <input type="text" name="fName" value="<?php echo $columns[5]; ?>" />
- <br>
- <label class="left" for="lName">Last Name:</label>
- <input type="text" name="lName" value="<?php echo $columns[6]; ?>" />
- <br>
- <label class="left">Sex:</label>
- <input type="radio" name="sex" value="male" />male
- <input type="radio" name="sex" value="male" />female
- <br>
- <label class="left" for="birth">Birthday:</label>
- <input type="text" name="day" value="<?php echo $columns[8]; ?>" />
- <input type="text" name="month" value="<?php echo $columns[9]; ?>" />
- <input type="text" name="year" value="<?php echo $columns[10]; ?>" />
- <hr>
- <input type="submit" value="Change Profile" />
- </form>
- </div>
- <?php
- $userName = trim($_POST['regName']);
- $userName = str_replace('!', '', $userName);
- $userPass1 = trim($_POST['regPass1']);
- $userPass1 = str_replace('!', '', $userPass1);
- $userPass2 = trim($_POST['regPass2']);
- $userPass2 = str_replace('!', '', $userPass2);
- $userQuest = $_POST['question'];
- $userAns = $_POST['answer'];
- $userEmail = $_POST['email'];
- $userFirst = $_POST['fName'];
- $userLast = $_POST['lName'];
- $sex = $_POST['sex'];
- $birth = $_POST['day']."!".$_POST['month']."!".$_POST['year'];
- $error = false;
- if ($_POST) {
- if (empty($_POST['regPass1']) || empty($_POST['regPass2']) || empty($_POST['question']) || empty($_POST['answer']) || empty($_POST['email']) || empty($_POST['fName']) || empty($_POST['lName']) || empty($_POST['sex']) || empty($_POST['day']) || empty($_POST['month']) || empty($_POST['year'])) {
- echo "You have to fill all fields!";
- $error=true;
- }
- if (!(preg_match('/^\w{6,}$/', $userPass1))) {
- echo '<p>Invalid Password!</p>';
- $error=true;
- }
- if ($userPass1 != $userPass2) {
- echo "<p>Password doesn't match!</p>";
- $error=true;
- }
- if (!(preg_match('/^\w{3,}$/', $userQuest))) {
- echo "<p>Use only letters and numbers!</p>";
- $error=true;
- }
- if (!(preg_match('/^\w{3,}$/', $userAns))) {
- echo "<p>Use only letters and numbers!</p>";
- $error=true;
- }
- $reg = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/";
- if (!(preg_match($reg, $userEmail))) {
- echo '<p>Invalid email!</p>';
- $error=true;
- }
- if (!(preg_match('/^\w{3,}$/', $userFirst))) {
- echo '<p>Invalid First Name!</p>';
- $error=true;
- }
- if (!(preg_match('/^\w{3,}$/', $userLast))) {
- echo '<p>Invalid Last Name!</p>';
- $error=true;
- }
- if (!(preg_match('/[0-9]$/', $_POST['day']))) {
- echo '<p>Invalid date!</p>';
- $error=true;
- }
- if (!(preg_match('/[[a-zA-Z]$/', $_POST['month']))) {
- echo '<p>Invalid month!</p>';
- $error=true;
- }
- if (!(preg_match('/[0-9]{4}$/', $_POST['year']))) {
- echo '<p>Invalid year!</p>';
- $error=true;
- }
- if (!$error) {
- $result = $userName."!".$userPass1."!".$userQuest."!".$userAns."!".$userEmail."!".$userFirst."!".$userLast."!".$sex."!"."!".$birth."\n";
- file_put_contents('data.txt', $result,FILE_APPEND);
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment