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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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