O'Reilly logo

CouchDB and PHP Web Development Beginner's Guide by Tim Juravich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — making a form to enable Post creation

Let's code the form for post creation right into our user's profile page. This form will only show up if the logged-in user is looking at their own profile.

  1. Open user/profile.php.
  2. Let's first check to see if the profile the user is looking at is their own.
    <div class="span8">
    <?php if ($is_current_user) { ?>
    <h2>Create a new post</h2>
    <?php } ?>
    
    <h2>Posts</h2>
    </div>
    
  3. Next, let's add a form that will allow the currently logged-in user to make posts.
    <div class="span8">
    <?php if ($is_current_user) { ?>
    <h2>Create a new post</h2>
    <form action="<?php echo $this->make_route('/post')?>" method="post"> <textarea id="content" name="content" class="span8" rows="3"> </textarea> <button id="create_post" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required