Page 1 of 1

can't get the go back button to diesappear

Posted: Thu Sep 16, 2010 4:15 pm
by simon_porter00
I'll admit I'm a complete noob and I've been plying with this for the last ... well, long time. There are three error messages which should make a go back button appear - that bit works. If all the requirements are satisfied (ie. there's no need for the go back button to appear) there should just be a message. But, the go back button appears regardless. It's probably something simple in the code, but I'd be grateful if someone could help me out

Code: Select all

echo "<table border=0 width=645>";
echo "<tr><td><input type=button value='<< Go Back' onclick='goBack()' 

/></td></tr></table>";

$aprice = $_POST['Price'];
    if(empty($aprice))
    {
    echo("<h5>You didn't AAA</h5>");
    $showbutton=1;
    }
    else
    {
      
    }

$aTeacherLang = $_POST['TeacherLang'];
    if(empty($aTeacherLang))
    {
      echo("<h5>You didn't BBB</h5>");
    $showbutton=1;
      }
    else
    {
        
    }
            
$athetime = $_POST['thetime'];
//echo("$athetime");

    if(empty($athetime))
    {
      echo("<h5>You didn't CCC.</h5>");
$showbutton=1;
    }
    else
     {
        
    }       
  
date_default_timezone_set('UTC');
//$today = $today = date("m.d.y");
//print_r($today);

$todays_date = date("Y-m-d");

//print $todays_date;

if ($showbutton=="1")
{

}

else
{

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "<h2>Your advert has been posted - thank you!";

}
mysql_close($con);

?>

Re: can't get the go back button to diesappear

Posted: Thu Sep 16, 2010 4:40 pm
by McInfo
You can't say, "Show the button; then, if the button should be visible, do nothing," and expect the button to disappear.

Re: can't get the go back button to diesappear

Posted: Thu Sep 16, 2010 4:43 pm
by simon_porter00
You'll have to forgive my idiocy here, but I'm not sure I follow you. Could you explain?

Re: can't get the go back button to diesappear

Posted: Thu Sep 16, 2010 4:48 pm
by John Cartwright
You need to put this line

Code: Select all

echo "<table border=0 width=645><tr><td><input type=button value='<< Go Back' onclick='goBack()'/></td></tr></table>";
Inside the conditional that checks whether to show the button or not..

Re: can't get the go back button to diesappear

Posted: Thu Sep 16, 2010 4:57 pm
by simon_porter00
Thanks for your help! That did the job.