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

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>

Related

PHP Session Vairables for Checkout/basket system

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.

Padding and class col-md not working

I am trying to shift my radio button to the right for this certain part for a long time and it still doesn't work, I try using padding and class col-md for it and even check if my tag are closed but it is still not moving to the right. Can anybody help me with this problem? Thanks in advance.
test.blade.php
<div class="form-group">
<label class="col-md-2"><b>Residential Status:</b></label>
<div class="col-md-8">
<input type="radio" name="residential_status" value="Local" required> Local<br>
<input type="radio" name="residential_status" value="Overseas" required> Overseas<br>
</div>
</div>
<div class="form-group">
<div class="editfield1">
<div class="radio">
<div id="chkNRICid1">
<label style="font-weight: bold">Do you have a NRIC?</label> <br/>
<input type="radio" name="NRIC_check" id="nricid1" value="Yes" onclick="document.getElementById('NRIC_check').style.display='block'" required> Yes <br>
<input type="radio" name="NRIC_check" id="nricid2" value="No" onclick="document.getElementById('NRIC_check').style.display='none'" required> No
</div>
</div>
</div>
<div class="editfield1" id="NRIC_check" style="display:none">
<label for="NRIC_check"> Type your NRIC/FIN number:</label>
<label><input type="text" name="nric_number1" id="nric_number1"> </label>
</div>
</div>
This is the screenshot of what is happening: (I want it to be like the Residential Status)
So many wayward and un-needed divs you can get rid of along with fixing your nesting, after that it's just a matter of following the structure in the first part of your template:
<div class="form-group">
<div class="col-md-2">
<label>Residential Status</label>
</div>
<div class="col-md-10">
<label><input type="radio" name="residential_status" value="Local" required> Local</label>
<br />
<label><input type="radio" name="residential_status" value="Overseas" required> Overseas</label>
</div>
</div>
<div class="form-group">
<div class="col-md-2">
<label>Do you have a NRIC?</label>
</div>
<div class="col-md-10">
<label><input type="radio" name="NRIC_check" id="nricid1" value="Yes" onclick="document.getElementById('NRIC_check').style.display='block'" required>Yes</label>
<br />
<label><input type="radio" name="NRIC_check" id="nricid2" value="No" onclick="document.getElementById('NRIC_check').style.display='none'" required> No </label>
</div>
</div>
<div class="form-group" id="NRIC_check" style="display:none">
<div class="col-md-2">
<label>Type your NRIC/FIN number:</label>
</div>
<div class="col-md-10">
<input type="text" name="nric_number1" id="nric_number1" />
</div>
</div>
Wrap the two inputs inside a <div> and add some margin.
<div style="margin-left: 50px">
<input ... />
<input ... />
</div>
If you are using Bootstrap 4 you could even:
<div class="ml-5">

$_POST method turns empty

Firstable, hello everyone. I have issue about the $_POST method, when I write this code block;
if (isset($_POST['menuduzenle'])) {
$menu_id=$_POST['menu_id']; //It didn't turn with value in mysql
$ayarguncelle=mysql_query("update menuler set menu_ad='".$_POST['menu_ad']."',menu_link='".$_POST['menu_link']."'where menu_id='$menu_id'");
if(mysql_affected_rows())
{
header("Location:../menuleriduzenle.php?guncelleme=basarili&menu_id=$menu_id");
}else{
header("Location:../menuleriduzenle.php?guncelleme=basarisiz&menu_id=$menu_id");}
}
menu_id turns emty, what I need to do for solve this?
and here it's html code
form
<form action="network/islem.php" method="POST">
<div class="col-md-12">
<div class="form-group col-md-9">
<label>Menu Adı: </label>
<input class="form-control" name="menu_ad" value="<?php echo $menucek['menu_ad']; ?>" />
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-9">
<label>Menu Link: </label>
<input class="form-control" name="menu_link" value="<?php echo $menucek['menu_link']; ?>" />
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-6">
<input class="btn btn-primary col-md-3" type="submit" name="menuduzenle" value="Edit Menu">
</div>
</form>
and
<td><button class="btn btn-primary col-md-12">Edit</button></td>
You not send any one input with name 'menu_id' on your from.
<form action="network/islem.php" method="POST">
<div class="col-md-12">
<div class="form-group col-md-9">
<label>Menu Adı: </label>
<input class="form-control" name="menu_ad" value="<?php echo $menucek['menu_ad']; ?>" />
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-9">
<label>Menu Link: </label>
<input class="form-control" name="menu_link" value="<?php echo $menucek['menu_link']; ?>" />
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-6">
<input class="btn btn-primary col-md-3" type="submit" name="menuduzenle" value="Edit Menu">
</div>
<input type="hidden" name="menu_id" value="<?php echo $_GET['menu_id'] ?>" />
</form>
You input name "menu_ad" would be "menu_id" or fault other input with name "menu_id" on you sample.

How to pass html codes in the values of text in a form and display it

So i've updated the codes.
i'm trying to make a radio box so when yes is checked on the radio box a textbox appears using angular.js hoping it would work.
<div ng-app="">
<div class="form-group">
<label class="control-label col-sm-2">Experience:</label>
<div class="col-sm-2">
<input type="radio" name="emp_experience" ng-model="experience" value='
<div class="form-group">
<label class="control-label col-sm-2">Experience Years:</label>
<div class="col-sm-4">
<input type="text" name="emp_exp_y" class="form-control" placeholder="Years">
</div>
</div>'
required />Yes
</div>
<div class="col-sm-2">
<input type="radio" name="emp_experience" ng-model="experience" value=" " required />No
</div>
<?php $a = "{{experience}}";
echo <<<EOD $a
EOD;
?>
</div>
</div>
I want the output to generate a textbox when yes is clicked but all I get is the code itself
<div class="form-group"><div class="col-sm-4"><input type="text" name="emp_exp_y" class="form-control" placeholder="Years"> </div></div>

I have 2 forms, the first form contains read only information, how do I update it using the second form input box with a link tag for submit

I have 2 forms, containing employee information that is readOnly=true
My second form contains, input box to replace and update the data inside the first form. My update is a link tag instead of button.
1st Form
<form class="secondtdr" name="updatein">
<h4 class="ua">Referrer Personal Information</h4>
<div class="referrerid">
<p align="left">Referrer ID</p>
<input type="text" name="cont" value="<?php echo $contact_no; ?>" readOnly="true">
</div>
<div class="empnum">
<p align="left">Employee Number</p>
<input type="number" name="cont" value="<?php echo $empid; ?>" readOnly="true">
</div>
2nd Form
<form class="tabletoedit" method="post">
<br>
<div class="empnum">
<p align="left">Employee Number</p><br>
<input type="number" name="cont" value="">
</div>
<div class="fnamep">
<p align="left">Fullname</p>
<input type="text" name="cont" value="">
</div>
<div class="action_btns">
<div class="one_half">
Update
</div>
</div>
</form>
You can achieve it by writing some javascript codes,like this(codes below are not tested).
<script>
function updateData()
{
document.getElementById('form1_employee_num').value = document.getElementById('employee_num').value;
...
//if you wan to update the new data to database,you can use AJAX
}
</script>
form 1
<form class="secondtdr" name="updatein">
<h4 class="ua">Referrer Personal Information</h4>
<div class="referrerid">
<p align="left">Referrer ID</p>
<input type="text" name="cont" value="<?php echo $contact_no; ?>" readOnly="true" id="form1_referrer_id">
</div>
<div class="empnum">
<p align="left">Employee Number</p>
<input type="number" name="cont" value="<?php echo $empid; ?>" readOnly="true" id="form1_employee_num">
</div>
form2
<form class="tabletoedit" method="post">
<br>
<div class="empnum">
<p align="left">Employee Number</p><br>
<input type="number" name="cont" value="" id="employee_num">
</div>
<div class="fnamep">
<p align="left">Fullname</p>
<input type="text" name="cont" value="" id="fullname">
</div>
<div class="action_btns">
<div class="one_half">
Update
</div>
</div>
</form>

Categories