form to paypal payment values not passing - php

I am using this form to pass values to paypal payment.
<form style="padding: 20px; border: 2px solid #f00; background: #fff; box-shadow: 10px 10px 20px -5px #000; border-radius: 10px; font-size:15px;" action="https://www.paypal.com/cgi-bin/webscr" method="POST">
<div class="form-row">
<div class="form-group col-md-12 mx-auto text-center">
<h3 class="text-uppercase">Please Confirm Your Payment</h3>
</div>
</div>
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="paypaltestgmail.com">
<input type="hidden" name="quantity" value="1">
<div class="form-row">
<div class="form-group col-md-4">
<label for="fullName">Full Name</label>
<input type="text" class="form-control" id="fullName" value="<?php echo $firstName . ' ' . $lastName; ?>" name="fullName" disabled="disabled">
</div>
<div class="form-group col-md-4">
<label for="email">Email</label>
<input type="text" class="form-control" id="email" value="<?php echo $email; ?>" name="email" disabled="disabled">
</div>
<div class="form-group col-md-4">
<label for="age">Age</label>
<input type="text" class="form-control" id="age" value="<?php echo $age; ?>" name="age" disabled="disabled">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="sessionType">Session Type</label>
<input type="text" class="form-control" id="sessionType" value="<?php echo $sessionType; ?>" name="item_name" disabled="disabled">
</div>
<div class="form-group col-md-4">
<label for="sessionDays">Session Days</label>
<textarea class="form-control" id="sessionDays name="sessionDays" disabled="disabled"><?php echo $sessionDays; ?></textarea>
</div>
<div class="form-group col-md-4">
<label for="sessionTime">Session Time</label>
<textarea class="form-control" id="sessionTime" name="sessionTime" disabled="disabled"><?php echo implode(', ', $_POST['sessionTime']); ?></textarea>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="totalCost">Total Cost</label>
<input type="text" class="form-control" id="totalCost" value="<?php echo $totalCost; ?>" name="totalCost" disabled="disabled">
</div>
<div class="form-group col-md-4">
<label for="totalTax">Tax Amount</label>
<input type="text" class="form-control" id="totalTax" value="<?php echo $totalTax; ?>" name="totalTax" disabled="disabled">
</div>
<div class="form-group col-md-4">
<label for="grandTotal">Grand Total</label>
<input type="text" class="form-control" id="grandTotal" value="<?php echo $grandTotal; ?>" name="amount" disabled="disabled">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<!-- <input type="hidden" name="bn" value="BuyNow"> -->
<input type="hidden" name="return" value="http://www.example.net/payment-success/">
</div>
</div>
<button type="submit" class="btn btn-primary btn-lg d-block mx-auto text-uppercase">Confirm & Pay</button>
And I am getting this result:
I am getting quantity but not getting $sessionType; in description field and $grandTotal; in price per item (total) field. I am doing this first time. What mistake is there in my form? I am not being able to solve the issue.

Use the magic of the readonly attribute:
This attribute indicates that the user cannot modify the value of the
control. The value of the attribute is irrelevant. If you need
read-write access to the input value, do not add the "readonly"
attribute. It is ignored if the value of the type attribute is hidden,
range, color, checkbox, radio, file, or a button type (such as button
or submit).

Related

I want to update the recorded in data base. I want to send the "employee_id" on clicking save button. so that corresponding 'id' recorded is updated

I want to update the record of the corresponding id that is sent on clicking save button. I tried button tage, input tage and link tage but there is some mistake that I am making, but I don't know where?
This is my form
<form method="POST" action="handle_update.php">
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">First name</label>
<input type="text" name="fname" value="'.$first_name.'" class="form-control" >
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Last name</label>
<input type="text" name="last_name" value="'.$last_name.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Email</label>
<input type="email" name="email" value="'.$email.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Designation</label>
<input type="text" name="designation" value="'.$designation.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Address</label>
<input type="address" name="address" value="'.$address.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Date of Joining</label>
<input type="date" name="joining_date" value="'.$joining_date.'" class="form-control">
</div>
<a name="update" role = "button" type="submit" href="handle_update.php?ployee_id='.$id2.'">Save</a>
</form>
Add a hidden input field that holds the value you want to submit. Change your <a> to a <button> that can submit your form. Change your code to:
<form method="POST" action="handle_update.php">
<input type="hidden" name="ployee_id" value="' . $id2 . '">
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">First name</label>
<input type="text" name="fname" value="'.$first_name.'" class="form-control" >
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Last name</label>
<input type="text" name="last_name" value="'.$last_name.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Email</label>
<input type="email" name="email" value="'.$email.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Designation</label>
<input type="text" name="designation" value="'.$designation.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Address</label>
<input type="address" name="address" value="'.$address.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Date of Joining</label>
<input type="date" name="joining_date" value="'.$joining_date.'" class="form-control">
</div>
<button type="submit" name="update">Save</button>
</form>
More on forms: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form
More on hidden inputs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/hidden

Cant Submit Textarea Tinymce

I can't submit form textarea TinyMCE. I need to be able to use many TinyMCE's, but my code only works if I don't have any.
please help me..
this is code :
<form action="action/insert.php?table=<?= $page ?>" method="post" enctype="multipart/form-data">
<div class="form-group">
<label class="control-label" for="item">Languange</label><br/>
<label for="en"><input type="radio" name="newlang" id="en" value="en"/> English</label>
<label for="id"><input type="radio" name="newlang" id="id" value="id"/> Indonesia</label>
</div>
<div class="form-group">
<label class="control-label" for="item">Item</label>
<input type="text" name="item" id="item" value="" class="form-control" required/>
</div>
<div class="form-group">
<label class="control-label" for="code">Code</label>
<input type="text" name="code" id="code" value="" class="form-control" required/>
</div>
<div class="form-group">
<label class="control-label" for="ingred">Ingredient</label>
<textarea name="ingred" id="ingred" required></textarea>
</div>
<div class="form-group">
<label class="control-label" for="spec">Spec</label>
<textarea name="spec" id="spec" required></textarea>
</div>
<div class="form-group">
<label class="control-label" for="package">Package</label>
<textarea name="package" id="package" required></textarea>
</div>
<div class="form-group">
<label class="control-label" for="price">Price</label>
<input type="number" name="price" id="price" value="" min="0" class="form-control" required/>
</div>
<div class="form-group">
<label class="control-label" for="file">Image</label>
<input type="file" name="file" id="file" class="form-control"/>
</div>
<hr>
<div class="form-group">
<button type="submit" name="submit" class="btn btn-success"><i class="fa fa-check-circle"></i> Add</button>
<button type="reset" name="reset" class="btn btn-default"><i class="fa fa-refresh"></i> Reset</button>
<button type="button" name="back" class="btn btn-default" onclick="location.assign('?page=<?= $page ?>/')"><i class="fa fa-reply"></i> Back</button>
</div>
I have to add a space between the textarea
How are you actually submitting the content of the editor here? Your first step would be to call editor.getcontent() somewhere.
https://www.tinymce.com/docs/api/tinymce/tinymce.editor/#getcontent

Place error message inside a Bootstrap input

I have a PHP that validates if a input is empty if it is an error message is displayed e.g Email required, I am using Bootstrap for my form. Originally the message is displayed under the input (which I don't want).
Code im currently using:
<label>Number Of Rooms: </label>
<input type="number" class="form-control input-sm" max="10" name="Rooms" value="<?php echo $RoomErr;?>">
<span class="error">* <br><?php echo $RoomErr;?></span>
here is the link to the website website
I want to display the error message inside the text input i tried assigning the error to the value of the input:
<label>Number Of Rooms: </label>
<input type="number" class="form-control input-sm error" max="10" name="Rooms" value="<?php echo $RoomErr;?>">
The following does not work.
My CSS just assigns the error to color red
.error{
color:red;
}
I can't find much stuff about this.
You can try like this, because it is working as a placeholder.
<input type="number" class="form-control input-sm error" max="10" name="Rooms" placeholder="<?php echo $RoomErr;?>">
Please try this. I am using position:absolute; And manage this
label {
display: inline-block;
margin-left: 20px;
width: 135px;
}
.error {
color: red;
}
.form-group .error {
left: 165px;
position: absolute;
top: 5px;
}
.form-group{position:relative;}
.form-inline .form-control{display: inline-block;
vertical-align: middle;
width: auto;}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<div class="col-md-9">
<div class="container-form">
<p><span class="error">* required field.</span></p>
<form id="EmailForm" class="form-horizontal" action="" method="post">
<div class="form-inline">
<div class="form-group" style="position: relative;">
<label for="first_name">Name: </label>
<input class="form-control input-sm" name="first_name" type="text">
<span class="error">*Name is required</span>
</div>
</div>
<div class="form-inline">
<div class="form-group">
<label for="last_name">SurnameName: </label>
<input class="form-control input-sm" name="last_name" type="text">
<span class="error">*</span>
</div>
</div>
<div class="form-inline">
<div class="form-group">
<label for="email">Email: </label>
<input class="form-control input-sm" name="email" type="text">
<span class="error">* Email is required</span>
</div>
</div>
<div class="form-inline">
<div class="form-group">
<label>Number Of Rooms: </label>
<input class="form-control input-sm" max="10" name="Rooms" value="Mininum number of Hours : 3" type="number">
<span class="error">* Mininum number of Hours : 3</span>
</div>
</div>
<div class="form-inline">
<div class="form-group">
<label> Number hours: </label>
<input class="form-control input-sm" min="3" name="Hours" type="number">
<span class="error">* Mininum number of Hours : 3</span>
</div>
</div>
<div class="form-inline">
<div class="form-group">
<label for="description">Description of the House: </label>
<textarea name="description" rows="auto" class="form-control input-sm" cols="55"></textarea>
<span class="error">* Description is required</span>
</div>
</div>
<div class="form-inline">
<div class="form-group">
<div class="radio" style="margin-left:70px">
<input name="ironing" id="radiobtn" value="Yes" type="radio">
Yes
</div>
<div class="radio">
<input name="ironing" id="radiobtn" value="No" type="radio">
No
</div>
<span class="error">* Ironing is Required</span>
<span class="help-block" style="margin-left:50px">Would Like Ironing?</span>
</div>
</div>
<input class="btn btn-info btn-lg" name="submit" value="Submit" type="submit">
</form>
</div>
</div>

undefined index in php using post but it can echo the value using request on update.php

I have these two files and i am updating a table but on the update.php file i get error saying Notice: Undefined index: pname , $pcode...... $pname = $_POST["pname"]; here i am storing pname value in pname variable.but it shows error
<address>
<div class="control-group">
<label class="control-label">Product Name:</label>
<div class="controls">
<input id="pname" name="pname" type="text" value="<?php echo $PName; ?>"
class="input-xlarge">
<p class="help-block"></p>
</div>
</div>
<div class="control-group">
<label class="control-label">Product Code:</label>
<div class="controls">
<input id="code" name="pcode" type="text" value="<?php echo $PCode; ?>"
class="input-xlarge">
</div>
</div>
<div class="control-group">
<label class="control-label">Product Price:</label>
<div class="controls">
<input id="price" name="pprice" type="text" value="<?php echo $PPrice; ?>"
class="input-xlarge">
</div>
</div>
<div class="control-group">
<label class="control-label">Availability:</label>
<div class="controls">
<select id="stock" name="stock" class="input-xlarge">
<option value="1" selected="selected">Available</option>
<option value="0">Not Available</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label">Product Description:</label>
<div class="controls">
<textarea rows="4" cols="50" name="description" > <?php echo $PDescription; ?> </textarea>
</div>
</div>
<div class="control-group">
Picture 1 :
<div class="controls">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<input type="file" name="pic1"
class="input-xlarge">
</div>
</div>
<div class="control-group">
Picture 2 :
<div class="controls">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<input type="file" name="pic2"
class="input-xlarge">
</div>
</div>
<div class="control-group">
Picture 3 :
<div class="controls">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<input type="file" name="pic3"
class="input-xlarge">
</div>
</div>
<div class="control-group">
<div class="controls">
<input type='hidden' name='id' value="<?php echo $ID; ?>"><br/>
<input type="submit" value="UPDATE" class="btn-large" />
</div>
</div>
</form>
Do you check for form submit?
if (isset($_POST["pname"])) {
// do all your form processing here.
}
$pname= (isset($_POST["pname"]) ? $_POST["pname"] : "");
this will check if pname exists in $_POST and then sets it.
you receive that error because you dont have set $_POST["pname"]

Reset button using JavaScript is not working after validating the form using Ajax

I have a "create user"form with reset and create button. This reset button is not working for some drop-downs in the form.
In addition, reset button is not clearing all the values in the form after validation. It only clears the values entered after validation.
Here is my code:
<div class="form-action clearfix">
<button type="button" onClick="clearForm()" > Reset </button>
<button class="button" type="button" id="button" onclick="doAjax('index.php/users/createUser', convertFormJson('#createUserForm'));">Create</button>
and
function clearForm() {
document.getElementById('createUserForm').reset();
}
Form:
<?php echo validation_errors(); ?>
<div class="container_12 clearfix leading" >
<div class="grid_12">
<!--<form class= "form has-validation">-->
<?php
$attributes = array('class' => 'form has-validation', 'id' => 'createUserForm');
echo form_open('/users/createUser', $attributes);
?>
<div class="clearfix">
<label for="form-name" class="form-label">First Name <em>*</em></label>
<div class="form-input">
<input type="text" id="form-name" name="firstname" required="required" placeholder="Enter the first name" value="<?php echo set_value('firstname'); ?>" />
</div>
</div>
<div class="clearfix">
<label for="form-name" class="form-label">Last Name <em>*</em></label>
<div class="form-input">
<input type="text" id="form-name" name="lastname" required="required" placeholder="Enter the last name" value="<?php echo set_value('lastname'); ?>"/>
</div>
</div>
<div class="clearfix">
<label for="form-email" class="form-label">Email <em>*</em></label>
<div class="form-input"><input type="email" id="form-email" name="email" required="required" placeholder="A valid email address" value="<?php echo set_value('email'); ?>"/></div>
</div>
<!--
<div class="clearfix">
<label for="form-birthday" class="form-label">Birthdate</label>
<div class="form-input"><input type="date" id="form-birthday" name="date" placeholder="mm/dd/yyyy" value="<?php //echo set_value('date'); ?>" class="date"/></div>
</div>
-->
<div class="clearfix">
<label for="form-username" class="form-label">Username <em>*</em></label>
<div class="form-input">
<?php echo form_error('username'); ?>
<input type="text" id="form-username" name="username" value="<?php echo set_value('username'); ?>" required="required" maxlength="30" placeholder="Alphanumeric (max 30 char.)" />
</div>
</div>
<div class="clearfix">
<label for="form-password" class="form-label">Password <em>*</em></label>
<div class="form-input">
<?php echo form_error('password'); ?>
<input type="password" id="form-password" name="password" value="<?php echo set_value('password'); ?>" maxlength="30" placeholder="Min 8 char. containing a capital, number and/or symbol" />
</div>
</div>
<div class="clearfix">
<label for="form-password-check" class="form-label">Password check <em>*</em></label>
<div class="form-input">
<?php echo form_error('passconf'); ?>
<input type="password" id="form-password-check" name="passconf" value="<?php echo set_value('passconf'); ?>" data-equals="password" maxlength="30" placeholder="Re-enter your password" />
</div>
</div>
<div class="clearfix">
<label for="form-group" class="form-label">Group <em>*</em></label>
<div class="form-input">
<?php
$groupsData[' '] = "--";
$groupJs = 'id="form-group"';
echo form_dropdown('groupId', $groupsData,' ',$groupJs);
?>
</div>
</div>
<div class="clearfix">
<label for="form-language" class="form-label" >Language <em>*</em></label>
<div class="form-input">
<select id="form-language" name="language">
<option value ="" > -- </option>
<option value ="1">English</option>
<option value ="2">French</option>
</select>
</div>
</div>
<div class="clearfix">
<label for="form-timezone" class="form-label" >Timezone <em>*</em></label>
<div class="form-input">
<?php echo timezone_menu('UM5', 'form-timezone'); ?>
</div>
</div>
Please help me out.

Categories