Código PHP:
<?php
$serverName = "host\SQLEXPRESS"; //serverName\instanceName
$connectionInfo = array( "Database"=>"db", "UID"=>"sa", "PWD"=>"pass");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn )
{
if ((eregi("[^a-zA-Z0-9_-]", stripslashes($_POST['RUser']))) || (eregi("[^a-zA-Z0-9_-]", stripslashes($_POST['RPass']))) || (eregi("[^a-zA-Z0-9_-]", stripslashes($_POST['RCorreo']))))
{
echo("<style type='text/css'>
<!--
body {
background-color: #B0C0EC;
}
-->
</style>Error solo letras y numeros");
exit();
}
else
{
$RUser = stripslashes($_POST['RUser']);
$RPass = stripslashes($_POST['RPass']);
$RCorreo = stripslashes($_POST['RCorreo']);
$sql = "select memb___id from MEMB_INFO where memb___id = '$RUser'";
$params = array(1, "some data");
$stmt = sqlsrv_query( $conn, $sql);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ) {
if ($RUser == $row[0])
{
echo("<style type='text/css'>
<!--
body {
background-color: #B0C0EC;
}
-->
</style>El Usuario ya existe");
}
else
{
$sql = "insert into dbo.MEMB_INFO (memb___id,memb__pwd,memb_name,sno__numb,bloc_code,ctl1_code) Values ('$RUser','$RPass','RCorreo',1,0,1)";
$params = array(2, "some data");
$stmt = sqlsrv_query( $conn, $sql);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
}
}
sqlsrv_free_stmt( $stmt);
}
}
else{
echo "Lamentablemente se produjo un error por favor notifiquelo al administrador.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>