2 forms on same page php - php

My studybook gives me an assignment which requires me to have 2 forms on one page and output them both to the same page. Is this even possible? Both forms work fine independently. Both have the action:
<?php echo $_SERVER['PHP_SELF']; ?>".
Both have a submit button, but the button only submits the form it's part of. This probably makes sence though.
Thing is i need the page to either post both form outputs when clicking one of the 2 submit buttons or press them subsequently but the information from the first form needs to stay on the page.
Is this possible or am i trying do to the impossible?
the forms are as follows;
form 1:
<form name="orderform" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Korting:
<tr>
<td>
<input type="checkbox" name="korting[]" value=15 /> Student 15% <br>
<input type="checkbox" name="korting[]" value=10 /> Senior 10% <br>
<input type="checkbox" name="korting[]" value=5 /> Klant 5% <br>
<hr />
</td>
</tr>
<tr>
<td>
betalingswijze
<input type="radio" name="betalingswijze" value="paypal"> Paypal
<input type="radio" name="betalingswijze" value="mastercard"> Mastercard
<input type="radio" name="betalingswijze" value="visa"> Visa
<hr />
</td>
<tr>
<td>
<img src="toshiba.jpg" alt=" " />
</td>
</tr>
<tr>
<td>
Toshiba Sattelite A100-510 Basisprijs 999.99
</td>
</tr>
<tr>
<td><!--Shopping Cart Begin-->
<input type="hidden" name="toshibaproduct" value="001" />
<input type="hidden" name="toshibamerk" value="toshiba" />
<input type="hidden" name="toshibamodel" value="Sattelite A100-510" />
Operating system <select name="toshibaos" value="Toshiba">
<option value="xp">Windows XP</option>
<option value="vista">Windows Vista</option>
<option value="linux">Linux</option>
</select>
Aantal: <input type="text" size=2 maxlength=3 name="toshibaaantal" value="0" />
<input type="hidden" name="toshibaprijs" value="999.99" />
<input type="image" src="bestel.jpg" border=0 value="bestellen" />
<hr />
<tr>
<td>
<img src="acer.jpg" alt=" " />
</td>
</tr>
<tr>
<td>
Acer Aspire 5735Z Basisprijs 529.99
</td>
</tr>
<tr>
<td>
<input type="hidden" name="acerproduct" value="002" />
<input type="hidden" name="acermerk" value="acer" />
<input type="hidden" name="acermodel" value="Aspire 5735Z" />
Operating system <select name="aceros" value="Acer">
<option value="xp">Windows XP</option>
<option value="vista">Windows Vista</option>
<option value="linux">Linux</option>
</select>
Aantal: <input type="text" size=2 maxlength=3 name="aceraantal" value="0" />
<input type="hidden" name="acerprijs" value="529.99" />
<input type="image" src="bestel.jpg" border=0 value="bestellen" />
<hr />
</td><!--Shopping Cart End-->
</tr>
</form>
Form 2
<form name="klant gegevens" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table border=1 >
<tr>
<td colspan="2">
<b>Factuur klantgegevens</b>
</td>
</tr>
<tr>
<td width="100">Naam: </td>
<td>
<input type="text" sie="55" name="naam" />
</td>
</tr>
<tr>
<tr>
<td>Adres: </td>
<td>
<input type="text" sie="55" name="adres" />
</td>
</tr>
<tr>
<td>Woonplaats:</td>
<td>
<input type="text size="34" name="woonplaats">
Postcode:<input type="text" size="6" name="postcode">
</td>
</tr>
<tr>
<td>e-mail:</td>
<td>
<input type="text" size="55" name="email">
</td>
</tr>
<tr>
<td>Feedback:</td>
<td>
<textarea cols="40" rows="3" name="commentaar">
</textarea>
</td>
</tr>
</table>
<input type="image" src="checkout.png" value="send"/>
</form>
Both have functions which kick in on submit. Sorry for the spacings. I have them better in my own files but i just don't know how to get them right on this site.
Greetings,
Lennart

The action represent the page that will receive the posted data. You may use differents actions or the same action with different parameters.
If you use the same action, you had to insert a parameter that permit to manage different cases. You may insert an hidden field to do this.
Consider these simple forms:
<form name="form_a" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="form" value="A">
<button type="submit">Form A</button>
</form>
<form name="form_b" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="form" value="B">
<button type="submit">Form B</button>
</form>
To manage the different submission, you had to check the value of the hidden field:
if(isset($_POST['form'])){
switch ($_POST['form']) {
case "A":
echo "submitted A";
break;
case "B":
echo "submitted B";
break;
default:
echo "What are you doing?";
}
}
You can't submit two separate forms at the same time, because each submission represent a different request to the server.
You may merge manually the fields of the two forms, or use Javascript to do this for you.
Keep in mind that if you do this via Javascript, the field of the forms had to have differents names.
As you caan see here you can do simply via jQuery:
var str1 = $("form_a").serialize();
var str2 = $("form_b").serialize();
$.post(url, str1 + "&" + str2);
Where url is the action params of the form

Your form should be like this.
First form
<form method="post" >
...
<input type="hidden" name="form1submission" value="yes" >
<input type="submit" name="submit" value="Submit" >
</form>
Second form
<form method="post" >
...
<input type="hidden" name="form2submission" value="yes" >
<input type="submit" name="submit" value="Submit" >
</form>
And your php for first form.
if('POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['form1submission'])) {
// first form code.
}
And second form php code.
if('POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['form2submission'])) {
// second form code.
}
That's it.

DUPLICATE POST
Yes you can!
First, add the proper action to all forms, secondly, give them an unique name
HTML Side
Don't forget to add the http method what you want (GET or POST)
<form method="post">
<input type="hidden" name="orderform" />
<!-- rest of form goes here -->
</form>
<form method="post">
<input type="hidden" name="klant_gegevens" />
<!-- rest of form goes here -->
</form>
Leaving the action-attribute empty or removing it entirely will make the form submit to the current page (see this post), and usage of $_SERVER["PHP_SELF"] can lead to XSS-injection read under "Big Note on PHP Form Security"
Note:
Avoid using space for field names, it can make some problem to match them...
PHP Side
getting input values, by filtering on received form name
if (isset($_POST["orderform"])) {
// The first form was submitted
}
if (isset($_POST["klant_gegevens"])) {
// The second form was submitted
}
Note:
Use print_r() or var_dump(), to debug the content of exchanged values

Related

Using one form to fill in two other forms

OK so I have two different types of forms and I want to use one form to submit them both. I am using a auto-responder form for form1 fields= first, last and email. My second form is a contact me form fields= name. email and a body field. I am trying to use both these forms at one shot. I have a form that will post fields to each form (INDEX.PHP) the problem is I am not sure how to set up form one to post fields into form1 and form2 the way I want. I want to use the fields that match from form index.php to both the other forms (form1, form2). so name and email will go to both forms and the body field will go to form2. The main form will post first and last in the name field of form2....also as you can see from form 1 and 2 each form has a some sort of redirect page I need to work around.?
I have main form:
Index.php
<html>
<head>
<title>Main Form</title>
</head>
<body>
<h2>Winner Aution Item Request Form</h2>
<p><span class="error"><FONT><font color="red">* required field.</font></span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
First Name: <input type="text" name="first_name" value="<?php echo $first_name;?>">
<FONT><font color="red"> *</font>
<br>
Last Name: <input type="text" name="last_name" value="<?php echo $last_name;?>"> <FONT><font color="red"> *</font>
<br>
E-mail: <input type="text" name="email" value="<?php echo $email;?>">
<FONT><font color="red"> *</font>
<br><br><i><b>Copy and paste auction item name below.</b></i><br>
Product Name: <input type="text" name="product_Name" rows="1" cols="10">
<?php echo $product_Name;?><FONT><font color="red"> *</font>
<input type="Submit" value="Submit" name="submit"></input>
</form>
</body>
</html>
the above form was found on a website and was pretty close to what I want it to do but not exactly....
Form1
<?php session_start(); ?>
<html>
<head>
<title>autoresponder</title>
</head>
<body>
<center>
<table cellspacing="10" bgcolor="#CCCCCC" style="border: 0px solid #000000;">
<tr><td>
<form action="http://newsletter.jeremyahenry.com//s.php" method=GET>
<strong><font color="#660000">Your First Name:</font></strong>
<input type="text" name="f" style="background-color : #FFFFFF" size=11 maxlength=40><br>
<strong><font color="#660000">Your Last name:</font></strong>
<input type="text" name="l" style="background-color : #FFFFFF" size=11 maxlength=40><br>
<strong><font color="#000066">Email address:</font></strong><br>
<input type="text" name="e" style="background-color : #FFFFFF" size=20 maxlength=50>
<input type="image" src="http://blog.jeremyahenry.com/mailermanager/images/go-button.gif" name="submit" value="Submit"><br>
<input type="hidden" name="r" value="4">
<input type="hidden" name="a" value="sub">
<input type="hidden" name="ref" value="none">
<br>
<font color="#003300">HTML: <input type="RADIO" name="h" value="1">Yes
<input type="RADIO" name="h" value="0" checked="checked">No<br>
</font>
</form>
</td></tr>
</table>
</center>
</body>
</html>
Form 2
<?php session_start(); ?>
<html>
<head>
<title>request form</title>
<style>p{font:10pt arial;}</style>
</head>
<body>
<form action="contact_me/process.php" method=post>
<table align=left border=0 height=300>
<tr>
<td nowrap>
<p> Your name:
<input maxlength=25 name=name size=25>
</td>
</tr>
<tr>
<td nowrap>
<p> Your email:
<input name=from size=25 maxlength=25>
</td>
</tr>
<tr>
<td colspan=2>
<center>
<p align=center>Enter your Auction item Name below:
<br>
<textarea cols=50 name=message rows=7></textarea>
<p align=center>
<input type=submit value="Send Message">
<input type=reset value=Reset name="reset">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
ass you can see from the code I was going to use sessions. But not to familiar with it even though I have experience with php I am still quite new to it and need help. I want to pars form data to both forms. and the product name to form two. any help on this would be greatly appreciated.. I hope this is clear enough for some one out there to help.....
Ok New code Three forms 1.main form submits information to form1 and form2.
I have set up using a session so I have: session.php
<?php
session_start();
// store session data
$_SESSION['af_first_name'] = $af_first_name;
$_SESSION['af_last_name'] = $af_last_name;
$_SESSION['af_email'] = $af_email;
$_SESSION['cf_address'] = $cf_item_name;
?>
That handles variables.
My new code for index.php
<?php
// including the session file
require_once("session_start.php")
?>
<?php
function stripZlashes($string)
{
//This function is to strip slashes for either array or a String
if (!is_array($string)) return stripslashes($string);
$nvar = array();
foreach ($string as $key => $value)
$nvar[stripslashes($key)] = stripZlashes($value);
return $nvar;
}
?>
</head>
<body>
<h2>Winner Aution Item Request Form</h2>
<p><span class="error"><FONT><font color="red">* required field.</font></span></p>
<form name="form1">
First Name: <input type="text" name="$af_first_name" id="af_first_name" value="<?php if(isset($_SESSION['af_first_name'])){echo stripslashes($_SESSION['af_first_name']); unset($_SESSION['af_first_name']); } ?>" /><br>
Last Name: <input type="text" name="$af_last_name" id="af_last_name" value="<?php if(isset($_SESSION['af_last_name'])){echo stripslashes($_SESSION['af_last_name']); unset($_SESSION['af_last_name']); } ?>" /><br>
E-Mail: <input type="text" name="$af_email" id="af_email" value="<?php if(isset($_SESSION['af_email'])){echo stripslashes($_SESSION['af_email']); unset($_SESSION['af_email']); } ?>" /><br>
</form>
<form name="form2">Copy and Paste Auction Name Below!<br>
Product Name <br><input type="text" name="$cf_item_name" id="cf_item_name" value="<?php if(isset($_SESSION['cf_item_name'])){echo stripslashes($_SESSION['cf_item_name']); unset($_SESSION['cf_item_name']); } ?>" /><br>
<input type="Submit" value="Submit" name="submit" onsubmit="form2.submit(); form3.submit();"></input>
That form takes input and sets to session. Session.php picks it up and places it in variable form. From here I used a strip for the underscores. and when it goes to form1 and form2 varables pick it up and fill in the form. Here is my new form1
<?php
function stripZlashes($string)
{
//This function is to strip slashes for either array or a String
if (!is_array($string)) return stripslashes($string);
$nvar = array();
foreach ($string as $key => $value)
$nvar[stripslashes($key)] = stripZlashes($value);
return $nvar;
}
if(!empty($_SESSION['_mf'])): //Strip all possible back slashes
stripZlashes($_SESSION['_mf']);
endif;
// including the session file
require_once("session_start.php")
?>
<center>
<table cellspacing="10" bgcolor="#CCCCCC" style="border: 0px solid #000000;"> <tr><td>
<form action="http://newsletter.jeremyahenry.com//s.php" method=GET>
<strong><font color="#660000">Your First Name:</font></strong>
<input type="text" id="$af_first_name" value="<?php echo (!empty($_SESSION['_af']['af_first_name'])?$_SESSION['_af']['af_first_name']:'') ?>" name="f" style="background-color : #FFFFFF" size=11 maxlength=40><br>
<strong><font color="#660000">Your Last name:</font></strong>
<input type="text" id="$af_last_name" value="<?php echo (!empty($_SESSION['_af']['af_last_name'])?$_SESSION['_af']['af_last_name']:'') ?>" name="l" style="background-color : #FFFFFF" size=11 maxlength=40><br>
<strong><font color="#000066">Email address:</font></strong><br>
<input type="text" id="$af_email" value="<?php echo (!empty($_SESSION['_af']['af_email'])?$_SESSION['_af']['af_email']:'') ?>" name="e" style="background-color : #FFFFFF" size=20 maxlength=50>
<input type="image" src="http://newsletter.jeremyahenry.com/images/go-button.gif" name="submit" value="Submit"><br>
<input type="hidden" name="r" value="4">
<input type="hidden" name="a" value="sub">
<input type="hidden" name="ref" value="none">
<br>
<font color="#003300">HTML: <input type="RADIO" name="h" value="1">Yes
<input type="RADIO" name="h" value="0" checked="checked">No<br>
</font></form>
</td></tr></table>
</center>
<?php
if(!empty($_SESSION['_mf'])):
unset($_SESSION['_mf']);
endif;
?>
form2:
<?php
function stripZlashes($string)
{
//This function is to strip slashes for either array or a String
if (!is_array($string)) return stripslashes($string);
$nvar = array();
foreach ($string as $key => $value)
$nvar[stripslashes($key)] = stripZlashes($value);
return $nvar;
}
if(!empty($_SESSION['_mf'])): //Strip all possible back slashes
stripZlashes($_SESSION['_mf']);
endif;
// including the session file
require_once("session_start.php")
?>
<form action="process.php" method=post>
<table align=left border=0 height=300>
<tr>
<td nowrap>
<p> Your name:
<input maxlength=25 name="af first name" id="af_first_name" value="<?php echo (!empty($_SESSION['_af']['af_first_name'])?$_SESSION['_af']['af_first_name']:'') ?>" size=25> />
</td</tr>
<tr>
<td nowrap>
<p> Your email:
<input name=af email id="af email" value="<?php echo (!empty($_SESSION['_af']['af_email'])?$_SESSION['_af']['af_email']:'') ?>" size=25 maxlength=25> />
</td></tr>
<tr>
<td colspan=2>
<center>
<p align=center>Enter your Auction item Name below:
<br>
<input name="cf item name" id="cf item name" value="<?php echo (!empty($_SESSION['_cf']['cf_item_name'])?$_SESSION['_cf']['cf_item_name']:'') ?>" rows="1" />
<p align=center>
<input type=submit value="Send Message">
</td></tr></table>
</form>
</center>
Ok now i have an issue with it submitting correctly...
<form name="form1">
<input type="text" value="" name="somename" onkeyup="form2.somename.value=this.value" />
</form>
<form name="form2">
<input type="text" value="" name="somename" />
</form>
check out the above code. hope this could be helpful. Or if this is not the result which you require. so you can be brief with your requirements in reply.
I don't know the usage or need of your implementation: maybe it is like a 3 step registration form?
It could be done in different ways without complicating it too much.
You could put all three forms in the same page and only showing the right one
according to th data being posted to the same page. It is the old way of doing things.
With Ajax calls, templates and javascript it could be don simpler but it depends on
your experience.
on each element you can mention as per their relevent events, such as
Ex. onkeyup="form2.elementname.value=this.value"

How to submit two php forms to one location

I have two php forms, both for registration means (enter name, username, password etc). My first registration form (reg1.php) contains the basic inputs as I mentioned above and then I have a second registration form (reg2.php) that includes checkboxes where the form would ask the user other questions before finalizing their sign up.
What I am having trouble with is that when I enter data into my inputs in the first registration form, then proceed to the next registration page and fill that out and click Sign Up, my output on my server only obtains the information I inputted in the second registration page, not the first.
How can I get both inputted data from the two registration pages to appear together? I have been told about POSTBACK to help with this but I am not all that familiar with how to use it.
First php page:
<body>
<?php include("menu.php"); ?>
<div id="main">
<h2>Sign Up</h2>
<table style="width:300px">
<form name="Rego" method="post" action="rego2.php">
<tr>
<td><label>Name:</label></td>
<td><input type="text" name="fname"/></td>
</tr>
<tr>
<td><label>Username:</label></td>
<td><input type="text" name="username"/></td>
</tr>
<tr>
<td><label>Password:</label></td>
<td><input type="password" name="password" id="pass" /></td>
</tr>
<tr>
<td><label>Confirm Password:</label></td>
<td><input type="password" name="conpassword" id="conpass"/></td>
</tr>
<tr>
<td><p><input class="button" type="submit" value="Next Page">
<input class="button" type="reset" value="Reset"></p></td>
</tr>
</form>
</table>
</div>
</body>
Second php page
<body>
<?php include("menu.php"); ?>
<div id="main">
<h2>Sign Up</h2>
<table>
<form name="Rego" method="post" action="http://myserver...">
<tr>
<td>
<input type="checkbox" name="checkbox" value="Agree to T&C">I agree to the Terms and Conditions<br>
<input type="checkbox" name="checkbox" value="No Criminal Records">I have no criminal associations<br>
</td>
</tr>
<tr>
<td><p><input class="button" type="submit" value="Sign Up">
<input class="button" type="reset" value="Reset"></p></td>
</tr>
</form>
</table>
</div>
</body>
When the first form is submitted either store the data in a $_SESSION variable and retrieve it when you process the second form, or write it to hidden <input> elements on your second form and retrieve it from the $_GET or $_POST array
In 2nd input form you take first inout from value and keep those one as hidden.
and 2nd input form you should
<body>
<?php include("menu.php"); ?>
<div id="main">
<h2>Sign Up</h2>
<table>
<form name="Rego" method="post" action="http://myserver...">
<input type="hidden" name="fname" value="<?php echo $_POST['fname'];?> " />
<input type="hidden" name="username" value="<?php echo $_POST['username'];?> " />
<input type="hidden" name="passowrd" value="<?php echo $_POST['password'];?> " />
<input type="hidden" name="conpassowrd" value="<?php echo $_POST['conpassword'];?> " />
<tr>
<td>
<input type="checkbox" name="checkbox" value="Agree to T&C">I agree to the Terms and Conditions<br>
<input type="checkbox" name="checkbox" value="No Criminal Records">I have no criminal associations<br>
</td>
</tr>
<tr>
<td><p><input class="button" type="submit" value="Sign Up">
<input class="button" type="reset" value="Reset"></p></td>
</tr>
</form>
</table>
</div>
</body>
I hope it will work for you.
In the second page, you can get the post data from page 1 and set it in a hidden field like this, say the fname:
<input type="hidden" name="fname" id="fname" value="<?php echo $_POST['fname'] ?>">
When you submit from the second page, you can catch this data in the destination page, say
$_POST['fname']

Sending form data to PayPal checkout

Ok here is problem, I am sending form data via radio buttons to a PayPal checkout but it works when you first upload the php file and takes the correct values, but if you return and select say the next radio button and submit it then changes the submit info to the value you sent before almost overiding it?
<table class="procut_item" border="0" cellpadding="4">
<tr>
<td width="auto"><h4>Product test</h4></td>
<td width="auto"><form method="post" action="process.php">
<input type="hidden" name="itemprice" value="10" />
<input type="hidden" name="itemQty" value="1" />
Size:<input type="radio" name="itemname" value="1">10 x 10</select>
<input class="dw_button" type="submit" name="submitbutt" value="Buy" />
</td>
<tr>
<tr>
<td width="auto"><h4>Product test</h4></td>
<td width="auto"><form method="post" action="process.php">
<input type="hidden" name="itemprice" value="30" />
<input type="hidden" name="itemQty" value="1" />
Size:<input type="radio" name="itemname" value="1">10 x 10</select>
<input class="dw_button" type="submit" name="submitbutt" value="Buy" />
</td>
<tr>
</table>
With seeing all of the code and how it is being handled, my first guess would be that you are usnig the same variable name, and it is overriding the first. You could could create an array if not already using one, or increment the variable name by appending a number to it.

1st form within table not submitting

I have a while loop generated table that looks like the following:
<table>
<tr>
<th>Date</th>
<th>Pushups</th>
<th>Delete</th>
</tr>
<tr>
<td>11-01-2012</td>
<td>28</td>
<td>
<form action="../workout_tracker/delete_pushups.php" method="get" id="Delete1">
<input type="hidden" value="253" name="pushups_id" />
<input type="hidden" value="/workout_tracker/pushups-tracker/" name="current_page" />
<input type="submit" value="Delete" form="Delete1" />
</form>
</td>
</tr>
<tr>
<td>11-02-2012</td>
<td>33</td>
<td>
<form action="../workout_tracker/delete_pushups.php" method="get" id="Delete2">
<input type="hidden" value="246" name="pushups_id" />
<input type="hidden" value="/workout_tracker/pushups-tracker/" name="current_page" />
<input type="submit" value="Delete" form="Delete2" />
</form>
</td>
</tr>
<tr>
<td>11-03-2012</td>
<td>43</td>
<td>
<form action="../workout_tracker/delete_pushups.php" method="get" id="Delete3">
<input type="hidden" value="39" name="pushups_id" />
<input type="hidden" value="/workout_tracker/pushups-tracker/" name="current_page" />
<input type="submit" value="Delete" form="Delete3" />
</form>
</td>
</tr>
</table>
The problem is that the first "Delete" form in the first row of the table isn't submitting. When I click, it doesn't do anything.
There is a form higher up on the page, but it closes and has validated. I get the same response in Chrome, Firefox, and IE.
UPDATE:
In a different form higher in the markup (not shown), the form tag had not been closed. I had </for>...
Do any of the other delete forms work or is it just the first one?
Open up your browser console/debugger and look for any errors on page load or when you click the button.
The only thing that looks as a possible problem is the form attribute of the submit input element. The link below shows that it's new in HTML5 and the only browser that doesn't support it yet is IE. It could be that you need to update to the latest version of your browser.
http://www.w3schools.com/tags/att_input_form.asp

Joomla 2.5 404 Error When Submitting PHP Form inside an Article

I made my own module to submit a php form's data into the database. I have the module inside of an article now.
When I submit the form, it goes to a 404 error page even though I have another template page for a successful submission.
I have tried using action = post.php as well as the exact URL but it fails.
Does anyone know what I am going wrong?
Here is the URL: http://aubrey-joomla-test.freeiz.com/index.php/new-user-registration-form
Here is my file name for the default template: default_tmpl.php
Here is my tmpl code:
<div>
<form action="<?php echo JRoute::_('index.php'); ?>" method="post" id="myform" class="cols" >
<input type="hidden" name="form_send" value="send" />
<h2>New User Registration Form</h2>
<table>
<label>Are you employed?</label>
<tr>
<td><label><input type="radio" name="option" value="1" required="required">Yes</label></td>
<td><label><input type="radio" name="option" value="0" required="required">No</label></td>
</tr>
<label>If not, please proceed to the next section.</label>
</table>
<fieldset name="salary">
<h4>Income From Employment</h4>
<table> <tr><label>Pay cycle:</label>
<td><label><input type="radio" name="option1" value="1" required="required">Monthly</label></td>
<td><label><input type="radio" name="option1" value="2" required="required">Biweekly</label></td>
</tr> </table>
<p><label>Please enter your typical pay: <input type="text" name="amountpay" required="required" pattern="\d+(\.\d{2})?"/> </label></p>
<p><label>Please select your next pay day: <input type="date" name="paydate" required="required" /> </label></p>
</fieldset>
<fieldset name="fixeditems">
<h4>Fixed Items</h4>
<table> <label>Payment cycle:</label> <tr>
<td><label><input type="radio" name="option2" value="1" required="required">Monthly</label></td>
<td><label><input type="radio" name="option2" value="2" required="required">Biweekly</label></td>
<tr>
</table>
<table> <label>Is this a form of:</label> <tr>
<td><label><input type="radio" name="option3" value="2" required="required">Income</label></td>
<td><label><input type="radio" name="option3" value="1" required="required">Expense</label></td>
<tr>
</table>
<p><label>Please enter the typical amount: <input type="text" name="amount" required="required" pattern ="\d+(\.\d{2})?" /> </label></p>
<p><label>Please select the next due date: <input type="date" name="amountdate" required="required" /> </label></p>
</fieldset>
<hr>
<div class="clear"></div>
<button type="submit" name="send" value="Send">Submit form</button>
<button type="reset">Reset</button>
</form>
</div>
You have no code to handle a form submission. You need to add in a hidden field that would trigger additional code that handles the form submission instead of displaying the form. You need something like this in your module -
if $_POST["form_submit_trigger"] :
PUT SOME CODE HERE TO HANDLE YOUR SUBMITTED DATA
else
PUT THE CODE TO DISPLAY YOUR FORM HERE
form_submit_trigger should be a hidden field in your form that is generated and hashed each time the form is diaplyed. This way you can confirm that the form was actually generated and submitted on your site.

Categories