y quiero guardar esos datos con php en mi base de datos abastos tabla categoria agradesco su ayuda
pues no se como hacer para guardar eso.
conexion.php
Código PHP:
<?php
class conexion{
var $conect;
function conexion(){
}
function getCon(){
return $this->conect;
}
function conectar() {
if(!($con=@mysql_connect("localhost","root","123")))
{
echo"Error al conectar a la base de datos";
exit();
}
if (!@mysql_select_db("abastos",$con)) {
echo "error al seleccionar la base de datos";
exit();
}
$this->conect=$con;
return true;
}
}
?>
submitform.php
Código PHP:
<?php
include_once("conexion/conexion.php");
header("Content-Type: text/plain");
// Support for the PUT method
$_PUT = array();
if($_SERVER['REQUEST_METHOD'] == 'PUT') {
parse_str(file_get_contents('php://input'), $_PUT);
}
$nombre_categoria = $_PUT['nombre_categoria'];
$idcategoria = $_PUT['idcategoria'];
//save your data here
//in your data base
//or whatever you want ;)
if(rand(0,1)===0){
//header('HTTP/1.1 201 Created success');
$info = array(
'success' => true,
'msg' => 'The record "'.$nombre_categoria.'" has been saved succesfully'
);
}else{
//header('HTTP/1.1 501 Error saving the record');
$info = array(
'success' => false,
'msg' => 'There was an error saving the record'
);
}
echo json_encode($info);
?>
Código PHP:
Ext.ns('com.quizzpot.tutorial');
Ext.BLANK_IMAGE_URL = 'ext-3.2.1/resources/images/default/s.gif';
com.quizzpot.tutorial.SubmitFormTutorial = {
init: function(){
this.form = new Ext.form.FormPanel({
//standardSubmit: true, // traditional submit
url: 'submitform.php',
border:false,
labelWidth: 80,
defaults: {
xtype:'textfield',
width: 150
},
items:[
{fieldLabel:'Nombre Categoria',name:'nombre_categoria', allowBlank:false},
{xtype:'numberfield',fieldLabel:'codigo categoria',name:'idcategoria'},
]
});
this.win = new Ext.Window({
id:'mywin',
title: 'Nueva Categoria',
bodyStyle: 'padding:10px;background-color:#fff;',
width:300,
height:270,
items:[this.form],
buttons: [{text:'Save',handler:this.sendData,scope:this},{text:'Cancel'}]
});
this.win.show();
},
sendData: function(){
//submit the form
var mask = new Ext.LoadMask(Ext.get('mywin'), {msg:'Saving. Please wait...'});
mask.show();
this.form.getForm().submit({
method: 'put',
params: {
extraParam: 'Extra params!',
param2: 'Param 2'
},
success: function(form,action){
mask.hide();
Ext.Msg.alert('Success',action.result.msg);
},
failure: function(form,action){
mask.hide();
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax communication failed');
break;
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
break;
default:
Ext.Msg.alert('Failure',action.result.msg);
}
}
});
}
}
Ext.onReady(com.quizzpot.tutorial.SubmitFormTutorial.init,com.quizzpot.tutorial.SubmitFormTutorial);