Jump to content

Help correcting this.


iamnottheend

Recommended Posts

I am pretty sure it works. I just think i have my if statements wrong. I am not very good with forms and this is the first time i have used radio buttons and well something is going wrong.

 

Form

 

<form action="{$currentpage}" method="post">
<input type="radio" name="availible" value="Availible"> Availible <br />			
<input type="radio" name="availible" value="NotAvailible"> Not Avilible
<input type="submit" name="AvailibleSubmit" value="submit" />
</form>

 

php

if ($_POST['AvailibleSubmit']) {
if ($_POST['availible'] = "Availible") {
	$sql="UPDATE `designer_status` SET `amavailible` = '1' WHERE `designer_status`.`amavailible` =1 LIMIT 1";
	$result = mysql_query($sql);
	if ($result) {
		echo "database changes have been made. Press <a href=\"admin.php\">back</a> to continue.";
	} else {
		echo "database changes failed, please try again";
	}
}
if ($_POST['availible'] = "NotAvailible") {
	$sql="UPDATE `designer_status` SET `amavailible` = '0' WHERE `designer_status`.`amavailible` =1 LIMIT 1";
	$result = mysql_query($sql);
	if ($result) {
		echo "database changes have been made. Press <a href=\"admin.php\">back</a> to continue.";
	} else {
		echo "database changes failed, please try again";
	}
}
}

 

Output

database changes have been made. Press back to continue.database changes have been made. Press back to continue.

 

What i believe is happening is that both if statements are running, this means that they are wrong. Could someone correct them for me so i can see where i am going wrong.

 

Thanks

Link to comment
Share on other sites

if (isset($_POST['AvailibleSubmit'])) {
if (isset($_POST['availible'])) {
	$sql="UPDATE `designer_status` SET `amavailible` = '1' WHERE `designer_status`.`amavailible` =1 LIMIT 1";
	$result = mysql_query($sql);
	if ($result) {
		echo "database changes have been made. Press <a href=\"admin.php\">back</a> to continue.";
	} else {
		echo "database changes failed, please try again";
	}
} else {
	$sql="UPDATE `designer_status` SET `amavailible` = '0' WHERE `designer_status`.`amavailible` =1 LIMIT 1";
	$result = mysql_query($sql);
	if ($result) {
		echo "database changes have been made. Press <a href=\"admin.php\">back</a> to continue.";
	} else {
		echo "database changes failed, please try again";
	}
}
}

 

Changed a few lines just to make it check if the variable isset or not, this is causing it to do one or the other, noth both. Is this what you were looking for?

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.