Reputation: 25
My HTML code:
<p>NEWS</p>
<p>
<form action="news.php" method="post"> <center><input name="NEW" type="submit"
id="new" value="NEW"/>
<input name="Modify" type="submit" id="Modify2" value="Modify" />
</form>
</p>
news.php
<?php //Main function
$event=$_POST;
if($event=='NEW')
post_new(); //already defined
else if($event=='Modify')
modify();//already defined
?>
post_new()
and Modify()
are already defined in the document.
What I intend to do is check which button has been clicked on the first page and invoke the functions accordingly but I don't know where I am wrong because its not working. Please help, thanks in advance.. :)
Upvotes: 0
Views: 922
Reputation: 3209
Try print_r($_POST)
to see the full contents and structure of $_POST (which is an array)
Upvotes: 0
Reputation: 479
For achieving this you will have to check:
if($_POST['NEW']=="NEW")
post_new();
else if($_POST['Modify']=="Modify")
modify();
Upvotes: 0
Reputation: 2817
$event (and $_POST) is an array. Use it like this:
<?php //Main function
$event=$_POST;
if(isset($event['NEW']))
post_new(); //already defined
else if(isset($event['Modify']))
modify();//already defined
?>
Upvotes: 3