PHP Session Vairables for Checkout/basket system - php

Im attempting to build an E-commerce website, I'm trying to use sessions to store a product name, price and quantity in a session variable from my product details page to then be used in my basket/checkout page once the user clicks add to basket.
I have some $_SESSION[] but I get the error :
Notice: Undefined index: prod_Name in C:\MAMP\htdocs\product1_details.php on line 25
Notice: Undefined index: prod_Price in C:\MAMP\htdocs\product1_details.php on line 26
I don't know how to add the product name, price and quantity to a session variable so that I can display it in my basket on another page.
you wont see a session.start() as it is in my application_top.php (I was asked to do it this way)
This is my product details page -
<?php
require('includes/application_top.php');
$page_title='Details';
require('includes/site_header.php');
$_GET['prod_ID'];
$product_id = isset($_REQUEST['prod_ID']) ? (int) $_REQUEST['prod_ID'] : 0;
$pound ="£";
?>
<style>
<?php
require('css/prod_details.css');
?>
</style>
<br>
<br>
<br>
<br>
<br>
<?php $product = get_product_details1($freshKickz_conn); ?>
<?php foreach($product as $productdetails) {
?>
<main class="container">
<!-- Left Column / Headphones Image -->
<div class="left-column">
<img data-image="red" class="active" src="<?= htmlspecialchars($productdetails['images']) ?>" style="height: 400px; width: 400px;" alt="">
</div>
<!-- Right Column -->
<div class="right-column">
<!-- Product Description -->
<div class="product-description">
<h1><?= htmlspecialchars($productdetails['prod_Name']) ?></h1>
<p><?= htmlspecialchars($productdetails['prod_Details']) ?></p>
</div>
<!-- Product Pricing -->
<div class="product-price">
<span><?=$pound?><?= htmlspecialchars($productdetails['prod_Price'])?></span>
Add to Basket
</div>
<br>
<div class="quantity">
<span>Quantity</span>
<br>
<input type="number" min="1" max="9" step="1" value="1">
</div>
</div>
</main>
<?php
} ?>
<script src="js/prodJS.js"></script>
<script>
$(document).ready(function () {
$('.color-choose input').on('click', function () {
var headphonesColor = $(this).attr('data-image');
$('.active').removeClass('active');
$('.left-column img[data-image = ' + headphonesColor + ']').addClass('active');
$(this).addClass('active');
});
});
</script>
<?php
require('includes/application_bottom.php');
require('includes/site_footer.php');
?>
And this is my basket page -
<?php
require('includes/application_top.php');
$page_title='Your Basket';
require('includes/site_header.php');
$_SESSION['p_Name'] = $_POST['prod_Name'];
$_SESSION['p_Price'] = $_POST['prod_Price'];
?>
<style>
<?php
require('css/basket.css');
?>
</style>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<div class="row">
<div class="col-75">
<div class="container">
<form action="/action_page.php">
<div class="row">
<div class="col-50">
<h3>Billing Address</h3>
<label for="fname"><i class="fa fa-user"></i> Full Name</label>
<input type="text" id="fname" name="firstname" placeholder="John M. Doe">
<label for="email"><i class="fa fa-envelope"></i> Email</label>
<input type="text" id="email" name="email" placeholder="john#example.com">
<label for="adr"><i class="fa fa-address-card-o"></i> Address</label>
<input type="text" id="adr" name="address" placeholder="542 W. 15th Street">
<label for="city"><i class="fa fa-institution"></i> City</label>
<input type="text" id="city" name="city" placeholder="New York">
<div class="row">
<div class="col-50">
<label for="state">County</label>
<input type="text" id="county" name="county" placeholder="Cheshire">
</div>
<div class="col-50">
<label for="zip">PostCode</label>
<input type="text" id="postcode" name="postcode" placeholder="SK11 6TF">
</div>
</div>
</div>
<div class="col-50">
<h3>Payment</h3>
<label for="fname">Accepted Cards</label>
<div class="icon-container">
<i class="fa fa-cc-visa" style="color:navy;"></i>
<i class="fa fa-cc-amex" style="color:blue;"></i>
<i class="fa fa-cc-mastercard" style="color:red;"></i>
<i class="fa fa-cc-discover" style="color:orange;"></i>
</div>
<label for="cname">Name on Card</label>
<input type="text" id="cname" name="cardname" placeholder="John More Doe">
<label for="ccnum">Credit card number</label>
<input type="text" id="ccnum" name="cardnumber" placeholder="1111-2222-3333-4444">
<label for="expmonth">Exp Month</label>
<input type="text" id="expmonth" name="expmonth" placeholder="September">
<div class="row">
<div class="col-50">
<label for="expyear">Exp Year</label>
<input type="text" id="expyear" name="expyear" placeholder="2018">
</div>
<div class="col-50">
<label for="cvv">CVV</label>
<input type="text" id="cvv" name="cvv" placeholder="352">
</div>
</div>
</div>
</div>
<label>
<input type="checkbox" checked="checked" name="sameadr"> Shipping address same as billing
</label>
<input type="submit" value="Continue to checkout" class="btn">
</form>
</div>
</div>
<div class="col-25">
<div class="container">
<h4>Cart
<span class="price" style="color:black">
<i class="fa fa-shopping-cart"></i>
<b>4</b>
</span>
</h4>
<p><?= $_SESSION['p_Name']?> <span class="price">$15</span></p>
<p>Product 2 <span class="price">$5</span></p>
<p>Product 3 <span class="price">$8</span></p>
<p>Product 4 <span class="price">$2</span></p>
<hr>
<p>Total <span class="price" style="color:black"><b>$30</b></span></p>
</div>
</div>
</div>
<?php
require('includes/application_bottom.php');
require('includes/site_footer.php');
?>

You are getting the error in $_POST. You are not submitting any form with method POST.

Related

If I click on one check box another check box also checked

If I click on one check box another check box also checked.
addquiz.php
<?php
$unique_id = time().'_'.uniqid(true);
$userid = $this->session->userdata('cp_userid');
?>
<!-- DC QUIZZ -->
<form class="addquizform" id="quiz_form_<?php echo $unique_id;?>" data-form = "<?php echo $unique_id;?>" data-user = '<?php echo $userid ?>'>
<input type="hidden" name="sid" value="<?php echo $sectionId;?>">
<input type="hidden" name="cid" value="<?php echo $courseId;?>">
<div class="dc-quizz-info dc-course-item">
<div class="dc-content-title">
<h5 class="xsm black">Quiz : Title of quiz</h5>
<div class="course-region-tool">
<input type="button" value = "Save" class="mc-btn-3 btn-style-1 savequiz save" id="save_quiz_<?php echo $unique_id;?>">
</div>
</div>
<div class="quizz-body dc-item-body">
<div class="form-item form-checkbox checkbox-style">
<input type="checkbox" id="showanswer" value="1" name="showanswer">
<label for="showanswer">
<i class="icon-checkbox icon md-check-1"></i>
Show Answer
</label>
</div>
<div class="form-item form-checkbox checkbox-style">
<input type="checkbox" id="limittime">
<label for="limittime">
<i class="icon-checkbox icon md-check-1"></i>
Limit time
</label>
</div>
<div class="time">
<div class="form-item">
<input type="text" name="limittime">
<label for="">mins</label>
</div>
</div>
<div class="form-item">
<input type="text" placeholder="Quiz Title" class="fullwidth" name="quiztitle">
</div>
<div class="form-item">
<input type="text" placeholder="Short introduction" class="fullwidth" name="quizintro">
</div>
</div>
</div>
</form>
<!-- END / DC QUIZZ -->
when I go to add one more quiz it asks to check the check box, but when I clicked on check box above check box also checked. How to over come this problem.
Please Check The Name as well as id You Defined there is missing an id and name for checkbox
<div class="dc-quizz-info dc-course-item">
<div class="dc-content-title">
<h5 class="xsm black">Quiz : Title of quiz</h5>
<div class="course-region-tool">
<input type="button" value = "Save" class="mc-btn-3 btn-style-1 savequiz save" id="save_quiz_<?php echo $unique_id;?>">
</div>
</div>
<div class="quizz-body dc-item-body">
<div class="form-item form-checkbox checkbox-style">
<input type="checkbox" id="showanswer" value="1" name="showanswer">
<label for="showanswer">
<i class="icon-checkbox icon md-check-1"></i>
Show Answer
</label>
</div>
<div class="form-item form-checkbox checkbox-style">
<input type="checkbox" name="limitcheck" id="limitcheck">
</div>
<div class="time">
<label for="limittime">
<i class="icon-checkbox icon md-check-1"></i>
Limit time
</label>
<div class="form-item">
<input type="text" value="" id="limittime" name="limittime">
<label for="">mins</label>
</div>
</div>
<div class="form-item">
<input type="text" placeholder="Quiz Title" class="fullwidth" name="quiztitle">
</div>
<div class="form-item">
<input type="text" placeholder="Short introduction" class="fullwidth" name="quizintro">
</div>
</div>
</div>

multipage form with jquery and php validation

I am working with a multipage form, needs to validate in each page. jquery validating well, but i have to post the data in the same page through ajax to backend for php validation and if return success needs to load the next page or else need to show validation error from backend to front end.
The problem is, here the form is getting validated well in frontend but not posting data for backend validation what i am doing wrong in the code please advice. Thanks in advance
HTML
<form class="ui form segment" id="msform" action="main.php" method="post">
<ul id="progressbar">
<li class="active">Account Setup</li>
<li>Career Details</li>
<li>Personal Details</li>
</ul>
<fieldset class="step">
<div class="two fields">
<div class="field">
<label>First name</label>
<input placeholder="First Name" name="first_name" type="text">
</div>
<div class="field">
<label>Last name</label>
<input placeholder="Last Name" name="last_name" type="text">
</div>
</div>
<div class="two fields">
<div class="field">
<label>Display name</label>
<input placeholder="Display Name" name="display_name" type="text">
</div>
<div class="field">
<label>User name</label>
<input placeholder="User Name" name="user_name" type="text">
</div>
</div>
<div class="two fields">
<div class="field">
<label>Email</label>
<input placeholder="Email" name="email" type="text">
</div>
<div class="field">
<label>Password</label>
<input type="password" placeholder="Password" name="password" type="text">
</div>
</div>
<div class="two fields">
<div class="field">
<label>Date of birth</label>
<div class="ui calendar" id="date_birth">
<div class="ui input left icon">
<i class="calendar icon"></i>
<input type="text" placeholder="Date" name="dob">
</div>
</div>
</div>
<div class="field">
<label>Gender</label>
<div class="ui selection dropdown">
<input name="gender" type="hidden">
<div class="default text">Gender</div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="1">Male</div>
<div class="item" data-value="0">Female</div>
</div>
</div>
</div>
</div>
<div class="field">
<label>Marital status</label>
<div class="ui selection dropdown">
<input name="marital_status" type="hidden">
<div class="default text">Marital status</div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="married">Married</div>
<div class="item" data-value="single">Single</div>
</div>
</div>
</div>
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<fieldset class="step">
<div class="two fields">
<div class="field">
<label>Highest qualification</label>
<input placeholder="Highest qualification" name="highest_qualification" type="text">
</div>
<div class="field">
<label>University/college</label>
<input placeholder="University/college" name="university_or_college" type="text">
</div>
</div>
<div class="two fields">
<div class="field">
<label>Course type</label>
<div class="ui selection dropdown">
<input name="course_type" type="hidden">
<div class="default text">Course type</div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="1">Full time</div>
<div class="item" data-value="0">Part time</div>
</div>
</div>
</div>
<div class="field">
<label>Mobile</label>
<input placeholder="Mobile" name="mobile" type="text">
</div>
</div>
<div class="field" id="container">
<label>Upload resume</label>
<label for="file" class="ui icon button">
<i class="file icon"></i>
<div id="filelist">Your browser doesn't have Flash, Silverlight or HTML5 support.</div>
<a id="pickfiles" href="javascript:;">Select resume</a> <br />
</label>
<input type="file" id="file" style="display:none">
<a id="uploadfiles" href="javascript:;">Upload</a>
</div>
<div class="field" id="container">
<label>Upload photo</label>
<label for="file" class="ui icon button">
<i class="file icon"></i>
<div id="filelist_new">Your browser doesn't have Flash, Silverlight or HTML5 support.</div>
<a id="pickfiles_new" href="javascript:;">Select photo</a>
</label>
<a id="uploadfiles_new" href="javascript:;">Upload</a>
<input type="file" id="file" style="display:none">
</div>
<div class="two fields">
<div class="field">
<label>Current designation</label>
<input placeholder="Current designation" name="current_designation" type="text">
</div>
<div class="field">
<label>Current company</label>
<input placeholder="Current company" name="current_company" type="text">
</div>
</div>
<div class="two fields">
<div class="field">
<label>Annual salary</label>
<div class="ui selection dropdown">
<input name="annual_salary" type="hidden">
<div class="default text">annual_salary</div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="0">Less than 1 Lakh</div>
<div class="item" data-value="1">1 to 2 Lakh</div>
<div class="item" data-value="2">2 to 3 Lakh</div>
<div class="item" data-value="3">3 to 4 Lakh</div>
<div class="item" data-value="4">5 Lakh and above </div>
</div>
</div>
</div>
<div class="field">
<label>Working since</label>
<div class="ui calendar" id="date_work">
<div class="ui input left icon">
<i class="calendar icon"></i>
<input placeholder="Working since" name="working_since" type="text">
</div>
</div>
</div>
</div>
<div class="two fields">
<div class="field">
<label>Current location</label>
<input placeholder="Current location" name="current_location" type="text">
</div>
<div class="field">
<label>Duration of notice</label>
<div class="ui selection dropdown">
<input name="duration_of_notice" type="hidden">
<div class="default text">Duration of notice</div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="0">Less than 15 days</div>
<div class="item" data-value="1">15 days to 1 month</div>
<div class="item" data-value="2">1 to 2 month</div>
</div>
</div>
</div>
</div>
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<fieldset class="step">
<div class="two fields">
<div class="field">
<label>Skills</label>
<input placeholder="Skills" name="skills" type="text">
</div>
<div class="field">
<label>Passing year</label>
<div class="ui calendar" id="example8">
<div class="ui input left icon">
<i class="time icon"></i>
<input type="text" name="passing_year" placeholder="Year">
</div>
</div>
</div>
</div>
<div class="two fields">
<div class="field">
<label> Present address</label>
<input placeholder="Present address" name="address_1" type="text">
</div>
<div class="field">
<label> Permanent address</label>
<input placeholder="Permanent address" name="address_2" type="text">
</div>
</div>
<div class="two fields">
<div class="field">
<label>City</label>
<input placeholder="City" name="city" type="text">
</div>
<div class="field">
<label>State</label>
<input placeholder="State" name="state" type="text">
</div>
</div>
<div class="two fields">
<div class="field">
<label>Country</label>
<input placeholder="Country" name="country" type="text">
</div>
<div class="field">
<label>Certifications</label>
<input placeholder="Certifications" name="certifications" type="text">
</div>
</div>
<div class="field">
<label>Will relocate </label>
<div class="ui selection dropdown">
<input name="will_relocate" type="hidden">
<div class="default text">Will relocate</div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="0">Yes</div>
<div class="item" data-value="1">No</div>
</div>
</div>
</div>
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="submit" class="submit action-button" value="Submit" />
</fieldset>
</form>
jQuery
$(document).ready(function(){
var current = 1;
widget = $(".step");
btnnext = $(".next");
btnback = $(".previous");
btnsubmit = $(".submit");
// Init buttons and UI
widget.not(':eq(0)').hide();
hideButtons(current);
setProgress(current);
// Next button click action
btnnext.click(function(){
current_fs = $(this).parents();
next_fs = $(this).parent().widget;
if(current < widget.length){
// Check validation
if($(".form").valid()){
dataString = [];
$('#msform').ajaxForm({
type: "POST",
url: "main.php",
data:{data: $(dataString).serializeArray()},
dataType: "json",
cache: false,
});
widget.show();
$("#progressbar li").eq($("fieldset").index(setProgress(current))).addClass("active");
widget.not(':eq('+(current++)+')').hide();
setProgress(current);
}
}
hideButtons(current);
})
// Back button click action
btnback.click(function(){
current_fs = $(this).parent();
previous_fs = $(this).parent().btnback;
if(current > 1){
current = current - 2;
if(current < widget.length){
$("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
widget.show();
widget.not(':eq('+(current++)+')').hide();
setProgress(current);
}
}
hideButtons(current);
})
// Submit button click
btnsubmit.click(function(){
dataString = [];
$('#msform').ajaxForm({
type: "POST",
url: "main.php",
data:{data: $(dataString).serializeArray()},
dataType: "json",
cache: false,
success: function(){
alert("You have submitted form successfully");
// $("form")[0].reset();
}
});
});
$('#msform').validate({ // initialize plugin
ignore:":not(:visible)",
rules: {
first_name : { required: true, minlength: 3},
last_name : "required",
display_name : { required: true, minlength: 3},
user_name : { required: true, minlength: 3},
email: {
required: true,
email: true
},
password: {
required: true,
minlength: 5
},
dob : {
required: true,
},
gender : "required",
marital_status: "required",
highest_qualification:"required",
university_or_college: "required",
mobile:{
required:true,
minlength:10,
maxlength:10,
number: true
},
current_designation:"required",
current_company:"required",
annual_salary:"required",
working_since:"required",
current_location:"required",
duration_of_notice:"required",
skills:"required",
address_1:"required",
city:"required",
state:"required",
country:"required",
certifications:"required",
},
});
});
// Change progress bar action
setProgress = function(currstep){
current_fs = $(this).parent();
next_fs = $(this).parent().btnnext;
var percent = parseFloat(100 / widget.length) * currstep;
percent = percent.toFixed();
$(".progress-bar").css("width",percent+"%").html(percent+"%");
$("#progressbar li").eq($(".step").index(current_fs)).removeClass("active");
}
// Hide buttons according to the current step
hideButtons = function(current){
var limit = parseInt(widget.length);
$(".action").hide();
if(current < limit) btnnext.show();
if(current > 1) btnback.show();
if (current == limit) {
btnnext.hide();
btnsubmit.show();
}
}
PHP
$post_data = $_POST;
print_r($post_data);

Issue with submission form

I have created a PHP form and i want to add Data on my SQL
Please check my Code where is the Issue whay not working my Code
I want to add all this field on my PHPadmin
but when i enter details and click on Make a payment its not working
i also add form action="insert.php"
Here is Code
<div class="agileits_main_grid_right">
<div class="wthree_payment_grid">
<h2>Seleccione Método de pago</h2>
<div id="horizontalTab">
<ul class="resp-tabs-list">
<li><img src="images/1.jpg" alt=" " /></li>
<li><img src="images/2.jpg" alt=" " /></li>
</ul>
<div class="resp-tabs-container">
<div class="agileits_w3layouts_tab1">
<form action="insert.php" method="post" class="creditly-card-form agileinfo_form">
<section class="creditly-wrapper wthree, w3_agileits_wrapper">
<div class="credit-card-wrapper">
<div class="first-row form-group">
<div class="controls">
<label class="control-label">Name on Card</label>
<input class="billing-address-name form-control" type="text" name="name" placeholder="John Smith">
</div>
<div class="w3_agileits_card_number_grids">
<div class="w3_agileits_card_number_grid_left">
<div class="controls">
<label class="control-label">Card Number</label>
<input class="number credit-card-number form-control" type="text" name="number"
inputmode="numeric" autocomplete="cc-number" autocompletetype="cc-number" x-autocompletetype="cc-number"
placeholder="•••• •••• •••• ••••">
</div>
</div>
<div class="w3_agileits_card_number_grid_right">
<div class="controls">
<label class="control-label">CVV</label>
<input class="security-code form-control"·
inputmode="numeric"
type="text" name="security-code"
placeholder="•••">
</div>
</div>
<div class="clear"> </div>
</div>
<div class="controls">
<label class="control-label">Expiration Date</label>
<input class="expiration-month-and-year form-control" type="text" name="expiration-month-and-year" placeholder="MM / YY">
</div>
</div>
<button class="submit"><span>Make a payment <i class="fa fa-long-arrow-right" aria-hidden="true"></i></span></button>
</div>
</section>
</form>
</div>

How I can use securimage captcha for form submitted on same page ?

I wan to use securimage captcha for my drupal site,
I have one registration form and and I am submitting that form on same page.
Securimage configuration document says that (here) use session_start() on first line of form processor.
I am having both form and form processor on same page so where should I write session_start()?
This is my code
<form id="user_form" action="" method="post">
<div class="form">
<?php if (isset($errors) && count($errors)>0) : ?>
<ul class="error-list">
<?php foreach ($errors as $e) : ?>
<li><?php echo $e; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<div class="form-section">
<div class="col">
<div class="row">
<label class="two-rows">Select your<br />account type <span>*</span></label>
<select name="uf_user_type" style="width:173px;" class="required">
<option value="">None Selected</option>
<option value="<?php print JOB_SEEKER_ROLE; ?>">Job Seeker</option>
<option value="<?php print MASTER_EMPLOYER_ROLE; ?>">Employer</option>
</select>
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<label>First Name <span>*</span></label>
<input type="text" class="field required" name="uf_first_name" />
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<label>Last Name <span>*</span></label>
<input type="text" class="field required" name="uf_last_name" />
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<label>Email <span>*</span></label>
<input type="text" class="field required email-field" name="uf_mail" />
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<div class="cl"> </div>
</div>
<div class="row">
<label class="two-rows">Image <span>*</span></label>
<img id="captcha" src="/sites/all/themes/jobnow/site/securimage/securimage_show.php" alt="CAPTCHA Image" height="45" width="160" style="border:1px solid #b9b9b9"/>
<a href="#" onclick="document.getElementById('captcha').src = '/sites/all/themes/jobnow/site/securimage/securimage_show.php?' + Math.random(); return false">
<img src="/sites/all/themes/jobnow/site/securimage/images/refresh.png" height="30" width="30" alt="Reload Image" onclick="this.blur()" align="bottom" border="0">
</a>
</div>
</div>
<div class="col right-col">
<div class="row">
<label class="two-rows">How did you <br />hear about us? <span>*</span></label>
<select name="uf_hear_about_us" style="width:173px;" class="required">
<option value="">None Selected</option>
<option>Colleague/Friend</option>
<option>Search Engine</option>
<option>LinkedIn</option>
<option>Twitter</option>
<option>Facebook</option>
<option>Advertisement</option>
<option>In The News</option>
<option>Trade Show/Organization</option>
<option>Other</option>
</select>
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<p class="hint"><?php echo bfstring('hint_register_password'); ?></p>
<label>Password <span>*</span></label>
<input type="password" class="field required" id="pass1" name="uf_password" />
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<label class="two-rows">Confirm <br />Password <span>*</span></label>
<input type="password" class="field required" id="pass2" name="uf_password2" />
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<label class="labelBlack">
<input type="checkbox" class="check required" name="uf_terms" value="1" <?php if(isset($_POST['uf_terms']) && $_POST['uf_terms'] == 1) print 'checked'; ?> />
</label>
<p>I accept the Terms of Service.</p>
<div class="cl"> </div>
</div>
<div class="row">
<div class="cl"> </div>
</div>
<div class="row">
<label class="two-rows">What code is<br />in the image?<span>*</span></label>
<input type="text" class="field required" name="captcha_code" size="10" maxlength="6" />
<div class="cl"> </div>
<em class="status"></em>
</div>
</div>
<div class="cl"> </div>
</div>
<div>
</div>
<div class="form-actions">
<span class="required-info"><strong>*</strong> required</span>
<input type="submit" class="form-submit" value="Create Account" />
Cancel
<div class="cl"> </div>
</div>
</div>
</form>
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$securimage = new Securimage();
$isSecurImageValid=$securimage->check($_POST['captcha_code']) != false;
if ($validator->validateRules($_POST) && $isSecurImageValid)
{
$new_user = new stdClass();
$new_user->roles = array();
$username_base =strtolower(preg_replace('~(.*)\#.*~', '$1', site_rgpc($_POST['uf_mail'])));
$usernames = array();
}
else
{
$errors = $validator->getErrors();
if(!$isSecurImageValid)
$errors[]="The Security Code wasn't entered correctly.";
}
When I integrated this code on my site its saying your captcha is wrong for each and every attempt.
I am not getting what is the issue ?
Same code is working without session_start() on my another similar site.
Please help me

Two Forms In a HTML Document

I am having a form as below.
<div class="container">
<form method="post" action="index.php">
<div id="rule">
<div class="row">
<div class="span5">
<input type="text" class="input-xlarge" value="Rule Name"/>
</div>
<div class="span6">
<input type="text" class="input-xxlarge" value="Description"/>
</div>
<div class="clearfix"> </div>
</div>
</div>
<br />
<div id="sel" class="select">
<div class="row">
<div class="span1 offset2">
<p class="btn btn-danger">If</p>
</div>
<div class="span2">
<select class="span2" name="metrics">
<option value="bounce_rate">Bounce Rate</option>
<option value="location">Locations</option>
<option value="social_media">Social Media</option>
<option value="search">Search</option>
<option value="visits">Visitors</option>
</select>
</div>
<div class="span1">
<select name="conditions" class="span2">
<option value=">">></option>
<option value="<"><</option>
<option value=">=">>=</option>
<option value="<="><=</option>
<option value="=">=</option>
</select>
</div>
<div class="span1 offset1">
<input type="text" name="percentage" class="input-small"/>
</div>
<div class="clearfix"> </div>
</div>
<br />
<div class="row">
<div class="span1 offset2">
<p class="btn btn-danger">Period</p>
</div>
<div class="span3">
<div class="input-append date datepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
<input class="span2" size="16" type="text" value="12-02-2012" />
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="span3">
<div class="input-append date datepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
<input class="span2" size="16" type="text" value="12-02-2012" />
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="clearfix"> </div>
</div>
</div>
<div id="dyna"></div>
<div id="end">
<div class="row">
<div class="span1">
<p class="btn btn-danger">THEN</p>
</div>
<div class="span3">
<input type="text" class="input-xlarge" value="Statement" />
</div>
<div class="clearfix"> </div>
</div>
<div class="row">
<div class="span1">
<p class="btn btn-danger">ELSE</p>
</div>
<div class="span3">
<input type="text" class="input-xlarge" value="Statement" />
</div>
<div class="clearfix"> </div>
</div>
<div class="row">
<button class="span1 btn btn-success" type="submit" value="submit">Submit</button>
<div class="span2 offset9">
<p class="btn btn-success input-small" id="addRule">Add Rule </p>
</div>
<div class="clearfix"> </div>
</div>
</div>
</form>
</div>
I have included a button 'Add Rule' to create a dynamic elements within the above . So I used a javascript for creating dynamic elements as same of above.
The javascript as below.
<script type="text/javascript">
$('.datepicker').datepicker();
(function(){
var i = 0;
$("#addRule").live('click',function(){
++i;
var $ctrl = $('<div id="'+ i +'" class="select"><div class="row"><div class="span1 offset2"><button class="btn btn-danger">If</button></div><div class="span2"><select class="span2" name="metrics"><option value="bounce_rate">Bounce Rate</option><option value="location">Locations</option><option value="social_media">Social Media</option><option value="search">Search</option><option value="visits">Visitors</option></select></div><div class="span1"><select name="conditions" class="span2"><option value=">">></option><option value="<"><</option><option value=">=">>=</option><option value="<="><=</option><option value="=">=</option></select></div><div class="span1 offset1"><input type="text" name="percentage" class="input-small"/></div><div class="span2 offset1"><button class="btn btn-danger remove" id="'+ i +'">Remove</button></div><div class="clearfix"> </div></div><br /><div class="row"><div class="span1 offset2"><p class="btn btn-danger">Period</p></div><div class="span3"><div class="input-append date datepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy"><input class="span2" size="16" type="text" value="12-02-2012" /><span class="add-on"><i class="icon-th"></i></span></div></div><div class="span3"><div class="input-append date datepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy"><input class="span2" size="16" type="text" value="12-02-2012" /><span class="add-on"><i class="icon-th"></i></span></div></div><div class="clearfix"> </div></div></div>');
$("#dyna").append($ctrl);
$('.datepicker').datepicker();
});
}) ();
(function(){
$(".remove").live('click',function(){
var remDiv = $(this).attr('id');
//var questionList = "questionList"+remQ;
$("#" + remDiv).remove();
});
}) ();
So I wanna get the values once i click the submit button. Is it correct way what i am using only a form for fetching the data or am i create two forms separately? So how to do that?
You do not need to create a second form if you are inserting the new elements into the existing form and as long as they have different names from any existing inputs you want to receive.
You can create a second form if you want different submit buttons for the two different collections of input data.

Categories