<script>
function buttonClick(){
var total = 0;
var type = "";
for(var i=1;i<=3;i++) {
var id = "max_clicks" + i;
var label = "label" + i;
var badge = "badge" + i;
if (document.getElementById(id).checked!=null && document.getElementById(id).checked==true) {
total += parseInt(document.getElementById(id).value);
type +="Max-clicks:<hr style='margin-top:-1px;' />"+ "<span class='badge' style='margin-top:-5px;'>" + document.getElementById("label"+i).innerHTML + "</span> : <span class='badge' style='margin-top:-5px;'>" + document.getElementById("badge"+i).innerHTML + "</span><br />";
}
}
document.getElementById('Totalcost').innerHTML = total;
document.getElementById('individual').innerHTML = type;
}
</script>
<form action="<?php echo "".site_url."";?>/magaza/reklam-ver" method="post" enctype="multipart/form-data">
<input type="checkbox" name="max_clicks[]" id="max_clicks1" value="<?php echo "".$price1."";?>" onClick="buttonClick(this);">
<label id="label1" class="badge" style="background:#fc5a5d;"> 150 clicks</label>-<span class="badge" id="badge1">Price: 5 credits</span><br />
<input type="checkbox" name="max_clicks[]" id="max_clicks2" value="<?php echo "".$price2."";?>" onClick="buttonClick(this);">
<label id="label2" class="badge" style="background:#fc5a5d;"> 400 clicks</label>-<span class="badge" id="badge2">Price: 13 credits</span><br />
<input type="checkbox" name="max_clicks[]" id="max_clicks3" value="<?php echo "".$price3."";?>" onClick="buttonClick(this);">
<label id="label3" class="badge" style="background:#fc5a5d;"> 735 clicks</label>-<span class="badge" id="badge3">Price: 9 credits</span><br />
<span id="individual" class="badge" style="background:#f29d9d;">You dont have any select item.</span>
<button type="button"class="btn btn-primary" onclick="buttonClick()">Price to pay:
<span class="badge"><span id="Totalcost">0</span> credits</span></button>
<input class="btn btn-success" style="float:right;" type="submit" name="add_ad" value="Reklam satın al">
</form>
I trying to get checked item and send to mysql... All working but have problem with send to mysql i want to send max-click -info of <span>....</span> and check price with input value and send this to mysql - max-clicks -value off <span>..</span> and value of input any ideas ? i give my script form.php and action_form.php and sorry for my language :/
if($_POST['add_ad'])
{
if(!empty($_POST['max_clicks'])) {
$shipping_subtotal = 0;
foreach($_POST['max_clicks'] as $shipping){
$shipping_subtotal += $shipping;
}
$user = userInfo();
if($user['credits'] >= $shipping_subtotal){ //check user have enough credits or not
if($_POST['title'] && $_POST['target_url'])
{
$expires = strtotime("+1 month"); //Reklam 1 ay ekle
$title = quote_smart($_POST['title']);
$target_url = quote_smart($_POST['target_url']);
mysql_query("INSERT INTO ads (date_added,date_expires, target_url, clicks, author_id, title, max_clicks) VALUES ('".time()."',$expires, $target_url, '0', '".$_COOKIE['user_id']."', $title, $shipping_subtotal)") or die(mysql_error());
echo info("Success!");
delcredits($user['id'], $shipping_subtotal);
header ("refresh:3;url=".site_url."/magaza/reklam-ver");
}
else
{
echo error("Error.");
}
}
else
{
echo error("you dont have enough credits");
}
}
else{
echo "<b>Please select max-clicks.</b>";
}
}
Related
When I try to click on the submit or cancel the form nothing happens.
Here is part of the register_company.php code.
enter code here
<script type="text/JavaScript">
<!--
function getArrays() {
if (validateForm()) {
loadArray('appcatindex');
loadArray('targetindindex');
loadArray('managedservices');
document.getElementById('company').action = "<?php echo BASE_URL_JCM; ?>/save_company.php";
document.getElementById('company').submit();
} else {
return false;
}
}
function loadArray (tcIndex) {
if (document.getElementById(tcIndex) != null) {
lnLength = document.getElementById(tcIndex).length;
} else {
return true;
}
if (tcIndex == 'docindex') {
textDelim = "";
} else {
textDelim = "";
}
var lcIDs = "";
lcDelim = "";
for (var i=0;i<lnLength;i++) {
if (document.getElementById(tcIndex).options[i].selected) {
lcIDs = lcIDs + lcDelim + textDelim + document.getElementById(tcIndex).options[i].value + textDelim;
lcDelim = ",";
}
}
document.getElementById('a'+tcIndex).value = lcIDs;
}
function validateForm() {
lcReturn = "";
lcReturn = lcReturn + checkText('companyName','Company Name');
lcReturn = lcReturn + checkText('firstName','First Name');
lcReturn = lcReturn + checkText('contactEmail','Contact E-mail Address');
lcReturn = lcReturn + checkSelect('appcatindex','Application Categories');
lcReturn = lcReturn + checkSelect('targetindindex','Target Industries');
lcReturn = lcReturn + checkSelect('managedservices','Managed Services');
lcReturn = lcReturn + checkTextArea('hardwareTech','Hardware Technology');
lcReturn = lcReturn + checkTextArea('softwareTech','Software Technology');
lcReturn = lcReturn + checkTextArea('serviceSolution','Service Solutions');
lcReturn = lcReturn + checkTextArea('iaassolution','Infrastructure-as-Service(IaaS) Solution');
lcReturn = lcReturn + checkTextArea('paassolution','Platform-as-Service(PaaS) Solution');
lcReturn = lcReturn + checkTextArea('keyDiff','Key Differentiators');
lcReturn = lcReturn + checkTextArea('sampleCust','Sample Customer Names');
if (lcReturn != "") {
lcReturn = lcReturn + "\nPlease correct these fields and resubmit.";
alert(lcReturn);
return false;
}
return true;
}
function checkTextArea(tcField,tcLabel) {
lctext = "";
if (document.getElementById(tcField)) {
lctest = document.getElementById(tcField).value;
if (lctest.length > 250) {
lctext = tcLabel + " is greater than 250 characters ("+lctest.length+" used).\n";
}
}
return lctext;
}
function checkSelect(tcField,tcLabel) {
lctext = "";
if (document.getElementById(tcField)) {
lnLength = document.getElementById(tcField).length;
var lnSelCnt = 0;
for (var i=0;i<lnLength;i++) {
if (document.getElementById(tcField).options[i].selected) {
lnSelCnt++;
}
}
if (tcField!='appcatindex') {
if (tcField!='targetindindex') {
if (lnSelCnt > 5) {
lctext = tcLabel + " has more than 5 options selected ("+lnSelCnt+" selected).\n";
}
}
}
if (tcField=='appcatindex') {
if (lnSelCnt > <?php echo $saasAppCoLimit ?>)
{
lctext = tcLabel + " has more than <?php echo $saasAppCoLimit ?> options selected ("+lnSelCnt+" selected).\n";
}
}
if (tcField=='targetindindex' ) {
if (lnSelCnt > <?php echo $saasIndCoLimit ?>)
{
lctext = tcLabel + " has more than <?php echo $saasIndCoLimit ?> options selected ("+lnSelCnt+" selected).\n";
}
}
}
return lctext;
}
function checkText(tcField,tcLabel) {
lctext = "";
if (document.getElementById(tcField)) {
lctest = document.getElementById(tcField).value;
if (lctest == "") {
lctext = tcLabel + " is empty. This field is required.\n";
}
}
return lctext;
}
function updateStatus (toOption) {
lcStatus = toOption.value;
lcStatus = lcStatus.substring(0,1);
document.getElementById('status').value = lcStatus;
}
-->
</script>
<div id="divMain" align="center">
<div id="divContent" align="left">
<!--img src="<?php echo DOMAIN_URL ?>/343/images/company.jpg" border="0" width="670px" align="top" -->
<form name='company' id='company' method='post' action=''>
<!-- h3><?php echo $headtitle ?></h3 -->
<input type='button' value='Submit' onclick='getArrays();return false;' /> <input type='button' value='Cancel' onclick='self.close();' />
<input type="hidden" name="companyid" id="companyid" value="<?php echo $companyid ?>"><input type="hidden" name="querytype" id="querytype" value="<?php echo $querytype ?>">
<input type="hidden" name="profiletype" id="profiletype" value="<?php echo $profiletype ?>"><input type="hidden" name="status" id="status" value="<?php echo $status ?>">
<input type="hidden" name="key" id="key" value="<?php echo $key ?>"><input type="hidden" name="createDate" id="createDate" value="<?php echo $createDate ?>">
<input type="hidden" name="updateDate" id="updateDate" value="<?php echo $updateDate ?>"><input type="hidden" name="enablingTech" id="enablingTech" value="<?php echo $enablingTech ?>">
<input type="hidden" name="paas" id="paas" value="<?php echo $paas ?>"><input type="hidden" name="iaas" id="iaas" value="<?php echo $iaas ?>">
<input type="hidden" name="aappcatindex" id="aappcatindex" value=""><input type="hidden" name="atargetindindex" id="atargetindindex" value="">
<input type="hidden" name="amanagedservices" id="amanagedservices" value=""><input type="hidden" name="request_uri" id="request_uri" value="<?php echo $request_uri ?>">
</form>
</div>
</div>
Problem is only related to submit button it does nothing, I googled it but didn't find any posible solution.
Here is the web link http://www.cloudshowplace.com/saas/
You have a </form> tag but no <form> tag. Something like <form action="action_page.php" method="post"> should work. You could also attach javascript actions to the submit button.
Here the answer to my problem.
Changed input type "button" to "submit", and it started working like a charm.
<input type='submit' value='Submit' onclick='getArrays();return false;' />
<input type='submit' value='Cancel' onclick='self.close();' />
1.can someone find why the form doesnt add/submit the values to database ?
i have tried adding values by the form and testing but its not getting in the database
2.and on calculation i get soms values with more than 2 decimals how to fix that because at the script/code i have decimals on 2 maybe someone ?
screenshot of decimals http://prntscr.com/5fbedf
<html>
<head>
</head><body>
<?php require "config.php" ; ?>
<?php require "admin_menu.php" ;?>
<?php
if(isset($_POST['verzenden']))
{
$id = addslashes($_POST['id']);
$flesnummer = addslashes($_POST['flesnummer']);
$begin_gewicht = addslashes($_POST['begin_gewicht']);
$verbruikt = addslashes($_POST['verbruikt']);
$eind_gewicht = addslashes($_POST['eind_gewicht']);
$verschil = addslashes($_POST['verschil']);
$tara_gewicht = addslashes($_POST['tara_gewicht']);
$over = addslashes($_POST['over']);
mysql_query("INSERT INTO Flesnummer (id, flesnummer, begin_gewicht, verbruikt, eind_gewicht, verschil, tara_gewicht, over) VALUES ('".$id."', '".$flesnummer."', '".$begin_gewicht."', '".$verbruikt."', '".$eind_gewicht."', '".$verschil."', '".$tara_gewicht."', '".$over."')");
echo '<br><br><br>Fles succesvol toegevoegd';
}
else
{
?>
<script>
function totaalIt() {
var x = document.getElementById("begin_gewicht").value;
var y = document.getElementById("tara_gewicht").value;
var z = document.getElementById("verbruikt").value;
var w = document.getElementById("eind_gewicht").value;
if ((isNumeric(x, true)) && (isNumeric(y, true)) && (isNumeric(z, true))&& (isNumeric(w, true))) {
x = parseFloat(x);
y = parseFloat(y);
z = parseFloat(z);
w = parseFloat(w);
var wverschil = x - y - z + y - w
var xyzover = x - y - z
var xyztotaal = x - y - z + y;
document.getElementById("verschil").value = wverschil;
document.getElementById("over").value = xyzover;
document.getElementById("totaal").value = xyztotaal;
if (confirm ("Formule: Begin gewicht - tara gewicht = vulling - verbruikt = vulling over + tara gewicht = totaal - eind gewicht = verschil(verlies) ?")) {
document.getElementById("form1").submit();
}
} else {
alert("Numeric Values must be entered.");
}
}
function isNumeric(sText, decimalAllowed) {
if (sText.length == 0) return false;
var validChars = "";
if (decimalAllowed) {
validChars = "0123456789.";
} else {
validChars = "0123456789";
}
var isNumber = true;
var charA;
var decimalCount = 0;
for (i = 0; i < sText.length && isNumber == true && decimalCount < 2; i++) {
charA = sText.charAt(i);
if (charA == ".") {
decimalCount += 1;
}
if (validChars.indexOf(charA) == -1) {
isNumber = false;
}
}
return isNumber;
}
</script>
<form name="form1" id="form1" action=" <?=$_SERVER['PHP_SELF']?> " method="POST">
<table>
<input type="hidden" name="id" >
<tr><td>Flesnummer:</td><td><input name="flesnummer" id="flesnummer" type="text" size"4">
<tr><td>Begin gewicht:</td><td><input name="begin_gewicht" type="text" id="begin_gewicht" size="4" />
Kg</td></tr>
<tr><td>Tara gewicht:</td><td><input name="tara_gewicht" type="text" id="tara_gewicht" size="4" />
Kg</td></tr>
<tr><td>Verbruik:</td><td><input name="verbruikt" type="text" id="verbruikt" size="4" />
Kg</td></tr>
<tr><td>Vulling over:</td><td><input name="over" type="text" id="over" size="4" readonly="true" />
Kg (automatisch berekend)</td></tr>
<tr><td>Eind gewicht:</td><td><input name="eind_gewicht" type="text" id="eind_gewicht" size="4" />
Kg</td></tr>
<tr><td>Eind gewicht: <img title="Eindgewicht volgens berekening" src="img/question.gif" width="15" height="15" onMouseDown="Eindgewicht volgens berekening" alt="Eindgewicht volgens berekening." /></td><td><input name="totaal" type="text" id="totaal" size="4" readonly="true" />
Kg (automatisch berekend)</td></tr>
<tr><td>Verschil(verlies):</td><td><input name="verschil" type="text" id="verschil" size="4" readonly="true" />
Kg (automatisch berekend)</td></tr>
<tr><td><input type="button" name="verzenden" id="verzenden" value="Verzenden" onClick="totaalIt()" /></td></tr>
</table></form>
<?
}
?>
On your form, try turning your button input to submit:
<input type="button" name="verzenden" id="verzenden" value="Verzenden" onClick="totaalIt()" />
TO:
<input type="submit" name="verzenden" id="verzenden" value="Verzenden" onClick="totaalIt()" />
Your button is not registering the name so it's not getting to the $_POST['verzenden'] in your check:
// There is no $_POST['verzenden'] with the button.
if(isset($_POST['verzenden'])) {
In form, I will be adding product info in. looping name eg. pname1, pname2 when add.
I realise now that when i wanna send to email we need the 'name'. what code should i put on php file to loop the pname?
noted: my form and php code is not in the same file.
or i should put them together and click to loop?
Php file put this?
<?php
$x=1;
while($x<=10)
{
echo "The number is: $x <br>";
echo ;
$x++;
}
?>
form in html
<div class="" id="" name="productlist"> <!-- Add Product Here -->
<ol><input class="fpname" type="text" id="addpname"placeholder="Product Name"/><input class="fpqty" type="number" id="addpqty" placeholder="Quantity"/><input class="fpprice" type="text" id="addpprice" placeholder="Price per Item"/><input type="button" id="padd" value="add"/>
</br><font color="red" size="1.5"><i>*Becareful when adding the Product, once added you are unable to edit the information except changing the quantity.</i></font>
</ol>
<ol id="addhereform"><input type="text" class="fpname" value="Product Name" readonly/><input class="fpqty" type="text" id="pqty" value="Quantity" readonly/><input type="text" class="fpprice" value="Total Price" readonly/>
</ol>
<ol><input class="fpname" id="fpships" type="text" Value="" readonly/><input class="fpqty" id="overallqty" type="text" value="" readonly/><input class="fpprice" type="text" id="overallprice" value="" readonly/>
</ol> <!-- Result -->
</div> <!-- Add Product End Here -->
jquery add button
var count = 1;
$('#padd').click(function(){
var pname = $('#addpname').val();
var pqty = $('#addpqty').val();
var pprice = $('#addpprice').val();
var totalpprice = (pqty * pprice).toFixed(2);
$('#addhereform').append('<li><input class="fpname" type="text" id="pname" name="pname' + count + '" value="' + pname + '" readonly/><input class="fpqty" type="number" id="pqty" name="pqty' + count + '" value="' + pqty + '"/><input type="text" id="pprice" name="pprice' + count + '" value="' + pprice + '" readonly hidden/><input class="fpprice" type="text" id="totalpprice" name="totalpprice' + count + '" value="' + totalpprice + '" readonly/><input type="button" id="premove" value="X"/></li>').before('</li>');
count++;
});
Ans:
$name1 = $_POST["name1"];
$name2 = $_POST["name2"];
$name3 = $_POST["name3"];
# and so on...
for($i = 1; $i <=5; $i++){
$productlist = ${'name' . $i};
echo $productlist;}
Thanks for everyones help,
Here's another method(better) I just found. no need to type all the super long loop way.
Stristr is find name keyword.
if($_POST){
foreach($_POST as $key => $value){
if(stristr($k, 'pname')){
echo "$v";
}
if(stristr($k, 'pqty')){
echo "$v";
}
if(stristr($k, 'pprice')){
echo "$v";
}
if(stristr($k, 'ptotalprice')){
echo "$v</br>";
}
}
}
<input type="button" value="addkid " onClick="show()" />
<div>
<div id="myTableData" style="display:none; width:800px; height:500px; background-color:yellow; margin:0 auto;">
<form action="javascript:insert()" method="get">
<table>
<tr>
<td width="175">NAME</td>
<td width="245"> Gender</td>
<td width="245">Date of Birth</td>
</tr>
<tr>
<td width="175">
<input type="text" name="kid_name" id="kid_name" />
</td>
<td width="245">FEMALE
<input type="radio" name="gender" value="female" id="gender" />MALE
<input type="radio" name="gender" id="gender" value="male" />
</td>
<td width="245">
<?php for ( $i=1; $i<13; $i++ ) { $month=d ate( 'm', mktime(0,0,0,$i,2,2000)); $sel=( $i==d ate( 'n') ? ' selected="selected"' : ''); $options1[]="<option value=\" {$month}\ " {$sel}>{$month}</option>"; } $options_list1=j oin( "", $options1); echo "<select name=\"month\ " id='month' >{$options_list1}</select>"; for ( $j=1; $j<32; $j++ ) { $theday=d ate( 'd', mktime(0,0,0,0,$j,2000)); $sel=( $j==d ate( 'd') ? ' selected="selected"' : ''); $options2[]="<option value=\" {$theday}\ " {$sel}>{$theday}</option>"; } $options_list2=j oin( "\r\n", $options2); echo "<select name=\"day\ " id='day' >{$options_list2}</select>"; for ( $k=1960; $k<2016; $k++ ) { $theyear=d ate( 'Y', mktime(0,0,0,1,1,$k)); $sel1=( $k==d ate( "Y") ? ' selected="selected"' : ''); $options3[]="<option value=\" {$theyear}\ " {$sel1}>{$theyear}</option>"; } $options_list3=j oin( "\r\n", $options3); echo "<select name=\"year\ " id='year' >{$options_list3}</select>"; ?>
</td>
</tr>
</table>
<input type="submit" name="sub" value="add" />
</form>
</div>
</div>
<script>
function show() {
document.getElementById("myTableData").style.display = "block";
}
function createObject() {
var request_type;
var browser = navigator.appName;
if (browser == "Microsoft Internet Explorer") {
request_type = new ActiveXObject("Microsoft.XMLHTTP");
} else {
request_type = new XMLHttpRequest();
}
return request_type;
}
var http = createObject();
//value solve an Internet Explorer cache issue
var nocache = 0;
function insert() {
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('content02').innerHTML = "Just a second..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var kid_name = encodeURI(document.getElementById('kid_name').value);
var gender = encodeURI(document.getElementById('gender').value);
var month = encodeURI(document.getElementById('month').value);
var day = encodeURI(document.getElementById('day').value);
var year = encodeURI(document.getElementById('year').value);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', '4.php?kid_name=' + kid_name + '&gender=' + gender + '&month=' + month + '& day=' + day + '&year=' + year + '&nocache = ' + nocache);
http.onreadystatechange = insertReply;
http.send(null);
}
function insertReply() {
if (http.readyState == 4) {
var response = http.responseText;
// else if login is ok show a message: "Site added+ site URL".
document.getElementById('content02').innerHTML = 'Your contact was successfully added!' + response;
}
}
</script>
4.php
<?php
if(isset($_GET['kid_name']) && isset($_GET['gender']) && isset($_GET['year']) && isset($_GET['day']) && isset($_GET['month']) )
{
echo $newFname = $_GET["kid_name"] ;
echo $newLname = $_GET["gender"] ;
echo $newPhone = $_GET["year"] ;
echo $newEmail = $_GET["day"] ;
echo $newAddress = $_GET["month"] ;
//$insertContact_sql = "INSERT INTO `test`.`contacts` (`newFname`, `newLname`, `newPhone`, `newEmail`, `newAddress`, `group`) VALUES ('{$newFname}' , '{$newLname}' , '{$newPhone}' , '{$newEmail}' , '{$newAddress}' , '{$group}')";
//$insertContact= mysql_query($insertContact_sql) or die(mysql_error());
} else
{
echo 'Error! Please fill all fileds!';
}
?>
I am working with php language. There is a addkid button, which, when the user clicks on the button a pop type window shows the form which has NAME , GENDER AND DOB. In the form action javascript:insert(). I am using ajax for the 1st time so I am not able to understand why it's not working. I guess it should redirect me to 4.php and in 4.php it will echo the values?
I have tested your code and seems it works, I just added a div to show the results there...
You can try to add this div you are not already added it...
<div id="content02">
</div>
Here you write the response, like "Your contact was successfully added"....
I'm doing form in php but I have some problem.
First I will have 3 different form in the same page.
What I want is only 1 form appear and then with the answer a second form will appear and so on.
The answer of the form will be display on the same page.
For now my first form work and after get the answer go to the 2nd form but I want to submit the 2nd form the problem appear.
It delete the answer of my first form and don't do anything (everything start like I am in my first form).
I try to find the problem but can't have idea about how to solve it.
Here is my code:
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
Q1?
<input type="number" name="nbtemplate" min="1" max="30">
<input type="submit" name="submitbutton1" value="Confirm!">
</form>
<?php
if(!isset($submitbutton1)) {
if (!empty($_POST['nbtemplate']) != "") {
echo "<b>{$_POST['nbtemplate']}</b> !\n";
echo "<br />";
$Nnbtemplate = $_POST['nbtemplate'];
$result = mysql_query("UPDATE tb SET day='$Nnbtemplate'") or die(mysql_error());
?>
<form action='<?php echo $_SERVER['PHP_SELF'];?>' method='post'>
Q2? <br>
<?php
for ($i = 1; $i <= $Nnbtemplate; $i++) { // start loop
echo "Template ";
echo $i;
?>
<input type="number" name="nbtime" min="1" max="96">
<?php
}
echo '<input type="submit" name="submitbutton2" value="Confirm!">';
echo '</form>';
if(isset($submitbutton1) && !isset($submitbutton2)) {
if (!empty($_POST['nbtime']) != "") {
echo "<b>{$_POST['nbtime']}</b> !\n";
echo "<br />";
$nbtime = $_POST['nbtime'];
for ($j = 1; $j <= $nbtime; $j++) {
echo "Time";
echo $j;
?>
Q3:
<input type="time" name="starttime"> To <input type="time" name="endtime">
<?php
}
echo '<input type="submit">';
echo '</form>';
}
}
}
}
?>
That is some gnarly code you got there, brother. This is a really simple task when handled with some javascript. Then you can have a single post to your php. I like using the jQuery framework so here's a couple links I found quickly: this one and this one
Example code in response to comment about building form elements dynamically:
<html>
<head>
<!-- load jquery library -->
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
</head>
<body>
<form action="toyourpage.php">
How Many?:
<input type="text" name="number" id="number">
<div id="add"></div>
</form>
<!-- javascript go -->
<script type="text/javascript">
$(document).ready(function()
{
$('input#number').keyup(function()
{
var num = $(this).val(); // get num
if(!isNaN(num)) // check if number
{
$('div#add').html(''); // empty
for(i = 1; i <= num; i++) // add
{
$('div#add').append('New Field ' + i + ': <input type="text" name="next_' + i + '" id="next' + i + '"><br>');
}
}
else
{
alert('Valid number required');
}
});
});
</script>
</body>
</html>
I did some changes on Your code, and have tested, it works.
You had any mistakes in your {} brackets and if conditions. Also as I commented I added extract($_POST).
<?php
extract ( $_POST );
if (! isset ( $submitbutton1 ) && !isset($submitbutton2)) {
?>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
Q1? <input type="number" name="nbtemplate" min="1" max="30"> <input
type="submit" name="submitbutton1" value="Confirm!">
</form>
<?php ;
}
if (isset ( $submitbutton1 )) {
if (! empty ( $_POST ['nbtemplate'] ) != "") {
echo "<b>{$_POST['nbtemplate']}</b> !\n";
echo "<br />";
$Nnbtemplate = $_POST ['nbtemplate'];
$result = mysql_query("UPDATE tb SET day='$Nnbtemplate'") or
die(mysql_error());
?>
<form action='<?php echo $_SERVER['PHP_SELF'];?>' method='post'>
Q2? <br>
<?php
for($i = 1; $i <= $Nnbtemplate; $i ++) { // start loop
echo "Template ";
echo $i;
?>
<input type="number" name="nbtime" min="1" max="96">
<?php
}
echo '<input type="submit" name="submitbutton2" value="Confirm!">';
echo '</form>';
}
}
if ( isset ( $submitbutton2 )) {
if (! empty ( $_POST ['nbtime'] ) != "") {
echo "<b>{$_POST['nbtime']}</b> !\n";
echo "<br />";
$nbtime = $_POST ['nbtime'];
for($j = 1; $j <= $nbtime; $j ++) {
echo "Time";
echo $j;
?>
Q3:
<input type="time" name="starttime"> To <input type="time"
name="endtime">
<?php
}
echo '<input type="submit">';
echo '</form>';
}
}
?>