I have the following form code but I cannot choose between these for choices.
I can't figure where is the problem. all i know about radio buttons is that they need to have the same name
<div class="controls">
<input type="radio" name="pub_place" id="1" value="1" >1
<input type="radio" name="pub_place" id="2" value="2" >2
<input type="radio" name="pub_place" id="3" value="3" >3
<input type="radio" name="pub_place" id="4" value="3" >4
</div>
this is all the view
<form class="form-horizontal" action="{{ url('/save-publicity')}}" method="post" enctype="multipart/form-data">
{{ csrf_field() }}
<fieldset>
<div class="control-group">
<label class="control-label" for="date01">Publicity Name</label>
<div class="controls">
<input type="text" class="input-xlarge" name="pub_name" required="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="date01">website Link</label>
<div class="controls">
<input type="text" class="input-xlarge" name="pub_link" required="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="fileInput">Publicity Image</label>
<div class="controls">
<input class="input-file uniform_on" name="pub_image" id="pub_image" type="file" required="">
</div>
</div>
<div class="control-group hidden-phone">
<label class="control-label" for="textarea2">Publication status </label>
<div class="controls">
<input type="checkbox" name="pub_status" value="1">
</div>
</div>
<div class="control-group hidden-phone">
<label class="control-label" for="textarea2">Pub Place </label>
<div class="controls">
<input type="radio" name="pub_place" id="1" value="1" >1
<input type="radio" name="pub_place" id="2" value="2" >2
<input type="radio" name="pub_place" id="3" value="3" >3
<input type="radio" name="pub_place" id="4" value="4" >4
</div>
<p>NB: <strong>Place 1 dimension:</strong> 1170x150 |
<strong>Place 2 dimension:</strong> 850x100 |
<strong>Place 3 and 4 dimension:</strong> 270x329</p>
<img style="width:300px"src="backend/brunch.jpg" alt="" />
<div class="form-actions">
<button type="submit" class="btn btn-primary">Add Publicity</button>
<button type="reset" class="btn">Cancel</button>
</div>
</div>
</fieldset>
</form>
they keep giving me NULL on the column pub_place on my database
Related
I have a custom input field that acts as a drop-down menu and it works like this:
Each option is an <input> field and I need the value of this input to be passed into the controller. The <input> looks like this:
<!-- Updated -->
<label for="United States">United States</label>
<input type="radio" class="radio" id="United States" name="country" value="United States">
When the user presses the continue button, I want the value of the <input> to be passed to my controller: WelcomeController.
-- Updated --
My controller method looks like this:
public function countrySelect(Request $request)
{
$country = $request->input('country');
dd($country);
}
Here is a basic code structure of the inputs - I think I should be using a form and so have created a route in web.php:
Route::post('/', [\App\Http\Controllers\WelcomeController::class, 'countrySelect'])->name('CS');
And that the input should have the value property:
<!-- Updated -->
<form action="{{ route('CS') }}" method="POST">
<input name="country" value="[COUNTRY Value]">
<button type="submit"> CONTINUE </button>
</form>
The countrySelect method in my controller is empty and so how do I pass the value of the <input> into it? Thanks!
My Full Form:
<form action="{{ route('CS') }}" method="POST">
#csrf
<div class="country-select-container">
<div class="country-align-container">
<div class="CountryInput">
<div class="select-box">
<div class="options-container">
<div class="option">
<label for="United States">United States</label>
<input type="radio" name="country" value="United States">
</div>
<div class="option">
<label for="United Kingdom And Ireland">United Kingdom And Ireland</label>
<input type="radio" class="radio" id="United Kingdom And Ireland" name="country" value="United Kingdom And Ireland">
</div>
<div class="option">
<label for="Philippines">Philippines</label>
<input type="radio" name="country" value="Philippines">
</div>
<div class="option">
<label for="India">India</label>
<input type="radio" name="country" value="India">
</div>
<div class="option">
<label for="Indonesia">Indonesia</label>
<input type="radio" name="country" value="Indonesia">
</div>
<div class="option">
<label for="Malaysia">Malaysia</label>
<input type="radio" name="country" value="Malaysia">
</div>
<div class="option">
<label for="Mexico">Mexico</label>
<input type="radio" name="country" value="Mexico">
</div>
<div class="option">
<label for="Singapore">Singapore</label>
<input type="radio" name="Singapore">
</div>
<div class="option">
<label for="Germany">Germany</label>
<input type="radio" name="country" value="Germany">
</div>
<div class="option">
<label for="Brazil">Brazil</label>
<input type="radio" name="country" value="Brazil">
</div>
<div class="option">
<label for="Canada">Canada</label>
<input type="radio" name="country" value="Canada">
</div>
<div class="option">
<label for="Italy">Italy</label>
<input type="radio" name="country" value="Italy">
</div>
<div class="option">
<label for="Colombia">Colombia</label>
<input type="radio" name="country" value="Colombia">
</div>
<div class="option">
<label for="Australia">Australia</label>
<input type="radio" name="country" value="Australia">
</div>
<div class="option">
<label for="South Africa">South Africa</label>
<input type="radio" name="country" value="South Africa">
</div>
<div class="option">
<label for="France">France</label>
<input type="radio" name="country" value="France">
</div>
<div class="option">
<label for="Pakistan">Pakistan</label>
<input type="radio" name="country" value="Pakistan">
</div>
<div class="option">
<label for="Bangladesh">Bangladesh</label>
<input type="radio" name="country" value="Bangladesh">
</div>
<div class="option">
<label for="Spain">Spain</label>
<input type="radio" name="country" value="Spain">
</div>
<div class="option">
<label for="United Arab Emirates">United Arab Emirates</label>
<input type="radio" name="country" value="United Arab Emirates">
</div>
<div class="option">
<label for="Netherlands">Netherlands</label>
<input type="radio" name="country" value="Netherlands">
</div>
<div class="option">
<label for="Sri Lanka">Sri Lanka</label>
<input type="radio" name="country" value="Sri Lanka">
</div>
<div class="option">
<label for="Russia">Russia</label>
<input type="radio" name="country" value="Russia">
</div>
<div class="option">
<label for="Trinidad & Tobago">Trinidad & Tobago</label>
<input type="radio" name="country" value="Trinidad & Tobago">
</div>
<div class="option">
<label for="Saudi Arabia">Saudi Arabia</label>
<input type="radio" name="country" value="Saudi Arabia">
</div>
<div class="option">
<label for="Thailand">Thailand</label>
<input type="radio" name="country" value="Thailand">
</div>
<div class="option">
<label for="Peru">Peru</label>
<input type="radio" name="country" value="Peru">
</div>
<div class="option">
<label for="New Zealand">New Zealand</label>
<input type="radio" name="country" value="New Zealand">
</div>
<div class="option">
<label for="Vietnam">Vietnam</label>
<input type="radio" name="country" value="Vietnam">
</div>
<div class="option">
<label for="Japan">Japan</label>
<input type="radio" name="country" value="Japan">
</div>
<div class="option">
<label for="Egypt">Egypt</label>
<input type="radio" name="country" value="Egypt">
</div>
<div class="option">
<label for="Argentina">Argentina</label>
<input type="radio" name="country" value="Argentina">
</div>
<div class="option">
<label for="Other">Other...</label>
<input type="radio" name="country" value="Other...">
</div>
</div>
<div class="selected">
Select Country To Continue:
</div>
</div>
</div>
</div>
<div class="guest-action-container">
<div class="go-back-container">
<div class="go-back-btn">
<span class="go-back">
<span class="go-back-icon"></span>
<span class="go-back-text">BACK</span>
</span>
</div>
</div>
<div class="continue-to-site-container">
<div class="continue-to-site-btn">
<button type="submit" class="continue-to-site">
<span class="continue-text">CONTINUE</span>
<span class="continue-icon"></span>
</button>
</div>
</div>
<div class="clearFix"></div>
</div>
</div>
</form>
Here is the JS that creates the dropdown effect:
// country select drop down
$(document).ready(function(){
// country select options
const selected = document.querySelector(".selected");
const optionsContainer = document.querySelector(".options-container");
const optionsList = document.querySelectorAll(".option");
selected.addEventListener("click", () => {
optionsContainer.classList.toggle("active");
});
optionsList.forEach( o => {
o.addEventListener("click", () => {
selected.innerHTML = o.querySelector("label").innerHTML;
optionsContainer.classList.remove("active");
});
});
});
start by changing the code of the form from:
<form action="{{ route('CS') }}" method="POST">
<input value="country">
<button type="submit"> CONTINUE </button>
</form
to
<form action="{{ route('CS') }}" method="POST">
#csrf
<input value="country" name="country">
<button type="submit"> CONTINUE </button>
</form>
i hope that you are seeing the difference. while using a form in laravel you must and the csrf tokem if not i will not work.
After that in your controller just write:
public function handleSubmission(Request $request)
{
$country = $request->input('country');
}
In order to pass the value of an input to your controller you should start by having a "name" parameter in your input, then a POST route, in your web.php file, that calls the method in the controller that should get the values. Finally use request('name-of-input') and that should return the value.
Example:
view:
<form action="/user" class="admin-form" method="POST">
#csrf
<label for="form-name">Name: </label>
<input type="text" id="form-name" name="name" required>
<label for="form-email">Email: </label>
<input type="email" id="form-email" name="email" required>
<input id="form-submit" type="submit" value="Sign up!">
</form>
web.php:
Route::post('/user', 'App\Http\Controllers\UserController#store');
controller:
public function store(Request $request)
{
$user = new User();
$user->name = request('name');
$user->email = request('email');
$user->save();
return redirect('/user/create');
}
You need to include the name attribute in the input field like this:
<form action="{{ route('CS') }}" method="POST">
<input name="country" value="country">
<button type="submit"> CONTINUE </button>
</form
Then in the controller action you can reference the name field like this:
public function handleSubmission(Request $request)
{
$country = $request->input('country');
}
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">
i am trying to get connected to database .html page doesnt get connected to addtodatabase.php which has many feilds like radio button,checkbox,textarea, input field .Once given submit it doesn't display the data .
<form action="addtodatabase.php" method="post">
<div class="container">
<form class="form-inline">
<fieldset>
<legend>Security Department User Registration</legend>
<div class="form-group">
<label for="Firstname">First Name</label>
<input type="text" class="form-control" id="Firstname" name="Firstname" placeholder="Text input"><br/>
</div>
<div class="form-group">
<label for="Secondname">Second Name</label>
<input type="text" class="form-control" id="Secondname" name="Secondname" placeholder="Text input"><br/>
</div>
</form>
.....
...
<button type="submit" class="btn btn-default">Submit</button>
addtodatabase.php page as phpmyadmin username as root , pasword NULL
<?php
$connection = mysql_connect ('root','','');
mysql_select_db('form_db');
$Firstname = $_POST ['Firstname'];
$Secondname = $_POST ['Secondname'];
echo $_POST['Firstname'];
echo '<br />';
echo $_POST['Secondname'];
$query =
"INSERT INTO form_details
(Firstname,Secondname)
values
('$Firstname','$Secondname')";
$result = mysql_query($query);
Echo "Database Saved";
mysql_close($connection);
?>
i have change the code from mysql to mysqli
<?php
$connect=mysqli_connect('localhost','root','','form_db');
if(mysqli_connect_errno($connect))
{
echo 'Failed to connect';
}
$Firstname = $_POST ['Firstname'];
$Secondname =$_POST ['Secondname'];
echo $_POST['Firstname'];
echo '<br />';
echo $_POST['Secondname'];
$query =
"INSERT INTO form_details
(Firstname,Secondname)
values
('$Firstname','$Secondname')";
$result = mysqli_query($query);
if(mysqli_affected_rows($connect) > 0){
echo "<p>Employee Added</p>";
echo "Go Back";
} else {
echo "Employee NOT Added<br />";
echo mysqli_error ($connect);
}
?>
Even after changing to mysqli it not working .addtodatabase.php
I am getting this error Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp64\www\Form\addtodatabase.php on line 2
My entire form looks this way
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="customstyle.css">
</head>
<body>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<form action="addtodatabase.php" method="post">
<div class="container">
<h1> Group of Companies</h1>
<h3> ICT & Security Department User Registration form </h3>
<h4> To be filled by HR department for New Employee </h4>
<form class="form-inline">
<fieldset>
<legend>Security Department User Registration</legend>
<div class="form-group">
<label for="Firstname">First Name</label>
<input type="text" class="form-control" id="Firstname" name="Firstname" placeholder="Text input"><br/>
</div>
<div class="form-group">
<label for="Secondname">Second Name</label>
<input type="text" class="form-control" id="Secondname" name="Secondname" placeholder="Text input"><br/>
</div>
</form>
<form >
<div class="form-group">
<label for="location">Dpt./Location</label>
<input type="text" class="form-control" name="location" id="location" placeholder="Text input">
</div>
</form>
<form class="form-inline">
<div class="form-group">
<label for="Designation">Designation</label>
<input type="text" class="form-control" id="Designation" placeholder="Text input"><br/>
</div>
<div class="form-group">
<label for="Fileno">File No</label>
<input type="text" class="form-control" id="Fileno" placeholder="Password"><br/>
</div>
</form>
<form class="form-inline">
<div class="form-group">
<label for="Dateofapplication">Date of Application</label>
<input type="text" class="form-control" id="Dateofapplication" placeholder="Text input"><br/>
</div>
<div class="form-group">
<label for="Dateofjoining">Date of Joining</label>
<input type="text" class="form-control" id="Dateofjoining" placeholder="Password"><br/>
</div>
</form>
<form>
<fieldset>
<legend>For Head office staffs only </legend>
<label>Card Type:</label>
<div id="idcard">
<label class="checkbox-inline">
<input type="checkbox" value="">Trainee ID Card
</label>
<label class="radio-inline">
<input type="radio" name="green">Green
</label>
<label class="radio-inline">
<input type="radio" name="red">Red
</label>
<label class="checkbox-inline">
<input type="checkbox" value="">Permanent ID Card
</label>
</div>
<div class="aligncheckbox">
<label>Door Access:</label>
<label class="checkbox-inline">
<input type="checkbox" value="">Main
</label>
<label class="checkbox-inline">
<input type="checkbox" value="">Finance Division
</label>
</div>
<div class="aligncheckbox">
<label class="checkbox-inline">
<input type="checkbox" value="">Meeting Room
</label>
<label class="checkbox-inline">
<input type="checkbox" value="">Goods Receiving
</label>
</div>
<div class="aligncheckbox">
<label class="checkbox-inline">
<input type="checkbox" value="">Graphics & Media
</label>
<label class="checkbox-inline">
<input type="checkbox" value="">IT Dept
</label>
</div>
<div class="aligncheckbox">
<label class="checkbox-inline">
<input type="checkbox" value="">Server Room
</label>
<label class="checkbox-inline">
<input type="checkbox" value="">Dist.&Quality Control
</label>
</div>
<div class="aligncheckbox">
<label class="checkbox-inline">
<input type="checkbox" value="">Warehouse Supervisor
</label>
<label class="checkbox-inline">
<input type="checkbox" value="">Pur.Office Meeting Room
</label>
</div>
<div class="aligncheckbox">
<label class="checkbox-inline">
<input type="checkbox" value="">Purchase Office
</label>
<label class="checkbox-inline">
<input type="checkbox" value="">Exit
</label>
</div>
<!-- <div class="upload">
<label for="Passportcopy">Passport Copy</label>
<input type="file" id="Passportcopy">
<label for="Photo">Photo</label>
<input type="file" id="Photo">
</div>
<div>
<label class="checkbox-inline">
<input type="checkbox" value="">Finger Registration
</label>
</div> -->
<div class="container">
<div id="upload row">
<form class="form-inline">
<div class="form-group col-xs-*">
<label for="Passportcopy">Passport Copy</label>
<input type="file" class="form-control" id="Passportcopy">
</div>
<div class="form-group col-xs-*">
<label for="Photo">Photo</label>
<input type="file" class="form-control" id="Photo">
</div>
</form>
</div>
</div>
</form>
<!-- second form IT department -->
<div class="secform">
<form>
<fieldset>
<legend>IT Department User Registration </legend>
<div class="container">
<form class="form-inline">
<div class="checkbox-inline" id="erp">
<label><input type="checkbox" value="">Enroll as sales Person ERP</label>
</div>
<div class="form-group" id="textbox">
<label for="erpmodules">ERP Modules</label>
<textarea class="form-control" rows="5" id="erpmodules"></textarea>
</div>
</fieldset>
</form>
<form>
<fieldset>
<legend>For Head office staffs only </legend>
<div class="fkhaccess">
<div class="form-group" id="textbox">
<label for="fkhaccess">FKH Folder Access</label>
<textarea class="form-control" rows="5" id="fkhaccess"></textarea>
</div>
<div class="container-fluid">
<ul id="access">
<li> <label>Internet Access</label></li>
<li>
<label class="radio-inline">
<input type="radio" name="yes">Yes
</label></li>
<li>
<label class="radio-inline">
<input type="radio" name="no">No
</label></li>
</ul>
<ul id="purpose">
<li><p>If yes, Purpose </p></li>
<li>
<div class="form-group" id="textbox">
<label for="purpose">Job Purpose</label>
<textarea class="form-control" rows="5" id="purpose"></textarea>
</div></li>
</ul>
<ul id="compmail">
<li>
<div class="form-group" id="textbox" >
<label for="companyemail">Company Email</label>
<textarea class="form-control" rows="5" id="companyemail"></textarea>
</div></li>
</ul>
<form class="form-inline">
<label> Computer facilities: </label>
<label> CD ROM </label>
<label class="checkbox-inline">
<input type="checkbox" value="">Read
</label>
<label class="checkbox-inline">
<input type="checkbox" value="">Write
</label>
<label> USB PORTS </label>
<label class="checkbox-inline">
<input type="checkbox" value="">Read
</label>
<label class="checkbox-inline">
<input type="checkbox" value="">Write
</label>
</form>
<form class="form-inline">
<label class="checkbox-inline" id="label1">
<input type="checkbox" value="">Parallel Port
</label>
</form>
<form class="form-inline">
<label> Printers </label>
<label class="checkbox-inline">
<input type="checkbox" value="">MP2352(Front Office)
</label>
<label class="checkbox-inline">
<input type="checkbox" value="">MP2501(Purchase)
</label>
</form>
<form class="form-inline">
<label class="checkbox-inline">
<input type="checkbox" value="">MP1600(MD Office)
</label>
<label class="checkbox-inline">
<input type="checkbox" value="">DSM616(Finance)
</label>
</form>
<form class="form-inline">
<ul><li>
<label> Computer Utilities :</label>
<label class="checkbox-inline">
<input type="checkbox" value="">Scanner
</label></li>
<li>
<label class="checkbox-inline">
<input type="checkbox" value="">Barcode Scanner
</label></li>
<li>
<label class="checkbox-inline">
<input type="checkbox" value="">Others
</label></li>
<ul id="software">
<li>
<div class="form-group" id="textbox" >
<label for="softwarerequired">Software Required </label>
<textarea class="form-control" rows="5" id="software"></textarea>
</div></li>
</ul>
</form>
</div>
</div>
</fieldset>
</form>
<div >
<div class="fill">
<div class='sign-container'>
<div class="div1">Form Filled by</div>
<div class='sign'> </div>
<div class="div2"> </div>
<div class="div3">(HR)</div>
</div>
</div>
<div class="sign-box">
<p id="signbox"> Signature </p>
<div class="div4"> </div>
<div class="fill">
<div class='sign-container'>
<div class="div1">Form Filled by</div>
<div class='sign'> </div>
<div class="div2"> </div>
<div class="div3">(Admin Manager)</div>
</div>
</div>
<div class="sign-box">
<p id="signbox"> Signature </p>
<div class="div4"> </div>
</div>
<div class="fill">
<div class='sign-container'>
<div class="div1">Form Filled by</div>
<div class='sign'> </div>
<div class="div2"> </div>
<div class="div3">(IT Manager)</div>
</div>
</div>
<div class="sign-box">
<p id="signbox"> Signature </p>
<div class="div4"> </div>
</div>
</div>
<div class="Threeform">
<form>
<fieldset>
<legend> User Confirmation </legend>
<div class="sign-container">
<div class="div1">User Name</div>
<div class='sign'> </div>
<div class="div1">System No</div>
<div class='sign'> </div>
</div>
<div class="policy-container">
<div class="div1">Received all the above mentioned facilities and understood international & FGC Cyber policy by
<div class='sign1'> </div></div>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</form>
</div>
</body>
</html>
plz help me to rectify.
I am not able to connect from form.html page to addtodatabase.php .
Notice: Undefined index: firstname in C:\wamp64\www\Form\addtodatabase.php on line 12
You need to pass 2 parameters! $result = mysqli_query($connect, $query);
Im trying to bootstrap a mulitple choice tickbox for PHP. I have the following code:
<div class="container">
<div class="row">
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-addon">
<form action="catcheck.php" method="post">
<input type="checkbox" name="check_list[]" value="value 1">
<input type="submit" />
</form>
</span>
</div>
</div>
</div>
</div>
But im just getting a normal checkbox, how do I go about changing this to submit to catcheck.php whilst using the bootstrap css?
The below code will work (Hope this is what you needed):
<div class="container">
<div class="row">
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-addon">
<form action="catcheck.php" method="post" role="form">
<label>
<input type="checkbox" name="check_list[]" value="value 1" /> Value 1
</label>
<label>
<input type="checkbox" name="check_list[]" value="value 2" /> Value 2
</label>
<label>
<input type="checkbox" name="check_list[]" value="value 3" /> Value 3
</label>
<label>
<input type="checkbox" name="check_list[]" value="value 4" /> Value 4
</label>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</span>
</div>
</div>
</div>
</div>
In catcheck.php
You can retrieve data as $_POST['check_list'] which will return an array. You can begin from:
echo "<pre>";
print_r($_POST);
echo "</pre>";
EDIT:
The below code will do what you have asked (with doc reference)
<div class="row">
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" name="check_list[]" value="value 1" />
</span>
<input type="text" name="text_value[]" class="form-control" />
</div>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" name="check_list[]" value="value 2" />
</span>
<input type="text" name="text_value[]" class="form-control" />
</div>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" name="check_list[]" value="value 3" />
</span>
<input type="text" name="text_value[]" class="form-control" />
</div>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" name="check_list[]" value="value 4" />
</span>
<input type="text" name="text_value[]" class="form-control" />
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
For alignment consider the following CSS:
.input-group
{
margin-bottom:10px;
}
You can adjust the size of input area by reducing col-lg-6 to col-lg-4 and so on.
Fiddle Demo : http://jsfiddle.net/27LnT/
I'm trying to submit data to a list in my mail chimp but also allow the user to upload a file.
Here is my code, the first chunk is the mailchimp autogenerated form which is submitted via:
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
and then it's followed by the basic code to submit a file. But at the moment both functions have a submit button. I want only one. Can anyone help?
<body>
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="http://test.us7.list-manage.com/subscribe/post?u=d12b70d4bb1e08c1568d5b392&id=bfb41cbf75" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<h2>Subscribe to our test mailing list</h2>
<div class="indicates-required">
<span class="asterisk">*</span> indicates required
</div>
<div class="mc-field-group">
<label for="mce-EMAIL">
Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name </label>
<input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>
<div class="mc-field-group">
<label for="mce-LNAME">Last Name </label>
<input type="text" value="" name="LNAME" class="" id="mce-LNAME">
</div>
<div class="mc-field-group input-group">
<strong>Interests </strong>
<ul>
<li><input type="checkbox" value="1" name="group[5597][1]" id="mce-group[5597]-5597-0"><label for="mce-group[5597]-5597-0">Interest 1</label></li>
<li><input type="checkbox" value="2" name="group[5597][2]" id="mce-group[5597]-5597-1"> <label for="mce-group[5597]-5597-1">Interest 2</label></li>
<li><input type="checkbox" value="4" name="group[5597][4]" id="mce-group[5597]-5597-2"><label for="mce-group[5597]-5597-2">Interest 3</label></li>
</ul>
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
</div>
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
<div class="clear">
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
</form>
</form>
</body>
You could accomplish this by routing the MailChimp information through your upload_file.php file.
MailChimp has a great API that you can use for more than just adding a subscriber to a list. You would specifically want the listSubscribe() function. There are some great examples on that page.
Here's more documentation on MailChimp's API: http://apidocs.mailchimp.com/api/2.0/
So in your HTML, you would want to remove the second submit button and make it one form with action="upload_file.php". The PHP file would upload the file, then use the API to submit the data to MailChimp.
You html should look like this:
<body>
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<h2>Subscribe to our test mailing list</h2>
<div class="indicates-required">
<span class="asterisk">*</span> indicates required
</div>
<div class="mc-field-group">
<label for="mce-EMAIL">
Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name </label>
<input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>
<div class="mc-field-group">
<label for="mce-LNAME">Last Name </label>
<input type="text" value="" name="LNAME" class="" id="mce-LNAME">
</div>
<div class="mc-field-group input-group">
<strong>Interests </strong>
<ul>
<li><input type="checkbox" value="1" name="group[5597][1]" id="mce-group[5597]-5597-0"><label for="mce-group[5597]-5597-0">Interest 1</label></li>
<li><input type="checkbox" value="2" name="group[5597][2]" id="mce-group[5597]-5597-1"> <label for="mce-group[5597]-5597-1">Interest 2</label></li>
<li><input type="checkbox" value="4" name="group[5597][4]" id="mce-group[5597]-5597-2"><label for="mce-group[5597]-5597-2">Interest 3</label></li>
</ul>
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
</div>
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<div class="clear">
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
</body>