Jump to content

Recommended Posts

I have a script that i want to change a mysql database if a variable contains information, and then to go on to display the information but if the variable does not conatin any informatiion i want it to skip the changing process and just display the information from the db

here is my code but i am not sure how to finish this off can come one help me out;

  <?php
  // Check if there is a cookie, if there isn't then exit!
  if (!isset($_COOKIE['cookie_info'])) {
      echo "You are not logged in.";
  exit;
       }
elseif (!isset($_COOKIE['cookie_info1'])) {
echo "You are not an admin.";
exit;
}
else{
include 'connect.php';
$change = "";
$change = $_GET["Authorised"];
if(preg_match('/[A-Za-z0-9]/', $change)==TRUE){


$letter = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
$numbers = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", " ");
#
$user = str_replace($numbers, "", $change);
$auth = str_replace($letter, "", $change);
echo "$user <BR> " .
 "$auth <BR> ";
mysql_query("UPDATE members SET Authorised = '$auth' WHERE Gamertag= '$user'") or die(mysql_error());
}else{
$activate = "";
$query  = "SELECT Gamertag, Authorised FROM members";
$result = mysql_query($query);
$count = 1;
while($row = mysql_fetch_assoc($result))
{
if($row['Authorised'] == 0){
$activate = "<a href='updateusers.php?Authorised=1$row[Gamertag]'>Deactivated
</a>";
}
else{
$activate = "<a href='updateusers.php?Authorised=0$row[Gamertag]'>Activated
</a>";
}
echo "Name :{$row['Gamertag']} <br>" .
         "Account status : $activate <br>";

$count++;         
}
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/72198-how-would-i/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.