MySQL table only submitting first time from EXT js + PHP entry -
i having problem mysql.
i have setup , well, when submit form work if table empty. not submit entry if there information stored in table.
here mysql table
create table student (studentid int not null, studentfirst varchar(30), studentlast varchar(30), studentemail varchar(254), studentphone varchar(12), studentdob date, datestarted date, lessonid int, studentaddress varchar(50), studentcity varchar(30), studentstate char(2), studentzip varchar(10), musicinterest text); alter table student add constraint studentpk primary key auto_increment (studentid); alter table student add constraint lessonfk foreign key (lessonid) references lesson(lessonid);
this php
if(isset($_request['action'])){ switch($_request['action']){ case 'submit_student': $first = $_request['studentfirst']; $last = $_request['studentlast']; $email = $_request['studentemail']; $phone = $_request['studentphone']; $dob = $_request['studentdob']; $datestarted = $_request['datestarted']; $lessonid = $_request['lessonid']; $address = $_request['studentaddress']; $city = $_request['studentcity']; $state = $_request['studentstate']; $zip = $_request['studentzip']; $musicinterest = $_request['musicinterest']; $stmt = $dbh->prepare("insert student (studentfirst, studentlast, studentemail, studentphone, studentdob, datestarted, lessonid, studentaddress, studentcity, studentstate, studentzip,musicinterest) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"); $stmt -> bindparam(1,$first); $stmt -> bindparam(2,$last); $stmt -> bindparam(3,$email); $stmt -> bindparam(4,$phone); $stmt -> bindparam(5,$dob); $stmt -> bindparam(6,$datestarted); $stmt -> bindparam(7,$lessonid); $stmt -> bindparam(8,$address); $stmt -> bindparam(9,$city); $stmt -> bindparam(10,$state); $stmt -> bindparam(11,$zip); $stmt -> bindparam(12,$musicinterest); $stmt -> execute(); break;
and extjs
function addstudent(){ ext.ajax.request ({ url: 'inc/template.php', params: {action: 'submit_student', studentfirst:firstnametextfield.getvalue(), studentlast:lastnametextfield.getvalue(), studentemail: emailtextfield.getvalue(), studentphone:phonenumbertextfield.getvalue(), studentdob:ext.util.format.date(dateofbirth.getvalue(), 'y-m-d'), datestarted:datestarted.getvalue(), lessonid:daytypecombo.getvalue(), studentaddress:streettextfield.getvalue(), studentcity:citytextfield.getvalue(), studentstate:statetextfield.getvalue(), studentzip:ziptextfield.getvalue(), musicinterest:musicinterest.getvalue() }, method: 'post', }); tabpanel.activate(studentgrid); tabpanel.activate(schedulegrid); clearstudentform();
i have no idea why submits 1 time. baffling. shows post in firebug.
any appreciated.
i not sure auto-increment
statement at
alter table student add constraint studentpk primary key auto_increment (studentid);
also think, should use syntax multiple columns. 1 column use
create table student (studentid int not null primary key, studentfirst varchar(30), ...