MSSQL exécuter une procédure stocker sur un serveur distant
Posté : 13 mars 2011, 17:58
Bonjour a tous,
Je cherche a créer une page d'inscription pour un jeux en ligne.
Je dispose d'un serveur distant avec la base de données Microsoft SQL Serveur 2005.
Voici les infos du site devant héberger la page d'inscription
http://s361377848.onlinehome.fr/info.php
Je ne peux pas utiliser MSSQL Connect vu qu'il a été supprimer a partir de PHP5 et c'est précisement cette version de php qui est utiliser.
Un exemple de page d'inscription qui fonctionner avant que mssql soit supprimer.
Je cherche a créer une page d'inscription pour un jeux en ligne.
Je dispose d'un serveur distant avec la base de données Microsoft SQL Serveur 2005.
Voici les infos du site devant héberger la page d'inscription
http://s361377848.onlinehome.fr/info.php
Je ne peux pas utiliser MSSQL Connect vu qu'il a été supprimer a partir de PHP5 et c'est précisement cette version de php qui est utiliser.
Un exemple de page d'inscription qui fonctionner avant que mssql soit supprimer.
<?php
/* Copyright 2011 Aaron Roderigues */
require_once "captcha/securimage.php";
$securimage = new Securimage();
function doesUsernameExist($name){
$exit = FALSE;
$result = @mssql_query("SELECT * FROM dbo.ACCOUNT_TBL WHERE account='$name'");
if(mssql_num_rows($result) != 0){
$exit = TRUE;
}
return $exit;
}
function cl($info){
return strtolower(preg_replace("|[^\w]|", "", $info));
}
function check_email($email){
$exit = FALSE;
if(filter_var($email, FILTER_VALIDATE_EMAIL)){
list($alias, $domain) = split("@", $email);
if (checkdnsrr($domain, "MX")){
getmxrr($domain, $mxhosts);
if(in_array("0.0.0.0", $mxhosts)){
return $exit;
}
return $exit = TRUE;
}
else {
return $exit;
}
}
else {
return $exit;
}
}
if(isset($_POST['submit'])){
/* Start editing */
$salt = "serus";
$link = @mssql_connect("HOSTIP", "USER", "PASSWORD") or die ("Server is down!");
$db = @mssql_select_db('ACCOUNT_DBF') or die ("Accout table is missing!");
/* */
$username = cl($_POST['username']);
$password = cl($_POST['password']);
$password_hashed = md5($salt.$password);
$birthdate = $_POST['month']."/".$_POST['day']."/".$_POST['year'];
if(empty($username) || strlen($username) > 15){
echo "Problem with your username. Go back and try again.";
exit();
}
else if(empty($password) || strlen($password) > 36){
echo "Problem with your password. Go back and try again.";
exit();
}
else if(empty($_POST['email']) || !check_email($_POST['email'])){
echo "Problem with your email. Go back and try again.";
exit();
}
else if(empty($_POST['month']) || empty($_POST['day']) || empty($_POST['year']) || strlen($_POST['month']) > 2 || strlen($_POST['day']) > 2 || strlen($_POST['year']) != 4 || !is_numeric($_POST['month']) || !is_numeric($_POST['day']) || !is_numeric($_POST['year'])){
echo "Problem with your birthdate. Go back and try again.";
exit();
}
else if(doesUsernameExist($username)){
echo "Username already exists. Go back and try again.";
exit();
}
else if($securimage->check($_POST['captcha_code']) == false){
echo "The code you entered was incorrect. Go back and try again.";
exit();
}
/* Passed everything, so lets create the account. */
$stmt = mssql_init('dbo.webCreateAcc', $link);
mssql_bind($stmt, '@account', $username, SQLVARCHAR, false, false, 15);
mssql_bind($stmt, '@password', $password_hashed, SQLVARCHAR, false, false, 36);
mssql_bind($stmt, '@birthday', $birthdate, SQLVARCHAR, false, false, 120);
mssql_bind($stmt, '@email', $_POST['email'], SQLVARCHAR, false, false, 120);
mssql_execute($stmt) or die ("Something is wrong on the execution.");
mssql_free_statement($stmt);
echo "User account created for: ".$username;
mssql_close($link);
exit();
}
?>
<!DOCTYPE html>
<html>
<body>
<div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table>
<tr>
<td>Username:</td>
<td><input size="20" name="username" maxlength="15" type="text" /></td>
<td>(A-Z, a-z, 0-9)</td>
</tr>
<tr>
<td>Password:</td>
<td><input size="20" name="password" maxlength="35" type="password" /></td>
<td>(A-Z, a-z, 0-9)</td>
</tr>
<tr>
<td>Email:</td>
<td><input size="20" name="email" maxlength="255" type="text" /></td>
</tr>
<tr>
<td>Birthday:</td>
<td>
<input size="1" name="month" maxlength="2" type="text" placeholder="MM" />
<input size="1" name="day" maxlength="2" type="text" placeholder="DD" />
<input size="3" name="year" maxlength="4" type="text" placeholder="YYYY" />
</td>
</tr>
<tr>
<td>Security Code:</td>
<td><input type="text" name="captcha_code" size="10" maxlength="4" /></td>
</tr>
<tr>
<td colspan="3" align="center"><img id="captcha" src="captcha/securimage_show.php" alt="CAPTCHA Image" /></td>
</tr>
</table>
<input type="submit" name="submit" value="register" />
</form>
</div>
</body>
</html>
Je ne connais vraiment pas les fonction qui ont remplacer mssql et comment les utiliser. Quelqu'un pourais m'aider a adapter ce script ? Merci d'avance