can't get the go back button to diesappear

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simon_porter00
Forum Newbie
Posts: 13
Joined: Thu Feb 25, 2010 1:25 pm

can't get the go back button to diesappear

Post 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);

?>
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

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

Post by McInfo »

You can't say, "Show the button; then, if the button should be visible, do nothing," and expect the button to disappear.
simon_porter00
Forum Newbie
Posts: 13
Joined: Thu Feb 25, 2010 1:25 pm

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

Post by simon_porter00 »

You'll have to forgive my idiocy here, but I'm not sure I follow you. Could you explain?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

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

Post 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..
simon_porter00
Forum Newbie
Posts: 13
Joined: Thu Feb 25, 2010 1:25 pm

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

Post by simon_porter00 »

Thanks for your help! That did the job.
Post Reply