probe el ajax q me pasaste y funciona bien... el tema esta en que no me agrega los campos correctamente en la base de datos... probe cambiando el button a submit y ahi si inserta datos... pero mediante ajax.... ingresa solo un dato en la bd... q viene por la variable session... te dejo mi php... y mi html para ver si alguien puede darme una mano
addCity.php
Código HTML:
<?php
class sites
{
public $city;
public $arrival;
public $departure;
public $comment;
public $numrows;
public $error;
public $error2;
public $ok;
public $fields;
public $regquery;
public function __construct($city,$arrival,$departure,$comment)
{
include "config.php";
$this->city=$city;
$this->arrival=$arrival;
$this->departure=$departure;
$this->comment=$comment;
$this->error="El campo ciudad no puede estar vacio";
$this->error2="Day of arrival can not be after a day of departure";
$this->error3="Day of departure can not be until the arrival day";
$this->query=mysql_query("SELECT * FROM sites WHERE city = '".$this->city."'");
$this->numrows=mysql_num_rows($this->query);
$this->ok=header('location:site.php');
}
public function check()
{
session_start();
if($this->city=="")
{
echo $this->error;
}
if($this->arrival>$this->departure)
{
echo $this->error2;
}
if($this->departure<$this->arrival)
{
echo $this->error3;
}
else
{
$register = mysql_query("INSERT INTO sites(city,arrival,departure,comment,nombreCirc) VALUES ('".$this->city."','".$this->arrival."','".$this->departure."','".$this->comment."','".$_SESSION['namecirc']."')");
echo $this->ok;
}
}
}
include_once "clear.php";
$reg = new sites(clear($_GET['city']),clear($_GET['arrival']), clear($_GET['departure']), clear($_GET['comment']));
echo $reg->check();
?>
y este es el php que contiene el form
Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Trip Minded - Add Site</title>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<link rel="stylesheet" href="colorbox.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://tripminded.com/app/circuits/colorbox/jquery.colorbox.js"></script>
<link type="text/css" href="js/jquery-ui-1.8.6.custom.css" rel="Stylesheet" />
<link type="text/css" href="autocompletado.css" rel="stylesheet" />
<link href="upload.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-ui-1.8.6.custom.min.js"></script>
<script type="text/javascript" src="js/colorbox.js"></script>
<script type="text/javascript" src="js/ciudades.js"></script>
<script type="text/javascript" src="js/funcionalidades.js"></script>
<script type="text/javascript" src="js/jquery.ui.js"></script>
</head>
<body>
<center>
<table width="800" border="1">
<tr>
<th width="267" scope="row"> </th>
<td width="225" align="center"><div style="font-weight: 700; font-size:20px; width: 596px">Add Sites for your Circuit</div></td>
<td class="style1"> </td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
<td class="style1"> </td>
</tr>
<tr>
<th scope="row">City:</th>
<td>
<input type='text' name='ciudad' id='ciudad' onfocus="javascript:this.value=''" class='ui-widget' />
<button onclick='agregarCiudad();' id='add' style='width: 144px'>Add City</button>
</td>
<td align="center" class="style1"><a class='inline' href="#inline_content" style="text-decoration:none; font-weight:bold; font-size:18px;"><input type="button" value="+" id="more" disabled="disabled" ></a>
<!-- This contains the hidden content for inline calls -->
<div style='display:none'>
<div id='inline_content' style='padding:10px; background:#fff;'>
<center>
<form action="addCity.php" id="add" name="addCity" method="get">
<table>
<tr>
<td>Selected City:</td>
<td><input type="text" id="city" name="city" readonly="readonly" style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-weight:bold; color:#F00; font-size:16px;" /></td>
</tr>
<tr>
<td>Arrival Date:
<br/>
<input type="text" id="datepicker_value" name="arrival" readonly="readonly"/>
</td>
<td><div id="datepicker"></div></td><td></td>
</tr>
<tr>
<td>Departure Date:
<br/>
<input type="text" id="otrodatepicker_value" name="departure" readonly="readonly" />
</td>
<td><div id="otrodatepicker"></div></td><td></td>
</tr>
<tr>
<tr>
<td>Comment:</td>
<td><input type="text" id="comment" name="comment" style="width:300px; height:200px;" /></td>
</tr>
<tr>
<td></td>
<td>
<br/>
</td>
</tr>
<tr>
<td></td>
<td align="center" class="style1"><input type="button" value="Save City" id="savecity" onclick="save()" disabled="disabled" /></td>
</tr>
</form>
</table>
</center>
</div>
</div>
</td>
</tr>
<tr>
<th scope="row"> </th>
<td><div id="map_canvas" style="width: 600px; height: 400px"></div> </td>
<td class="style1"> </td>
</tr>
<tr>
<th scope="row">Latitud:</th>
<td><span id="lat" name="lat" style="width:586px;padding-left:10px; font-size:12px; font-family:Verdana, Geneva, sans-serif;" /></span></td>
<td></td>
</tr>
<tr>
<th scope="row">Longitud:</th>
<td><span id="long" name="long" style="width:586px; padding-left:10px; font-size:12px; font-family:Verdana, Geneva, sans-serif;"/></span></td>
<td align="center" class="style1"> </td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
<td class="style1"> </td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
<td class="style1"> </td>
</tr>
</table>
</center>
</body>
</html>