Tuesday, April 23, 2013

php check if record already exists




<?php

mysql_connect('localhost', 'admin', 'abc456');
mysql_select_db('web');
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
?>
<?php

$suid = $_SESSION['userid'];
$check = mysql_query("SELECT id FROM arts WHERE id = '$suid'");
$chid = mysql_fetch_array( $check );

if ($chid == true)
   {
  header('Location: userprofile.php');
   }
  else {
 header('Location: edit-profile.php');
       }
?>

0 Comments:

Post a Comment