Jump to content

[SOLVED] Forms in PHP


itdmacar

Recommended Posts

Hi,

 

How do you process if you have forms in your script ? I have form 1 and form 2 in my scripts and their method are both 'POST', my logic is to go back to the same script whenever I click the submit button from my form 1, my problem is whenever I click the select botton and goes back to the same script it does not recognise the other buttons from Form 2.

 

How do I process 2 forms ?  Can someone has the sample scripts, please . . .

Link to comment
https://forums.phpfreaks.com/topic/68623-solved-forms-in-php/
Share on other sites

Something along the lines of:

 

<?php
if(isset($_POST['submitbutton1'])){
//process 1st form
}
if(isset($_POST['submitbutton2'])){
//process 2nd form
}
//any html headers/css etc
?>
<form action=<?php echo $_SERVER['phpself'];?> method="POST">
<?php
if(!isset($_POST['submitbutton2'])){
if(!isset($_POST['submitbutton1'])){//neither form submitted
	//show first form
	echo '<input type="submit" name="submitbutton1">';
}else{//first form has been submitted 
	//show second form
	echo '<input type="submit" name="submitbutton2">';
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/68623-solved-forms-in-php/#findComment-344911
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.