Skip to content

Commit 0998b3b

Browse files
author
Phalcon
committed
Adding tutorial
0 parents  commit 0998b3b

7 files changed

Lines changed: 104 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
class IndexController extends Phalcon_Controller {
4+
5+
function indexAction(){
6+
7+
}
8+
9+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
class SignupController extends Phalcon_Controller {
4+
5+
function indexAction(){
6+
7+
}
8+
9+
function registerAction(){
10+
11+
//Request variables from html form
12+
$name = $this->request->getPost('name', 'string');
13+
$email = $this->request->getPost('email', 'email');
14+
15+
$user = new Users();
16+
$user->name = $name;
17+
$user->email = $email;
18+
19+
//Store and check for errors
20+
if ($user->save() == true) {
21+
echo 'Thanks for register!';
22+
} else {
23+
echo 'Sorry, the next problems was generated: ';
24+
foreach ($user->getMessages() as $message){
25+
echo $message->getMessage(), '<br/>';
26+
}
27+
}
28+
}
29+
30+
}

app/models/Users.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
class Users extends Phalcon_Model_Base {
4+
5+
}

app/views/index/index.phtml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
echo "<h1>Hello!</h1>";
4+
5+
echo Phalcon_Tag::linkTo("signup", "Sign Up Here!");
6+

app/views/signup/index.phtml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<h2>Sign using this form</h2>
2+
3+
<?php echo Phalcon_Tag::form('signup/register') ?>
4+
5+
<p>
6+
<label for="name">Name</label>
7+
<?php echo Phalcon_Tag::textField("name") ?>
8+
</p>
9+
10+
<p>
11+
<label for="name">E-Mail</label>
12+
<?php echo Phalcon_Tag::textField("email") ?>
13+
</p>
14+
15+
<p>
16+
<?php echo Phalcon_Tag::submitButton("Register") ?>
17+
</p>
18+
19+
</form>

public/.htaccess

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
AddDefaultCharset UTF-8
2+
<IfModule mod_rewrite.c>
3+
RewriteEngine On
4+
RewriteCond %{REQUEST_FILENAME} !-d
5+
RewriteCond %{REQUEST_FILENAME} !-f
6+
RewriteRule ^(.*)$ index.php?_url=$1 [QSA,L]
7+
</IfModule>

public/index.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
try {
4+
5+
$config = new Phalcon_Config(array(
6+
'database' => array(
7+
'adapter' => 'Mysql',
8+
'host' => 'localhost',
9+
'username' => 'test',
10+
'password' => 'test',
11+
'name' => 'test_db'
12+
),
13+
'phalcon' => array(
14+
'controllersDir' => '../app/controllers/',
15+
'modelsDir' => '../app/models/',
16+
'viewsDir' => '../app/views/'
17+
)
18+
));
19+
20+
$front = Phalcon_Controller_Front::getInstance();
21+
$front->setConfig($config);
22+
echo $front->dispatchLoop()->getContent();
23+
24+
}
25+
catch(Phalcon_Exception $e){
26+
echo 'PhalconException: '.$e->getMessage(), PHP_EOL;
27+
}
28+

0 commit comments

Comments
 (0)