two different functions
Is there any way to have two different functions on the same form?
I have my form importing to Mysql(works great) but the imports are limited. I need the whole form to be saved,emailed,imported some where else(I dont need the whole form imported to the DB. I have tried the file import,and the copy, but the "submit" only looks at the first .PHP and not the second.
You want the choice of handling the form data two different ways?
What you are asking is a little unclear.:confused:
You can have only one action attribute for a HMTL form element.
You could have two forms on the page (eg. two submit buttons) and the user can choose which one to use...
is that what you are talking about??
look at Trickie post,,, I was trying to get two different actions to work on the same HTML>
Well, it depends on how you write your code. You can actually have the option of multiple actions for one form.
Look at "Submit" and "Reset"... there's two different actions right there.
You can have multiple buttons on the same form and have each button assigned a different value. The action performed on the form data would be dependant upon the value of the pressed submit button.
Let's see if I can whip up a brief example for you:
Now in this form, we could perform one of 6 actions, Submit, Delete, Change, Hop, Skip, or Jump, upon the data (the lone text field in this form), depending up which "submit" button is pressed.
<form name="exampleForm" action="recievingCode.php" method="post">
<input type="text" name="textField" value="" />
<input type="submit" name="submit" value="Submit" />
<input type="submit" name="submit" value="Delete" />
<input type="submit" name="submit" value="Change" />
<input type="submit" name="submit" value="Hop" />
<input type="submit" name="submit" value="Skip" />
<input type="submit" name="submit" value="Jump" />
<input type="reset" value="Reset" />
We can do this because the VALUE of the submit button is checked by the recievingCode.php file and the appropriate action performed.
Is this want you were looking for?
$submit = isset($_POST['submit']) ? $_POST['submit'] : '';
if($submit == 'Submit')
// code to perform when "Submit" was pressed
if($submit == 'Delete')
// code to perform when "Delete" was pressed
if($submit == 'Jump')
// code to perform when "Jump" was pressed
is the there help with the code (PHP) in the book?
And you don't need to have a lot of buttons on your form. You could have a drop-down box that lists the possible actions you could perform on the submitted data, and only one submit button. Then you test for the value of the selected item in the drop-down, and perform the appropriate action.
Anyway, I don't know what book you are talking about, but any good PHP book will talk/teach the principles that you need to make it work.