Jump to content

Unset isnt working like I want it to


jdock1

Recommended Posts

I am using an if statement. If the user has a credit value of 1 or more it echos a variable thats a form. When the user submits the form, it takes a credit away, so the credit value is -1. I need the form to dissapear, because the form has a button that will execute a query that I dont want to execute.

 

So, usually unset() fixes this, but its not in my case.

 

Heres the code

$a='<strong></strong>';
					if ($hintcredit<1)
						$a.='<font style="color: #cc0000;">You have already requested a hint! Once you guess the correct number, you will be able to get another hint. </font>';
					else
$form= "<form action='blablabla' method='post'>blablablabla</form>";
						$a.=$form;
					$a.='<strong></strong>';
                        echo $a;
					if ($_POST['request'] == "Retrieve Hint")
					{
						unset($form);
						$form= '<b>One of the digits in your number is '.substr($num, -1).'</b>';
						$newquery= "UPDATE userinfo SET hint_credits = '-1' WHERE username = '".$_SESSION['login_name']."'";
						echo $form;

						mysql_query($newquery,$link);

					}

 

In this case, the form is still being shown.

 

I need the form completely removed after the form has been submitted.

 

This is simple and idk why its not working for me!?

Link to comment
Share on other sites

Seems like you could just use a "$showform" variable that's is changed if processing doesn't validate.  For example.

IF ($_POST['Submit']=='Submit){
$showform=false;
IF (!empty($_POST['name'])){
$ckname=('good');
}
Else{
$ckname=('bad');
$showform=true;
}
//ect through the rest of the processing

IF anything doesn't pass, $showform will be true and you can use this to show the form.  Hey, just an idea.

Link to comment
Share on other sites

Seems like you could just use a "$showform" variable that's is changed if processing doesn't validate.  For example.

IF ($_POST['Submit']=='Submit){
$showform=false;
IF (!empty($_POST['name'])){
$ckname=('good');
}
Else{
$ckname=('bad');
$showform=true;
}
//ect through the rest of the processing

IF anything doesn't pass, $showform will be true and you can use this to show the form.  Hey, just an idea.

 

Thanks for the idea. Yeah, that seems like itd be easier.

 

And yes, I know, I have the shittiest code. I can code, but its very messy!

 

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.