Signup with database

You must Login before you can answer or comment on any questions.

I make form registration for new member and i want to save it in database. How to make it success. This my code. And thanks :)

var win = Ti.UI.createWindow({
    backgroundColor : '#8C0221'
});
 
var title = Ti.UI.createPicker({
    selectionIndicator : true,
    top : 140,
    left : 20
});
 
// Add data to the Picker.
var data = [];
data[0] = Ti.UI.createPickerRow({title:'Mr', custom_item:'Man});
data[1] = Ti.UI.createPickerRow({title:'Ms, custom_item:'Woman'});
 
title.add(data);
 
// Add to the parent view.
win.add(title);
 
 
// Create a TextField.
var name = Ti.UI.createTextField({
    height : 40,
    top : 190,
    left : 20,
    width : 240,
    hintText : 'Full Name',
    softKeyboardOnFocus : Ti.UI.Android.SOFT_KEYBOARD_DEFAULT_ON_FOCUS, // Android only
    keyboardType : Ti.UI.KEYBOARD_DEFAULT,
    returnKeyType : Ti.UI.RETURNKEY_DEFAULT,
    borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
    suppressReturn : false
});
 
// Add to the parent view.
win.add(name);
 
 
// Create a TextField.
var telephone = Ti.UI.createTextField({
    height : 40,
    top : 240,
    left : 20,
    width : 240,
    hintText : 'No. Handphone',
    softKeyboardOnFocus : Ti.UI.Android.SOFT_KEYBOARD_DEFAULT_ON_FOCUS, // Android only
    keyboardType : Ti.UI.KEYBOARD_DEFAULT,
    returnKeyType : Ti.UI.RETURNKEY_DEFAULT,
    borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
    suppressReturn : false
});
 
// Add to the parent view.
win.add(telephone);
 
// Create a Label.
var date = Ti.UI.createLabel({
    text : 'Birth Date',
    color : '#ffffff',
    font : {fontSize:14},
    height : 20,
    width : 100,
    top : 340,
    left : 20,
    textAlign : 'center'
});
 
// Add to the parent view.
win.add(date);
 
 
var minDate = new Date();
minDate.setFullYear(1945);
minDate.setMonth(0);
minDate.setDate(1);
 
var maxDate = new Date();
maxDate.setFullYear(1995);
maxDate.setMonth(12);
maxDate.setDate(31);
 
var value = new Date();
value.setFullYear(1945);
value.setMonth(0);
value.setDate(1);
 
var picker = Ti.UI.createPicker({
    type : Ti.UI.PICKER_TYPE_DATE,
    minDate:minDate,
    maxDate:maxDate,
    value:value,
    top : 370,
    left : 20
});
 
picker.selectionIndicator = true;
 
win.add(picker);
 
 
-- This my database--
 
 
var db = Ti.Database.open('people');
var db = Ti.Database.install('mydata', 'people');
db.execute('INSERT INTO user (title TEXT, nama TEXT, handphone FLOAT, birth_date FLOAT)');
 
var thisTitle = 'Mr';
var thisName = 'Yosua Hendrik S';
var thisHandphone = '08561234556';
var thisBirth_date = '11011990';
 
db.execute('INSERT INTO user (title, name, handphone, birth_date) VALUES (?, ?, ?, ?)',  thisTitle, thisName, thisHandphone, thisBirth_Date);
 
var rows = db.execute('SELECT title,name,handphone,birth_date FROM user');
db.close();
 
while (rows.isValidRow())
{
  Ti.API.info('pelanggan  Title: ' + rows.fieldByName('title') + ', name: ' + rows.fieldByName('name') + ', handphone: ' + rows.fieldByName('handphone')+ ', birth date: ' + rows.fieldByName('birth_date'));
  rows.next();
}
rows.close();
 
// Create a Signup.
var signups = Ti.UI.createButton({
    title : 'Sign up',
    height : 40,
    width : 80,
    top : 301,
    left : 200
});
 
// Listen for click events.
signups.addEventListener('click', function() {
 
    if(succes){
    Ti.UI.createWindow({url:'main_menu/menu.js'}).open();
}
});
 
// Add to the parent view.
win.add(signups);

— asked 8 months ago by yosua hendrik
2 Comments
  • Not really clear what specifically you are looking for?

    — commented 8 months ago by Aaron Saunders

  • i have fill form, and how to store that data in database android and in web based PHP?

    — commented 8 months ago by yosua hendrik

1 Answer

while setting data you have missed ' after Man and Ms replace these lines in your code

data[0] = Ti.UI.createPickerRow({title:'Mr', custom_item:'Man'});

data[1] = Ti.UI.createPickerRow({title:'Ms', custom_item:'Woman'});

Your Answer

Think you can help? Login to answer this question!