Php+Mysql

Fermé
ray_loubayi Messages postés 8 Date d'inscription mercredi 4 août 2010 Statut Membre Dernière intervention 26 mars 2012 - 7 nov. 2010 à 15:58
Bonjour,

jai un problem, j'ai cree un code qui est supposer envoye des information du site internet a la base de donne mais le code ne marche pas apres que l'utilisateur est submit tout ces differents infos c'est just une page blanche qui saffiche aucune eureur ou quoi que se soit.
voici le code

<?php

//declaring variable

$fname= $_POST['fn'];
$mn= $_POST['mn'];
$ln= $_POST['ln'];
$al1= $_POST['al1'];
$al2= $_POST['al2'];
$city= $_POST['city'];
$state= $_POST['state'];
$zcode= $_POST['zc'];
$country= $_POST['country'];
$Email= $_POST['email'];
$date= $_POST['month'];
$cname= $_POST['cname'];
$nc= $_POST['nc'];
$hsname= $_POST['hsname'];
$Gdate= $_POST['Gdate'];
$file1= $_POST['File'];

//Establishing connection to the database

$DBhost = "localhost";
$DBuser = "root";
$DBpass = "celine";
$DBName = "university";
$table = "Graduate";

$host = "localhost";
$user = "root";
$password = "celine";
$db = "university";
$dsn = "mysql:host=localhost; dbname=university";

$dbh = new PDO($dsn, $user, $password);


//inserting data into graduate table

//everything is ok now send details into, detabase

$fname = ucfirst(strtolower(strip_tags(trim($_POST['fn']))));
$ln = ucfirst(strtolower(strip_tags(trim($_POST['ln']))));
$mn= $_POST['mn'];
$al1= $_POST['al1'];
$al2= $_POST['al2'];
$city= $_POST['city'];
$state= $_POST['state'];
$zc= $_POST['zc'];
$country= $_POST['country'];
$email= $_POST['email'];
$date= $_POST['month'] .' '. $_POST['day'].' '. $_POST['year'];
$nc= $_POST['nc'];
$hsname= $_POST['hsname'];
$Gdate= $_POST['Month'].''.$_POST['year'];


//define file value
$fileName = $_FILES['File1']['name'];
$tmpName = $_FILES['File1']['tmp_name'];


if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}

$Maindir = "../G-attachment".DIRECTORY_SEPARATOR;
move_uploaded_file($_FILES['File1']['tmp_name'], $Maindir.$_FILES["File1"]["name"]);
$filePath = substr("$Maindir/$fileName", 3);
$fileName = $_FILES["File1"]['name'];
//var_dump($filePath);

//check registration

$sql = "SELECT Email FROM graduate WHERE fname = '$fname'";
$stmt = $dbh -> prepare($sql);

//execute
$result = $stmt -> execute();

//get the number of row

$num_row = $stmt -> rowCount();

if($num_row>0)
{
//user has already registered
header("location: ../pages/Graduate.php?login=failed&cause=".urlencode('Duplicate user!'));
}
else
{


//user is new
//register this new user
$sql = "INSERT INTO Graduate (
fname,
ln,
mn,
al1,
al2,
city,
state,
zcode,
country,
Email,
date,
cname,
nc,
hsname,
Gdate,
file1,
)
VALUE('$fname',
'$ln',
'$mn',
'$al1',
'$al2',
'$city',
'$state',
'$zc',
'$country',
'$email',
'$date',
'$cname',
'$nc',
'$hsname',
'Gdate',
'$filePath')";


$stmt = $dbh->prepare($sql);

try
{
//execute sql
$result=$stmt->execute();

if($result)
{
echo "Congrats!!! ";
print $_POST['fn'];
echo " Your Informations have been sumbit";
}
}

catch(PDOException $e)
{
echo 'error caught '. $e->getMessage() .'<br>';
echo 'at line '. $e->getLine();
}
}






?>


merci pour votre aide









<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>

<body>

</body>

</html>