I want to display a set of buttons when a button is pressed on the page. whats wrong in this code. it's giving errors

<?php
if(isset($_POST['submit']))
{ 
<form method="post" action="">
<input type="submit" name="submit1" value="Style1">
</form>

<form method="post" action="">
<input type="submit" name="submit2" value="Style2">
</form>

<form method="post" action="">
<input type="submit" name="submit3" value="Style3">
</form>

<form method="post" action="">
<input type="submit" name="submit4" value="Style4">
</form>

<form method="post" action="">
<input type="submit" name="submit5" value="Style5">
</form>

<form method="post" action="">
<input type="submit" name="submit6" value="Style6">
</form>

}
?>

<form method="post" action="">
<input type="submit" name="submit" value="Style">
</form>

Recommended Answers

All 5 Replies

What errors are you getting? Also the button never gets set because you do not tell the form where to post to.

Hi, change your codes to this

<?php
if(isset($_POST['submit']))
{ ?>
<form method="post" action="">
<input type="submit" name="submit1" value="Style1">
</form>

<form method="post" action="">
<input type="submit" name="submit2" value="Style2">
</form>

<form method="post" action="">
<input type="submit" name="submit3" value="Style3">
</form>

<form method="post" action="">
<input type="submit" name="submit4" value="Style4">
</form>

<form method="post" action="">
<input type="submit" name="submit5" value="Style5">
</form>

<form method="post" action="">
<input type="submit" name="submit6" value="Style6">
</form>

<?php
}
?>

<form method="post" action="">
<input type="submit" name="submit" value="Style">
</form>

You cannot put html tags within the php tags, without echo or print or better yet close the php tags and then re-open where it is needed as shown on your modified codes I have provided.

when i am pressing style1 the original page is coming with 'style' button. why is it? there's nothing should come right ? whats wrong

Member Avatar for diafol

you've started a new thread on this?

when i am pressing style1 the original page is coming with 'style' button. why is it? there's nothing should come right ? whats wrong

put your style button within the else statement like

<?php
}
else{
?>
<form method="post" action="">
<input type="submit" name="submit" value="Style">
</form>
<?php
}
?>

Just to remind you that you cannot double post on the same type of question. That will throw off a lot people here, who are just trying to help you..

It could be this post, or the other one that you've just started.. you choice..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.