Salve a tutti, sono ormai giorni che scapoccio di brutto perchè non capisco cosa non vada nel mio form, nessun errore, nessun problema relativo a php, nulla di sospetto, ma quando premo il submit del form, il codice php non viene eseguito e si ricarica la pagina.
Ecco a voi il codice:
Grazie in anticipo a tutti coloro che proveranno ad aiutarmi
Ecco a voi il codice:
PHP:
<!DOCTYPE html>
<html lang="en" xmlns:http="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>MySound - Settings</title>
<!-- Bootstrap -->
<link href="../css/bootstrap.min.css" rel="stylesheet">
<link href="../css/style.css" rel="stylesheet">
<link rel="stylesheet" href="../font-awesome-4.3.0/css/font-awesome.min.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container-fluid">
<section class="container">
<div class="container-page">
<form role="form" method="POST">
<div class="col-md-6">
<h3 class="dark-grey">Registration</h3>
<?php
if(isset($error) && (strlen($error) > 0)){
echo "<span class='label label-danger'>".$error."</span>";
} else {
if(isset($welcome_msg)) {
echo "<span class='label label-success'>".$welcome_msg."</span>";
}
}
?>
<div class="form-group col-lg-12">
<label>Username</label>
<input type="text" name="username" class="form-control" id="" value="">
</div>
<div class="form-group col-lg-6">
<label>Password</label>
<input type="password" name="password" class="form-control" id="" value="">
</div>
<div class="form-group col-lg-6">
<label>Repeat Password</label>
<input type="password" name="repassword" class="form-control" id="" value="">
</div>
<div class="form-group col-lg-6">
<label>Email Address</label>
<input type="email" name="email" class="form-control" id="" value="">
</div>
<div class="form-group col-lg-6">
<label>Repeat Email Address</label>
<input type="email" name="email2" class="form-control" id="" value="">
</div>
</div>
<div class="col-md-6">
<h3 class="dark-grey">Terms and Conditions</h3>
<p>
By clicking on "Register" you agree to The Company's' Terms and Conditions
</p>
<p>
While rare, prices are subject to change based on exchange rate fluctuations -
should such a fluctuation happen, we may request an additional payment. You have the option to request a full refund or to pay the new price. (Paragraph 13.5.8)
</p>
<p>
Should there be an error in the description or pricing of a product, we will provide you with a full refund (Paragraph 13.5.6)
</p>
<p>
Acceptance of an order by us is dependent on our suppliers ability to provide the product. (Paragraph 13.5.6)
</p>
<button type="submit" name="submit" class="btn btn-primary">Register</button>
</div>
</form>
</div>
</section>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="../js/bootstrap.min.js"></script>
</body>
</html>
<?php
include("../cfg/var.php");
if(isset($_POST['submit']))
{
$email = $_POST['email'];
$email2 = $_POST['email2'];
$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['repassword'];
$date = date("H:i:s d/m/Y");
$error = "";
$sql = "INSERT INTO 'user_data' ('username','email','password','since_date') VALUES (:username,:email,:password,:date)";
if($email == $email2)
{
if(filter_var($email, FILTER_VALIDATE_EMAIL))
{
if(preg_match('/^[a-zA-Z0-9_]{3,16}$/i',$username))
{
if($password == $password2)
{
if(preg_match('/^[a-zA-Z0-9_-@]{6,32}$/i',$password))
{
$col = 'mysql:host=localhost;dbname='.$mysql_data['db'];
try {
$connection = new pdo($col,$mysql_data['username'],$mysql_data['psw']);
}
// blocco catch per la gestione delle eccezioni
catch(PDOException $e) {
// notifica in caso di errorre
echo 'Attenction: '.$e->getMessage();
}
$connection->beginTransaction();
$query = $connection->prepare($sql);
$res = $query->execute(array(
':username' => $username,
':email' => $email,
':password' => md5($password),
':date' => $date
));
$connection->commit();
if(!($res)) {
$error = "Can't execute the query.";
}
else {
$welcome_msg = "Welcome in MySound ".$username.", start now to explore the music!";
}
}
else {
$error = "The Password is not valid. [a-z,A-Z,0-9,_,@,-] min:6 max:32";
}
}
else {
$error = "Password and RePassword have to be the same.";
}
}
else {
$error = "Username not valid. [a-z,A-Z,0-9,_] min:3 max:16";
}
}
else {
$error = "Email is not a valid email.";
}
}
else {
$error = "The emails have to be the same.";
}
} //if isset submit
?>
Grazie in anticipo a tutti coloro che proveranno ad aiutarmi