Jump to content

Proper way of using OR with two if commands


Shadowing

Recommended Posts

Im having trouble with this wondering if someone could help me out please

 

if (isset($_POST['escape'])) { || if (isset($_POST['suicide'])) {

 

its giving me a error on the ||

 

im writing it so that one or the other has to happend. is this the correct way to use this?

Link to comment
Share on other sites

maybe its suppose to be more closer to something like this if

 

(isset($_POST['escape']) || (isset($_POST['suicide'])) {

 

 

 

Edit: nevermind i got it to work forgot to add the other )

 

so its

 

(isset($_POST['escape']) || (isset($_POST['suicide']))) {

 

Link to comment
Share on other sites

I'm trying to let people delete their account but its not working

 

 

 

if (isset($_POST['escape']) || (isset($_POST['suicide']))) {

}else{

	if(empty($_POST['agree'])){
			echo "You need to check the box";

}else{

	mysql_query("DELETE FROM users WHERE id='".mysql_real_escape_string($_SESSION['user_id']))."'";

}

}

Link to comment
Share on other sites

Why empty firs body of 'if' ???

 

if (isset($_POST['escape']) || (isset($_POST['suicide']))) {
        // Why here is nothing wrote ???
} else {
    if(empty($_POST['agree'])){
            echo "You need to check the box";
    }else{
        mysql_query("DELETE FROM `users` WHERE `id`= ".(int)($_SESSION['user_id']);
    }
}

Link to comment
Share on other sites

Forgot to say thanks for reading my post and helping me guys

 

 

I get a error with using your code on

mysql_query("DELETE FROM `users` WHERE `id`= ".(int)($_SESSION['user_id']);

 

 

im trying to get it to read saying

 

if one of the two buttons are clicked

 

and agree isnt empty

 

then account will get deleted where the id matches the id session.

 

 

thats a good point you made haha i need to change it to

 

if(!empty($_POST['agree'])){

Link to comment
Share on other sites

oh i guess it needs to read more like this. I took out the or for testing reasons

this still doesnt work though hmm

 

if (isset($_POST['escape'])) {


	if(empty($_POST['agree'])){
			echo "You need to check the box";

} else {

	mysql_query("DELETE FROM users WHERE id='".mysql_real_escape_string($_SESSION['user_id']))."'";


}

}

Link to comment
Share on other sites

k i changed it to isset. just curious why you say it is beter cause ive been using empty alot maybe i should stop

 

still getting a error on

mysql_query("DELETE FROM `users` WHERE `id`= ".(int)($_SESSION['user_id']);

 

Parse error: syntax error, unexpected ';' in C:\Software\XAMPP\xampp\htdocs\stargate\delete_account.php on line 70

 

 

if (isset($_POST['escape'])) {


	if(!isset($_POST['agree'])){
			echo "You need to check the box";

} else {

	mysql_query("DELETE FROM `users` WHERE `id`= ".(int)($_SESSION['user_id']);

}

}

Link to comment
Share on other sites

I am not usually a fan of deleting data from a table, and I don't recommend doing it (but it also depends on what the table is for). You should have a toggle field, set it to "1" for an active user, or "0" for an inactive/deleted user.

 

<?php
if (isset($_POST['escape']) || (isset($_POST['suicide']))) {
        // Why here is nothing wrote ???
}elseif(empty($_POST['agree'])){
echo "You need to check the box";
}else{
mysql_query("update users set is_active = 0 where id = ".(int)$_SESSION['user_id']);
}
?>

Link to comment
Share on other sites

Thanks guys so much!

It all works now

 

Yah im creating a way for them to reset their account too. that toggle switch idea is a good idea. I was just going to use a another data base property for that but i may do that now instead

 

only on my 2nd week learning php lol. its pretty awesome

Link to comment
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.