Beispiel #1
0
    $message = 'Incorrect Length for Username';
} elseif (ctype_alnum($_POST['username']) != true) {
    /*** if there is no match ***/
    $message = "Username must be alpha numeric";
} elseif (strlen($_POST['password']) > 20 || strlen($_POST['password']) < 4) {
    $message = 'Incorrect Length for Password';
} elseif (strlen($_POST['email']) > 40 || strlen($_POST['email']) < 4) {
    $message = 'Incorrect Length for email';
} else {
    /*** if we are here the data is valid and we can insert it into database ***/
    $username = filter_var($_POST['username'], FILTER_SANITIZE_STRING);
    $password = filter_var($_POST['password'], FILTER_SANITIZE_STRING);
    $email = filter_var($_POST['email'], FILTER_SANITIZE_STRING);
    try {
        $newuser = new Users(NULL, $email, $username, $password);
        $up = new UserPersist();
        $up->save($newuser);
        $message = "Signup successful!";
    } catch (Exception $e) {
        /*** check if the username already exists ***/
        //echo $e->getMessage();
        if ($e->getCode() == 23000) {
            $message = 'Email already exists';
        } else {
            /*** if we are here, something has gone wrong with the database ***/
            $message = 'We are unable to process your request. Please try again later"';
        }
    }
}
?>
    ?>
  <!-- if the user isnt logeed in, redirect to login page-->
		You are not logged in! 
		<br>
		<a href = "index.html">Login</a>
	<?php 
}
?>
<tr>
<td> 

<?php 
// getch the all the posts,comments,likes from the DB for that user id
$ps1 = new Post_persist();
$reslt = $ps1->getPostByUserId($_SESSION['curruser']);
$us1 = new UserPersist();
$urw = $us1->getUserById($_SESSION['curruser']);
$user = $urw['user'];
foreach ($reslt as $row1) {
    ?>
	<div class="w3-container w3-padding-32 w3-teal">
		<b><?php 
    print $user;
    ?>
 says:</b> <br/>
		<?php 
    print $row1['time'];
    ?>
	</div>
	<section class="w3-container w3-border"> 
		<p>