ho questi file e non capisco perchè non mi inserisce i dati nel database....bho
tutorial.html
Codice PHP:
<!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>Demo Contact Form - Submit Without Page Refresh using jQuery</title>
<script src="js/jquery-1.2.3.pack.js"></script>
<script src="js/runonload.js"></script>
<script src="js/tutorial.js"></script>
<link href="css/tutorial.css" media="all" type="text/css" rel="stylesheet">
</head>
<body>
<div id="contact_form">
<form name="contact" method="post" action="">
<fieldset>
1<input type="radio" name="bellezza" value="1"/>
2<input type="radio" name="bellezza" value="2"/>
3<input type="radio" name="bellezza" value="3"/>
4<input type="radio" name="bellezza" value="4"/>
5<input type="radio" name="bellezza" value="5"/>
6<input type="radio" name="bellezza" value="6"/>
7<input type="radio" name="bellezza" value="7"/>
8<input type="radio" name="bellezza" value="8"/>
9<input type="radio" name="bellezza" value="9"/>
10<input type="radio" name="bellezza" value="10"/>
<input type="submit" name="submit" class="button" id="submit_btn" value="Send" />
</fieldset>
</form>
</div>
</body>
</html>
runonload.js
codice:
/*
* runOnLoad.js: portable registration for onload event handlers.
*
* This module defines a single runOnLoad() function for portably registering
* functions that can be safely invoked only when the document is fully loaded
* and the DOM is available.
*
* Functions registered with runOnLoad() will not be passed any arguments when
* invoked. They will not be invoked as a method of any meaningful object, and
* the this keyword should not be used. Functions registered with runOnLoad()
* will be invoked in the order in which they were registered. There is no
* way to deregister a function once it has been passed to runOnLoad().
*
* In old browsers that do not support addEventListener() or attachEvent(),
* this function relies on the DOM Level 0 window.onload property and will not
* work correctly when used in documents that set the onload attribute
* of their <body> or <frameset> tags.
*/
function runOnLoad(f) {
if (runOnLoad.loaded) f(); // If already loaded, just invoke f() now.
else runOnLoad.funcs.push(f); // Otherwise, store it for later
}
runOnLoad.funcs = []; // The array of functions to call when the document loads
runOnLoad.loaded = false; // The functions have not been run yet.
// Run all registered functions in the order in which they were registered.
// It is safe to call runOnLoad.run() more than once: invocations after the
// first do nothing. It is safe for an initialization function to call
// runOnLoad() to register another function.
runOnLoad.run = function() {
if (runOnLoad.loaded) return; // If we've already run, do nothing
for(var i = 0; i < runOnLoad.funcs.length; i++) {
try { runOnLoad.funcs[i](); }
catch(e) { /* An exception in one function shouldn't stop the rest */ }
}
runOnLoad.loaded = true; // Remember that we've already run once.
delete runOnLoad.funcs; // But don't remember the functions themselves.
delete runOnLoad.run; // And forget about this function too!
};
// Register runOnLoad.run() as the onload event handler for the window
if (window.addEventListener)
window.addEventListener("load", runOnLoad.run, false);
else if (window.attachEvent) window.attachEvent("onload", runOnLoad.run);
else window.onload = runOnLoad.run;
tutorial.js
codice:
$(function() {
$('.error').hide();
$('radio.text-input').css({backgroundColor:"#FFFFFF"});
$('radio.text-input').focus(function(){
$(this).css({backgroundColor:"#FFDDAA"});
});
$('radio.text-input').blur(function(){
$(this).css({backgroundColor:"#FFFFFF"});
});
$(".button").click(function() {
// validate and process form
// first hide any error messages
$('.error').hide();
var name = $("radio#name").val();
if (name == "") {
$("label#name_error").show();
$("radio#name").focus();
return false;
}
var email = $("radio#email").val();
if (email == "") {
$("label#email_error").show();
$("radio#email").focus();
return false;
}
var phone = $("radio#phone").val();
if (phone == "") {
$("label#phone_error").show();
$("radio#phone").focus();
return false;
}
var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "bin/process.php",
data: dataString,
success: function() {
$('#contact_form').html("<div id='message'></div>");
$('#message').html("<h2>Contact Form Submitted!</h2>")
.append("
We will be in touch soon.</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("[img]images/check.png[/img]");
});
}
});
return false;
});
});
runOnLoad(function(){
$("radio#name").select().focus();
});
process.php
Codice PHP:
<?php require_once('../../../Connections/connessione.php'); ?>
<?php
ob_start();
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$insertSQL = sprintf("INSERT INTO prova (bellezza) VALUES ( %s)",
GetSQLValueString($_POST['bellezza'], "text"));
mysql_select_db($database_connessione, $connessione);
$Result1 = mysql_query($insertSQL, $connessione) or die(mysql_error());
?>
dovè il problema?