hi, can anyone point out why is this script not working?? it does not inserting data into mysql..
here is the script:
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['form_name'] == 'signupform')
{
$newpassword = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
$code = 'NA';
$active = '1';
if ($newpassword != $confirmpassword)
{
$error_message = 'Password and Confirm Password are not the same!';
}
else
if (isset($_POST['captcha'],$_SESSION['random_txt']) && md5($_POST['captcha']) == $_SESSION['random_txt'])
{
unset($_POST['captcha'],$_SESSION['random_txt']);
}
else
{
$error_message = 'The entered code was wrong.';
}
if (empty($error_message))
{
try
{
$pdo = new PDO('mysql:host=localhost;dbname=blog', 'Avik', '');
}
catch (PDOException $e)
{
$output = 'Unable to connect to the database server.';
echo $output;
exit();
}
try
{
$sql = "SELECT username FROM ".$mysql_table." WHERE username = :username";
$statement = $pdo->prepare($sql);
$statement->bindValue(':username', $_POST['username']);
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
if (count($result) > 0)
{
$error_message = 'Username already used. Please select another username.';
}
}
catch (PDOException $e)
{
$output = 'Unable to send query';
echo $output;
exit();
}
}
if (empty($error_message))
{
$crypt_pass = md5($newpassword);
try
{
$sql = "INSERT INTO ".$mysql_table." username = :username, password = :password, fullname = :fullname, email = :email, role = :role, active = :active, code = :code";
$statement = $pdo->prepare($sql);
$statement->bindValue(':username', $_POST['username']);
$statement->bindValue(':password', md5($_POST['password']));
$statement->bindValue(':fullname', $_POST['fullname']);
$statement->bindValue(':email', $_POST['email']);
$statement->bindValue(':role', $_POST['role']);
$statement->bindValue(':active', $active);
$statement->bindValue(':code', $code);
$statement->execute();
}
catch (PDOException $e)
{
$output = 'Unable to connect to the database server.';
echo $output;
exit();
}
header('Location: '.$success_page);
exit;
}
}