Input stepping down - php

I'm having a step down issue with my registration form, I've tried everything I can find on google but nothing works.
My DOB section is split into 3 different input boxes, I'm trying to get the right column up beside the left but as soon as I put any styling on it, the year section steps down.
I've tried so many different variations; Float, display, nothing works. Also I've added extra boxes and it's always after the first 2 boxes the step down happens.
When I try to style, notice the year step down:
Always steps down after 2 no matter what order:
HTML code:
<div id="regforms">
<form method="post" action="register.php" name="registerform" id="registerform">
<fieldset2>
<div id="regforms1">
<label for="username"></label><input type="text" name="username" id="username" placeholder="Username"/><br />
<label for="password"></label><input type="password" name="password" id="password" placeholder="Password"/><br />
<label for="email"></label><input type="text" name="email" id="email" placeholder="Email"/><br />
<input type="submit" name="register" id="login" value="Register" />
</div>
<div id="regforms2">
<label for="name"></label><input type="text" name="name" id="name" placeholder="Name"/><br />
<div id="dob">
<label for="dobm"><input type="text" name="month" id="month" placeholder="MM"/><br />
<label for="dobd"><input type="text" name="day" id="day" placeholder="DD"/><br />
<label for="dobd"><input type="text" name="day" id="day" placeholder="DD"/><br />
<label for="dobd"><input type="text" name="day" id="day" placeholder="DD"/><br />
<label for="doby"><input type="text" name="year" id="year" placeholder="YYYY"/><br />
</div>
</div>
</fieldset3>
</form>
</div>
CSS:
#regforms {
margin-top:200px;
border: 0;
display:block;
width:600px;
}
#regforms1 {
padding-right:25px;
width:275px;
float:left;
}
#regforms2 {
width:275px;
float:right;
}
#dob {
}
#month{
width:5%;
margin-right:5px;
}
#day{
width:10%;
margin-right:5px;
}
#year{
width:10%;
margin-right:5px;
}

As Aligarian said, you just need to remove the <br/> tag, although you don't seem to be closing the <label> tags in the DOB fields; you should close them.

Related

I am trying to get value from radioButton but something happening wrong

I have tried so many times in different ways to solve this. Every time it generates the same output. I searched in [http://google.com] and [http://youtube.com] and followed many tutorials, and implemented my code according them..Their code runs properly but my code gives unknown output, though their code and my code is same.
This is the PHP code:
if(!isset($_POST["radio"])){
$radioMsg="You must Select a Category!";
}
if(isset($_POST["radio"])){
$radio=$_POST["radio"];
}
There is the radio Buttons
<form method="post" action="register.php" enctype="multipart/form-data"
style="width: 860px;margin: 0px;height: 580px;">
<input class="form-control" type="" name="name" placeholder="Name..."/
style="width: 400px; margin-left: 200px" ><br>
<input class="form-control" type="email" name="email"
placeholder="Email..."/ style="width: 400px; margin-left: 200px" ><br>
<input class="form-control" type="password" name="password"
placeholder="Password"/ style="width: 400px; margin-left: 200px" ><br>
<input class="form-control" type="password" name="cPassword"
placeholder="
confirm Password..."/ style="width: 400px; margin-left: 200px" ><br>
<input class="form-control" type="text" name="contactNO"
placeholder="Your
contact No.."/ style="width: 400px; margin-left: 200px" ><br>
<input type="file" name="image"/ style="width: 400px; margin-left:
200px">
<br><br>
<div style="border: 1px solid #4C6A6D;width: 250px;margin-left: 200px" >
<?php echo $radioMsg ?>
<h6 style="margin-left: 20px">Select a Cetagory</h6>
<input type="radio" name="radio" value="customer" style="margin-left:
25px">Customer<br>
<input type="radio" name="radio" value="DespensaryOwner" style="margin-
left:
25px">Despensary Owner<br>
input type="radio" name="radio" value="dealer" style="margin-left:
25px">Dealer<br>
</div>
<br>
<input class="btn-primary" type="submit" name="submit" value="Register"
style=" margin-left: 200px"><br><br>
</form>
if select radioButton1, it returns a value "radio" instead of value "customer"
Input type cannot be "cust":
<input type="radio" name="g" value="customer" style="margin-left:
25px">Customer<br>
<input type="radio" name="g" value="DespensaryOwner" style="margin-left:
25px">Despensary Owner<br>
<input type="radio" name="g" value="dealer" style="margin-left:
25px">Dealer<br>enter code here
Try code above and see if that works, also you should use better name values as suggested in the comments of this answer
I went ahead and ran this locally, by putting it all in a file called "register.php" in the root of a PHP dev server instance, with the PHP code at the top. In that situation, it spits out the error until a valid value is put in, but I imagine you're handling things differently.
I had to remove a number of strange forward slashes and line returns in your HTML, there were missing < and >, and your radio buttons were all named "radio", but after correcting those errors, the code below works:
PHP: (Included PHP tags for completeness)
<?php
if(!isset($_POST["category"])){
$radioMsg="You must Select a Category!";
}
if(isset($_POST["category"])){
$radioMsg="";
$radio=$_POST["category"];
}
?>
HTML: (Included entire html layout for completeness.)
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form method="post" action="register.php" enctype="multipart/form-data" style="width: 860px;margin: 0px;height: 580px;">
<input class="form-control" type="" name="name" placeholder="Name..." style="width: 400px; margin-left: 200px" ><br>
<input class="form-control" type="email" name="email" placeholder="Email..." style="width: 400px; margin-left: 200px" ><br>
<input class="form-control" type="password" name="password" placeholder="Password" style="width: 400px; margin-left: 200px" ><br>
<input class="form-control" type="password" name="cPassword" placeholder="confirm Password..." style="width: 400px; margin-left: 200px" ><br>
<input class="form-control" type="text" name="contactNO" placeholder="Your contact No.." style="width: 400px; margin-left: 200px" ><br>
<input type="file" name="image" style="width: 400px; margin-left: 200px">
<br><br>
<div style="border: 1px solid #4C6A6D;width: 250px;margin-left: 200px" >
<?php echo $radioMsg ?>
<h6 style="margin-left: 20px">Select a Category</h6>
<input type="radio" name="category" value="customer" style="margin-left: 25px">Customer<br>
<input type="radio" name="category" value="DispensaryOwner" style="margin-left: 25px">Dispensary Owner<br>
<input type="radio" name="category" value="dealer" style="margin-left: 25px">Dealer<br>
</div>
<br>
<input class="btn-primary" type="submit" name="submit" value="Register"
style=" margin-left: 200px"><br><br>
</form>
</body>
</html>

html form-- need help having new input area populate if radio button is clicked

I am making a basic new customer database with mysql and php. I would like when people click on the radio button"different mailing address" for another couple of input fields to appear for the mailing address. Im not quite sure how to handle this with inputs and not variables. Is there a way to do an if statement here is my html form code below
<form method="POST" action="insert.php">
<fieldset>
<legend>New Customer data</legend>
<label>Complete Below</label>
<div class="controls controls-row">
<input class="span4" name="firstname" type="text" placeholder="First name">
<input class="span3" name="lastname" type="text" placeholder="Last Name">
<input class="span3" name="phone" type="text" placeholder="Phone">
</div>
<div class="controls controls-row">
<input class="span4" name="address" type="text" placeholder="Address">
<input class="span2" name="city" type="text" placeholder="City">
<input class="span1" name="state" type="text" placeholder="State">
</div>
<div class="controls controls-row">
<input class="span4" name="zip" type="text" placeholder="Zip Code">
<input class="span2" name="email" type="text" placeholder="Email">
<input class="span2" name="ccemail" type="text" placeholder="cc email">
</div>
<span class="help-block">When is the customers due date monthly</span>
<label class="radio">
<input type="radio" name="duedate" id="optionsRadios1" value="1" checked>
1st of the month</label>
<label class="radio">
<input type="radio" name="duedate" id="optionsRadios2" value="15">
15th of the month
</label>
<span class="help-block">Mailing address</span>
<label class="radio">
<input type="radio" name="mailingaddress" id="optionsRadios3" value="1" checked>
Check if mailing address is the same as the service address
</label>
<label class="radio">
<input type="radio" name="mailingaddress" id="optionsRadios4" value="0">
Check if mailing address is different
</label>
<button type="submit" class="btn btn-primary">Submit</button>
</fieldset>
</form>
Using jQuery, have two inputs that are initially hidden. Once the user checks the box, '$.show()' on those two inputs. Id have a div containing two inputs, and just show or hide the div depending on whether the box is checked or not
you can try this.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" >
</script>
<script>
$(document).ready(function(){
$("#checkme").on('change',function(){
if($("#checkme").is(":checked")){
$("input#myemail").fadeIn();
}else{
$("input#myemail").fadeOut();
}
});
});
</script>
</head>
<body>
show: <input type="checkbox" id="checkme" /><br />
<input type="text" id="myemail" hidden />
</body>
</html>

AngularJS | How to Send the Data of Json to database in Codeigniter

I am trying to use Angular.
I am trying to Post Form of Angular, which have been done successfully, it is posting in JSON, But Problem is it only Post the input fields which have values, if i have NOT filled a textbox then it will NOT post that textbox value and fieldname, so how to know in controller which input fields have been posted.
Also how to send it to the model??
Here what i have done so far.
View.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
<link href="<?php echo base_url(); ?>/styles/formcss.css" rel="stylesheet" type="text/css"/>
<script src="<?php echo base_url(); ?>/scripts/angular.min.js"></script>
</head>
<body ng-app>
<div ng-controller="controller">
<form>
<label for="name">UserID:</label> <input type="text" name="UserID" ng-model="user.UserID" value=""><br>
<label for="UserName">Name:</label> <input type="text" name="UserName" ng-model="user.UserName" value=""><br>
<label for="rollno">In Game Name:</label> <input type="text" name="GameName" ng-model="user.InGameName" value="" ><br>
<label for="father">CNIC Number:</label> <input type="number" name="Cnic" ng-model="user.Cnic" value="" ><br>
<label for="age">Age:</label> <input name="Age" ng-model="user.Age" type="number" value="" ><br>
<label for="email1">Email:</label> <input name="Email" ng-model="user.Email" type="email" value="" ><br>
<label for="email2">Res enter Email:</label> <input id="email2" type="email" name="email2" value="" ><br>
<label for="pass1">Password:</label> <input id="pass1" type="password" name="Pass" ng-model="user.Password" value=""><br>
<label for="pass2">Re enter Password:</label> <input id="pass2" type="password" name="pass2" value="" ><br>
<label style="margin-bottom:-10px; " for="male">Male</label><input class="gen" ng-model="user.Gender" id="male" type="radio" name="g" value="Male"><br>
<label style="margin-bottom:15px;" for="female">Female</label><input class="gen" ng-model="user.Gender" id="female" type="radio" name="g" value="Female"><br>
<label class="dis" for="about" >About:</label> <textarea rows="5" cols="40" id="about" type="text" value=""></textarea><br>
<button style="margin-left: 225px;" ng-click="save()" >Save</button>
</form>
</div>
<script>
function controller ($scope,$http)
{
var angularform="<?php echo base_url(); ?>index.php/datacon/angform"
$scope.save=function()
{
$http.post(angularform, $scope.user);
}
}
</script>
</body>
</html>
Controller:
public function angform()
{
$get=file_get_contents('php://input');
$json_get=json_decode($get);
foreach($json_get as $key=>$value){
// i think something it has to do here.
}
$this->load->model('datamodel');
$this->datamodel->insert($data);
}
here is the screenshot, i have filled three fields so it posted the values of three fields only.
public function angform()
{
$get=file_get_contents('php://input');
$json_get=json_decode($get);
foreach($json_get as $key=>$value){
$data[$key]=$value; //Worked For Me.
}
$this->load->model('datamodel');
$this->datamodel->insert($data);
}
i check like this :-
if($this->input->get_post('male'))
{
// rest code goes here
}
Change your input name to match exactly like the database attribute(column) name. In that way you will not have to check anything:
$data = $this->input->post(null); #get the post array
$this->db->insert('table', $ata);

AngularJS, Databind Multiple Form Fields

Ok i have a Edit Form in AngularJS and i want show data in textboxes through angular databindings.
Here is the Form which i have done so far.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
<link href="<?php echo base_url(); ?>/styles/formcss.css" rel="stylesheet" type="text/css"/>
<script src="<?php echo base_url(); ?>/scripts/angular.min.js"></script>
</head>
<body ng-app>
<div ng-controller="controller">
<form>
<label for="name">UserID:</label> <input type="text" name="UserID" ng-model="user.UserID" value=""><br>
<label for="UserName">Name:</label> <input type="text" name="UserName" ng-model="user.UserName" value=""><br>
<label for="rollno">In Game Name:</label> <input type="text" name="GameName" ng-model="user.InGameName" value="" ><br>
<label for="father">CNIC Number:</label> <input type="number" name="Cnic" ng-model="user.Cnic" value="" ><br>
<label for="age">Age:</label> <input name="Age" ng-model="user.Age" type="number" value="" ><br>
<label for="email1">Email:</label> <input name="Email" ng-model="user.Email" type="email" value="" ><br>
<label for="email2">Res enter Email:</label> <input id="email2" type="email" name="email2" value="" ><br>
<label for="pass1">Password:</label> <input id="pass1" type="password" name="Pass" ng-model="user.Password" value=""><br>
<label for="pass2">Re enter Password:</label> <input id="pass2" type="password" name="pass2" value="" ><br>
<label style="margin-bottom:-10px; " for="male">Male</label><input class="gen" ng-model="user.Gender" id="male" type="radio" name="g" value="Male"><br>
<label style="margin-bottom:15px;" for="female">Female</label><input class="gen" ng-model="user.Gender" id="female" type="radio" name="g" value="Female"><br>
<label class="dis" for="about" >About:</label> <textarea rows="5" cols="40" id="about" type="text" value=""></textarea><br>
<button style="margin-left: 225px;" ng-click="save()" >Save</button>
</form>
</div>
<script>
function controller ($scope,$http)
{
var angularform="<?php echo base_url(); ?>index.php/datacon/angform"
$scope.save=function()
{
$http.post(angularform, $scope.user);
}
}
</script>
</body>
</html>
Here is the Json Array I am Getting From the Controller
JSON:
{"datas":[{"UserID":"168","UserName":"fdaa","Cnic":"23424","Email":"pak#gmail.com","Password":"asdad","Age":"12","Gender":"Male","Picture":null,"InGameName":"fds","ContactID":null,"GroupID":null,"ClanID":null}]}
But How to show these values in TextBoxes through Angular Data bindings?
Or if i am Doing Something Wrong Please Redirect me to my mistakes so i could solve my mistakes.
I am not sure whether I am getting you right or not. But I think If you are using $scope and ng-model, they are doing their job perfectly. You are using absolutely correct.
With the $http.post() you can save the data. At the same time data will be present in the text boxes.
What exactly you want to do. Please explain a bit more so that folks can try to explain you more.

html form is being sent on reset button

I have a problem with the html form.
This is my code:
<form name="contactform" method="post" action="send_form_email.php">
<input id="first_name" type="text" name="first_name" size="30"/>
<input id="company_name" type="text" name="company_name" size="30"/>
<input id="email" type="text" name="email" size="30"/>
<input type="image" align="middle" src="images/accept.png" alt="Submit" /> <input id="reset" type="image" src="images/reset.png" alt="Reset" align="middle" />
</form>
when I click any of this images my form is sent. How can I make this reset picture to only reset and not to send the form.
Your reset button is not a reset button. It has type="image", it is server side image map.
When you click on a server side image map the form will be submitted and the coordinates you clicked on will be included in the data.
If you want a reset button that is an image use:
<button type="reset"><img src="..." alt="..."></button>
The image type is like a submit button.
You have to take type="reset" and style your button with css.
Use
<input type = "reset" value = "" class = "btnResetClass" />
Your, btnResetClass will have Css Setting for background image to be set by you.
You have to use type="reset".
This jsFiddle example would be better.
HTML:
<form id="contactform" method="post" action="send_form_email.php">
<div>
<label>
First Name: <input id="first_name" name="first_name" type="text" size="30" />
</label>
</div>
<div>
<label>
Company Name: <input id="company_name" name="company_name" type="text" size="30" />
</label>
</div>
<div>
<label>
Email: <input id="email" type="text" name="email" size="30" />
</label>
</div>
<input id="submit" type="submit" value="" title="Submit" />
<input id="reset" type="reset" value="" title="Reset" />
</form>
CSS:
#submit, #reset {
border: none;
width: 64px;
height: 48px
}
#submit {
background: url('images/submit.png')
}
#reset {
background: url('images/reset.png')
}

Categories