Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //users controller code
- public function adduserAction()
- {
- //assign post vars
- $username = $this->_request->getPost('name');
- $password = $this->_request->getPost('password');
- $details = $this->_request->getPost('details');
- //bit of housework
- $username = mysql_escape_string($username);
- $password = mysql_escape_string($password);
- $details = mysql_escape_string($details);
- //do some error checking on the content (basic != '' validation)
- if ($username != '' && $password != '' && $details != ''){
- $this->view->userName = $username;
- $this->view->userPassword = $password;
- $this->view->userDetails = $details;
- //redirect them to the confirmation page / action
- $this->render('confirmuser');
- }else{
- //show messages depending on what they didnt fill in and don't redirect to new action
- if ($username == '' || $username == 'please insert a username!'){
- $username = 'please insert a username!';
- }
- if ($details == '' || $details == 'please tell us about yourself!'){
- $details = 'please tell us about yourself!';
- }
- $this->view->userName = $username;
- $this->view->userPassword = $password;
- $this->view->userDetails = $details;
- }
- }
- public function confirmuserAction(){
- }
- //add user view
- <br /><br />
- <div id="view-content">
- <h1>Add a new user to the system form!</h1>
- <form action="adduser" method="post" enctype="application/x-www-form-urlencoded">
- <fieldset>
- <legend>Add new user</legend>
- <dl>
- <dt><label for="name">User name:</label></dt>
- <dd><input type="text" name="name" value="<?php echo $this->userName; ?>" /></dd>
- <dt><label for="password">User password:</label></dt>
- <dd><input type="password" name="password" value="<?php echo $this->userPassword; ?>" /></dd>
- <dt><label for="details">User details:</label></dt>
- <dd><textarea rows="20" cols="20" name="details"><?php echo $this->userDetails; ?></textarea></dd>
- <dt><label for="submit" style="display:none;">Add user:</label></dt>
- <dd><input type="submit" name="submit" value="Add user" /></dd>
- </dl>
- </fieldset>
- </form>
- </div>
- //confirm user view
- <br /><br />
- <div id="view-content">
- <h1>Confirm user</h1>
- <p>The details for the users are as follows:</p>
- <ul>
- <li>Name: <?php echo $this->userName; ?></li>
- <li>Password: <?php echo $this->userPassword; ?></li>
- <li>Details: <?php echo $this->userDetails; ?></li>
- </ul>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement