File tree 2 files changed +39
-0
lines changed
2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -11,4 +11,16 @@ exports.index = function(req, res) {
11
11
} ;
12
12
13
13
exports . add_hike = function ( req , res ) {
14
+ var input = req . body . hike ;
15
+ var hike = { HIKE_DATE : new Date ( ) , ID : uuid . v4 ( ) , NAME : input . NAME ,
16
+ LOCATION : input . LOCATION , DISTANCE : input . DISTANCE , WEATHER : input . WEATHER } ;
17
+
18
+ console . log ( 'Request to log hike:' + JSON . stringify ( hike ) ) ;
19
+ req . app . get ( 'connection' ) . query ( 'INSERT INTO HIKES set ?' , hike , function ( err ) {
20
+ if ( err ) {
21
+ res . send ( err ) ;
22
+ } else {
23
+ res . redirect ( '/hikes' ) ;
24
+ }
25
+ } ) ;
14
26
} ;
Original file line number Diff line number Diff line change @@ -4,6 +4,33 @@ block content
4
4
h1= title
5
5
p Welcome to #{title}
6
6
7
+ form( action ="/add_hike" , method ="post" )
8
+ table( border ="1" )
9
+ tr
10
+ td Your Name
11
+ td
12
+ input( name ="hike[NAME]" , type ="textbox" )
13
+ tr
14
+ td Location
15
+ td
16
+ input( name ="hike[LOCATION]" , type ="textbox" )
17
+ tr
18
+ td Distance
19
+ td
20
+ input( name ="hike[DISTANCE]" , type ="textbox" )
21
+ tr
22
+ td Weather
23
+ td
24
+ input( name ="hike[WEATHER]" , type ="radio" , value ="Good" )
25
+ | Good
26
+ input( name ="hike[WEATHER]" , type ="radio" , value ="Bad" )
27
+ | Bad
28
+ input( name ="hike[WEATHER]" , type ="radio" , value ="Seattle" , checked )
29
+ | Seattle
30
+ tr
31
+ td( colspan ="2" )
32
+ input( type ="submit" , value ="Record Hike" )
33
+
7
34
div
8
35
h3 Hikes
9
36
table( border ="1" )
You can’t perform that action at this time.
0 commit comments