HTML/PHP Form Formatting Error - forms

im new so don't go to hard on me here. I'm trying to make this registration form into two rows but every time i try it does not post all the values from both rows of the form, just the first.
http://i.stack.imgur.com/TSnjl.png
<table width="990" border="0">
<tr>
<td width="486" height="221"><form id='register' action='<?php echo $fgmembersite->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
<fieldset >
<legend>Register</legend>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<div class='short_explanation'>* required fields</div>
<input type='text' class='spmhidip' name='<?php echo $fgmembersite->GetSpamTrapInputName(); ?>' />
<div class="container"><span class='error'><?php echo $fgmembersite->GetErrorMessage(); ?></span>
<label for='name' >Your First Name*: </label>
<br/>
<input type='text' name='name' id='name' value='<?php echo $fgmembersite->SafeDisplay('name') ?>' maxlength="50" />
<br/>
</div>
<div class='container'>
<label for='lastname' >Your Last Name*: </label>
<br/>
<input type='text' name='lastname' id='lastname' value='<?php echo $fgmembersite->SafeDisplay('lastname') ?>' maxlength="50" />
<br/>
<span id='register_name_errorloc' class='error'></span> </div>
<div class='container'>
<label for='email' >Email Address*:</label>
<br/>
<input type='text' name='email' id='email' value='<?php echo $fgmembersite->SafeDisplay('email') ?>' maxlength="50" />
<br/>
<span id='register_email_errorloc' class='error'></span> </div>
<div class='container'>
<label for='username' >UserName*:</label><br/>
<input type='text' name='username' id='username' value='<?php echo $fgmembersite->SafeDisplay('username') ?>' maxlength="50" /><br/>
<span id='register_username_errorloc' class='error'></span>
<br/>
<span id='register_username_errorloc' class='error'></span> </div>
<div class='container' style='height:80px;'>
<label for='password' >Password*:</label>
<br/>
<div class='pwdwidgetdiv' id='thepwddiv' ></div>
<noscript>
<input type='password' name='password' id='password' maxlength="50" />
</noscript>
<div id='register_password_errorloc' class='error' style='clear:both'></div>
</div>
<input type='text' class='spmhidip' name='<?php echo $fgmembersite->GetSpamTrapInputName(); ?>2' />
<div class="container">
<p><span class='error'><?php echo $fgmembersite->GetErrorMessage(); ?></span>
<label for='phonenumber' >Phone Number: </label>
<br/>
<input type='text' name='phonenumber' id='phonenumber' value='<?php echo $fgmembersite->SafeDisplay('phonenumber') ?>' maxlength="15" />
<br/>
</p>
</div>
<div class='container'>
<label for='address' >Address: </label>
<br/>
<input type='text' name='address' id='address' value='<?php echo $fgmembersite->SafeDisplay('address') ?>' maxlength="40" />
<br/>
</div>
<div class='container'>
<label for='city' >City:</label>
<br/>
<input type='text' name='city' id='city'value='<?php echo $fgmembersite->SafeDisplay('city') ?>' maxlength="20">
<br/>
</div>
<div class='container'>
<label for='State' >State:</label>
<br/>
<input type='text' name='state' id='state' value='<?php echo $fgmembersite->SafeDisplay('state') ?>' maxlength="2" />
</div>
<div class='container'>
<label for='State' >Country:</label>
<br/>
<input type='text' name='country' id='country' value='<?php echo $fgmembersite->SafeDisplay('country') ?>' maxlength="3" />
<br/>
</div>
<div class='container' style='height:80px;'>
<p>
<label for='zip' >ZipCode:</label>
<br/>
<input type='text' name='zipcode' id='zipcode' value='<?php echo $fgmembersite->SafeDisplay('lastname') ?>' maxlength="5" />
</p>
<div class='container'>
<input type='submit' name='Submit' value='Submit' />
</div>
<p> </p>
</div>
</fieldset>
</form></td>
<td width="494" valign="top"><h2> </h2></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>

I think possible the error is in the way u use double quotes and single quotes.
value='<?php echo $fgmembersite->SafeDisplay('username') ?>'
should be changed to
value="<?php echo $fgmembersite->SafeDisplay('username') ?>"
Could you report back to me what happens if you do this in all the cases

Related

Why modal bootstrap on table data doesn't showing / fetching match data when popup?

Please check this image
I try to fetching data on every table data using modal bootstrap, but when i click every modal button it's just showing last table data in form of my popup modal. I want the data is per in the form on modal bootstrap. I am using CodeIgniter. Please help me, thanks. GBU
HERE IS MY CODE:
<table class="table table-bordered table-striped nowrap text-gray-900" id="dataTable" width="100%" style="font-size: 13px;" cellspacing="0">
<thead>
<tr class="table-success">
<th>ID</th>
<th>NOMOR</th>
<th>KODE</th>
<th>TINDAKAN</th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
<?php
foreach ($prosedur_rehab as $rehab) {
?>
<tr>
<td><?= $rehab->ID; ?></td>
<td><?= $rehab->NOMOR; ?></td>
<td><?= $rehab->KODE; ?></td>
<td><?= $rehab->TINDAKAN; ?></td>
<td>
<button type="button" class="btn btn-sm btn-info" data-toggle="modal" data-target="#perawat<?php echo $rehab->ID;?> ">
<i class="fas fa-user-nurse"></i>
</button>
<div class="modal fade" id="perawat<?php echo $rehab->ID;?>" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true" >
<div class="modal-dialog modal-lg" >
<div class="modal-content">
<div class="modal-header" style="background-color:#5bc0de">
<h5 class="modal-title" id="exampleModalLabel">Kelola Rawat Jalan (Diisi Oleh Perawat)</h5>
<button type="button" class="btn-danger" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form method="post" action="<?php echo base_url().'dokter/kunjungan/kirimlaprajal'?>">
<div class="form-group">
<!-- <label for="exampleInputEmail1">ID</label> -->
<select name="" class="form-control">
<option>-- CARI --</option>
<?php foreach ($prosedur_rehab as $rehab):?>
<option value="<?php echo $rehab->ID?>"><?php echo $rehab->ID?> || <?php echo $rehab->NORM?></option>
<?php endforeach ?>
</select>
</div>
<div class="form-group">
<label for="exampleInputEmail1">ID Prosedur</label>
<input type="text" name="ID" class="form-control" id="exampleInputEmail1" required readonly autocomplete="off" value="<?php echo $rehab->ID; ?>">
</div>
<div class="row">
<div class="col-6">
<div class="form-group">
<label for="exampleInputEmail1">No. Pendaftaran</label>
<input type="text" name="NOMOR" class="form-control" id="exampleInputEmail1" required readonly autocomplete="off" value="<?php echo $rehab->NOMOR; ?>">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Kode</label>
<input type="text" name="KODE" class="form-control" id="exampleInputEmail1" required readonly autocomplete="off" value="<?php echo $rehab->KODE; ?>">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Tindakan</label>
<input type="text" name="TINDAKAN" class="form-control" id="exampleInputEmail1" autocomplete="off" value="<?php echo $rehab->TINDAKAN; ?>">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Tanggal</label>
<input type="datetime-local" name="TANGGAL" class="form-control" id="exampleInputEmail1" required autocomplete="off" placeholder="" value="">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Instrumen Uji Fungsi</label>
<input type="text" name="PROGRAM" class="form-control" id="exampleInputEmail1" required autocomplete="off" value="">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Hasil</label>
<input type="text" name="HASIL" class="form-control" id="exampleInputEmail1" required autocomplete="off" placeholder="" value="">
</div>
</div>
<div class="col-6">
<div class="form-group">
<label for="exampleInputEmail1">Kesimpulan</label>
<input type="text" name="KESIMPULAN" class="form-control" id="exampleInputEmail1" required autocomplete="off" value="">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Rekomendasi</label>
<input type="text" name="REKOMENDASI" class="form-control" id="exampleInputEmail1" required autocomplete="off" value="">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Oleh</label>
<input type="text" name="OLEH" class="form-control" id="exampleInputEmail1" required autocomplete="off" value="<?php echo $session_user->nip ;?>" readonly>
</div>
<div class="form-group">
<label for="exampleInputEmail1">Status</label>
<input type="text" name="STATUS" class="form-control" id="exampleInputEmail1" required autocomplete="off" value="">
</div>
</div>
</div>
<button type="submit" name="simpen" class="btn btn-info float-right"><i class="fas fa-save"> </i> Simpan</button>
</form>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<th>ID</th>
<th>NOMOR</th>
<th>KODE</th>
<th>TINDAKAN</th>
</tr>
</tfoot>
</table>
i tried your code and it works perfectly, Check your $rehave->ID value maybe it doesn't have value or have invalid value, or check your modal plugins
The problem is i was used same foreach in select option . I was forgot if i 've been using first foreach to displaying table data and i used it again in form.
Don't using same foreach in form, delete or change this:
<select name="" class="form-control">
<option>-- CARI --</option>
<?php foreach ($prosedur_rehab as $rehab):?>
<option value="<?php echo $rehab->ID?>"><?php echo $rehab->ID?> || <?php echo $rehab->NORM?></option>
<?php endforeach ?>
</select>

Form Text Input Alignment Issue

I looked at the other forms on here and I still can't seem to get anywhere for whatever reason. I've tried several different methods that I've found on here and nothing is working >.< Can someone help me align these text boxes? Any help is greatly appreciated!
<h1>Registration</h1>
<div class="containter">
<form name=registration>
Username: <input type="text" name="username" value="">
<br><br> Password: <input type="text" name="password" value="">
<br><br> First Name: <input type="text" name="firstName" value="">
<br><br> Last Name: <input type="text" name="lastName" value="">
<br><br> Date of Birth: <input type="text" name="bDay" value="">
<br><br> Email: <input type="text" name="email" value="">
<br><br> Phone Number: <input type="text" name="firstName" value="">
<br><br>
</form>
</div>
You can just put it in a table:
<body>
<h1>Registration</h1>
<div class="containter">
<form name=registration>
<table style="width:100%">
<tr>
<td>Username: </td><td><input type="text" name="username" value=""></td>
</tr>
<tr>
<td>Password: </td><td><input type="text" name="password" value=""></td>
</tr>
<tr>
<td>First Name:</td><td> <input type="text" name="firstName" value=""></td>
</tr>
<tr>
<td>Last Name: </td><td><input type="text" name="lastName" value=""></td>
</tr>
<tr>
<td>Date of Birth: </td><td><input type="text" name="bDay" value=""></td>
</tr>
<tr>
<td>Email: </td><td><input type="text" name="email" value=""></td>
</tr>
<tr>
<td>Phone Number: </td><td><input type="text" name="firstName" value=""></td>
</tr>
</form>
</div>
You may want to use bootstrap and this is what you could get. Checkout this codepen
Bootstrap is used by a lot of companies and is an easier way to create responsive forms
<html>
<head>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
</head>
<body>
<h1>Registration</h1>
<form name=registration>
<div class="containter">
<div class="form-group row">
<label class="col-sm-2 col-form-labe">Username:</label>
<div class="col-sm-10">
<input class="form-control" type="text" name="username" value="" />
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-labe">Password:</label>
<div class="col-sm-10">
<input class="form-control" type="text" name="password" value="" />
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-labe">First Name:</label>
<div class="col-sm-10">
<input class="form-control" type="text" name="firstName" value="" />
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-labe">Last Name:</label>
<div class="col-sm-10">
<input class="form-control" type="text" name="lastName" value="">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-labe">Date of Birth:</label>
<div class="col-sm-10">
<input class="form-control" type="date" name="bDay" value="" />
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-labe">Email:</label>
<div class="col-sm-10">
<input class="form-control" type="email" name="email" value="">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-labe">Phone Number:</label>
<div class="col-sm-10">
<input class="form-control" type="text" name="firstName" value="" />
</div>
</div>
</div>
</form>
</body>
</html>

Pass Multiple Data Parameters to Bootstrap Modal

I have a dynamic data table with a button that launches a Bootstrap Modal. In the modal is a form. I need the softwareID to pass from the page to the modal to a hidden field in the form. My modal opens and the form displays fine but, the softwareID field is empty. I have searched the Internet trying all types of code and nothing seems to work. Any help would be appreciated. Thank you.
Here is my code so far:
<div class="col">
<!-- Button trigger modal -->
<script type="text/javascript">
$('#upload').on('show.bs.modal', function (event) {
var myVal = $(event.relatedTarget).data('softwareID');
$(this).find(".modal-body").text(myVal);
});
</script>
<?php
if (("".($district_results_private->getColumnVal("paid") ."" == "Y") and "".($logged_user->getColumnVal("tec_member") ."" == "Y")) or ("".$_GET['state'] ."" != "MA" and ("".($logged_user->getColumnVal("tec_member") ."" == NULL) or "".($logged_user->getColumnVal("tec_member") ."" == "N")) and "".$_GET['state'] ."" != "NH" and "".$_GET['state'] ."" != "RI")) { // WebAssist Show If
?> <button data-softwareID="<?php echo($district_results_private->getColumnVal("softwareID")); ?>" type="button" class="btn-sm btn-primary" data-toggle="modal" data-target="#upload">Create New Request</button><?php
} // ("".($district_results_private->getColumnVal("paid") ."" == "Y") and "".($logged_user->getColumnVal("tec_member") ."" == "Y")) or ("".$_GET['state'] ."" != "MA" and ("".($logged_user->getColumnVal("tec_member") ."" == NULL) or "".($logged_user->getColumnVal("tec_member") ."" == "N")) and "".$_GET['state'] ."" != "NH" and "".$_GET['state'] ."" != "RI")
?>
<!-- Modal -->
<form enctype="multipart/form-data" method="post">
<div class="modal fade" id="upload" tabindex="-1" role="dialog" aria-labelledby="uploadlLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="uploadLabel">Create New Request</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Cancel"> <span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<label for="supporting_files">Please fill out the following optional information:</label>
<br><br>
<div class="input-group mb-3 col-sm">
<div class="input-group-prepend"> <span class="input-group-text" id="basic-addon12">Principal/Dean</font></span></div>
<input name="principal_dean" type="text" class="form-control col-md-8" id="principal_dean" value="" date_approved="principal_dean" title="Principal/Dean">
</div>
<div class="input-group mb-3 col-sm">
<div class="input-group-prepend"> <span class="input-group-text" id="basic-addon10">Paid By</span></div>
<input name="paid_by" type="text" class="form-control col-md-8" id="paid_by" value="" title="Paid By">
</div>
<div class="input-group mb-3 col-sm">
<div class="input-group-prepend"> <span class="input-group-text" id="basic-addon11">Cost</span></div>
<input name="cost" type="text" class="form-control col-md-4" id="cost" value="" title="Cost">
</div>
<p> </p>
<div class="input-group mb-3 col-sm">
<div class="input-group-prepend"> <span class="input-group-text" id="basic-addon7"><font color="#339933">Grades</font></span></div>
<label for="grade_level3"><i><font size="-1">Check all that apply</font></i></label>
<table width="60%" class="table table-striped">
<tr>
<td scope="row"><label>
<input type="checkbox" name="grade_level[]" value="K" id="grade_level_0" />
K</label></td>
<td scope="row"><label>
<input type="checkbox" name="grade_level[]" value="1" id="grade_level_1" />
1</label></td>
<td scope="row"><label>
<input type="checkbox" name="grade_level[]" value="2" id="grade_level_2" />
2</label></td>
<td scope="row"><label>
<input type="checkbox" name="grade_level[]" value="3" id="grade_level_3" />
3</label></td>
</tr>
<tr>
<td><label>
<input type="checkbox" name="grade_level[]" value="4" id="grade_level_4" />
4</label></td>
<td><label>
<input type="checkbox" name="grade_level[]" value="5" id="grade_level_5" />
5</label></td>
<td><label>
<input type="checkbox" name="grade_level[]" value="6" id="grade_level_8" />
6</label></td>
<td><label>
<input type="checkbox" name="grade_level[]" value="7" id="grade_level_7" />
7</label></td>
</tr>
<tr>
<td><label>
<input type="checkbox" name="grade_level[]" value="8" id="grade_level_8" />
8</label></td>
<td><label>
<input type="checkbox" name="grade_level[]" value="9" id="grade_level_9" />
9</label></td>
<td><label>
<input type="checkbox" name="grade_level[]" value="10" id="grade_level_10" />
10</label></td>
<td><label>
<input type="checkbox" name="grade_level[]" value="11" id="grade_level_11" />
11</label></td>
</tr>
<tr>
<td><label>
<input type="checkbox" name="grade_level[]" value="12" id="grade_level_12" />
12</label></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</div>
<div class="input-group mb-3 col-sm">
<div class="input-group-prepend"> <span class="input-group-text" id="basic-addon8"><font color="#339933">Content Area</font></span></div>
<label for="grade_level4"><i><font size="-1">Check all that apply</font></i></label>
<table width="80%" class="table table-striped">
<tr>
<td width="50%" valign="top"><label>
<input type="checkbox" name="content_area[]" value="English Language Arts" id="content_area_0" />
English Language Arts</label></td>
<td width="50%" valign="top"><label>
<input type="checkbox" name="content_area[]" value="Health" id="content_area_1" />
Health</label></td>
</tr>
<tr>
<td width="50%" valign="top"><label>
<input type="checkbox" name="content_area[]" value="Instructional Technology" id="content_area_2" />
Instructional Technology</label></td>
<td width="50%" valign="top"><label>
<input type="checkbox" name="content_area[]" value="Library Media" id="content_area_3" />
Library Media</label></td>
</tr>
<tr>
<td width="50%" valign="top"><label>
<input type="checkbox" name="content_area[]" value="Math" id="content_area_4" />
Math</label></td>
<td width="50%" valign="top"><label>
<input type="checkbox" name="content_area[]" value="Science" id="content_area_6" />
Science</label></td>
</tr>
<tr>
<td width="50%" valign="top"><label>
<input type="checkbox" name="content_area[]" value="Physical Education" id="content_area_5" />
Physical Education</label></td>
<td width="50%" valign="top"><label>
<input type="checkbox" name="content_area[]" value="Visual Performing Arts" id="content_area_8" />
Visual Performing Arts</label></td>
</tr>
<tr>
<td width="50%" valign="top"><label>
<input type="checkbox" name="content_area[]" value="Social Science" id="content_area_7" />
Social Science</label></td>
<td width="50%" valign="top"><label>
<input type="checkbox" name="content_area[]" value="Other" id="content_area_10" />
Other</label></td>
</tr>
<tr>
<td width="50%" valign="top"><label>
<input type="checkbox" name="content_area[]" value="World Language" id="content_area_9" />
World Language</label></td>
<td width="50%" valign="top"><label>
<input type="checkbox" name="content_area[]" value="Computer Science" id="content_area_10" />
Computer Science</label></td>
</tr>
</table>
</div>
<div class="input-group mb-2 col-sm">
<div class="input-group-prepend"></div>
<input title="Requires Media Release" type="text" class="form-control" value="Requires Media Release?" aria-label="Requires Media Release?">
<div class="input-group-text"> Yes
<input name="media_release" type="checkbox" value="Y" aria-label="Requires Media Release">
</div>
</div><br>
<div class="input-group mb-3 col-sm">
<div class="input-group-prepend"> <span class="input-group-text" id="basic-addon12">Purpose</font></span></div>
<textarea class="form-control col-md-5" aria-label="With textarea" name="purpose"></textarea>
</div><br>
<p><strong>VENDOR CONTACT'S INFORMATION</strong> (optional)</p>
<div class="input-group mb-3 col-sm">
<div class="input-group-prepend"> <span class="input-group-text" id="basic-addon3">Contact Name</span></div>
<input title="Contact" name="contact" type="text" class="form-control col-md-8" id="contact" value="" aria-describedby="basic-addon3" placeholder="">
</div>
<div class="input-group mb-3 col-sm">
<div class="input-group-prepend"> <span class="input-group-text" id="basic-addon4">Contact Email</span></div>
<input title="Email" name="contact_email" type="email" class="form-control col-md-8" id="contact_email" value="" aria-describedby="basic-addon3" placeholder="Enter a valid email address.">
</div>
<div class="input-group mb-3 col-sm">
<div class="input-group-prepend"> <span class="input-group-text" id="basic-addon5">Contact Phone</span></div>
<input name="phone" type="text" class="form-control col-md-8" id="phone" value="" aria-describedby="basic-addon3" placeholder="" title="phone">
</div>
<div class="modal-footer">
<input name="statusID" type="hidden" value="6">
<input name="request_submitted_date" type="hidden" id="request_submitted_date" value="<?php echo date('Y-m-d'); ?>" />
<input type="hidden" name="districtID" id="districtID" value="<?php echo($logged_user->getColumnVal("districtID")); ?>">
<input type="text" name="softwareID" id="softwareID" value="">
<button class="btn btn-info" type="submit" name="submit" id="submit">Save New Request</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div></div>
</form>
</div>

How to generate new upload button in real time

I have a simple contact form with a file upload option built in. However, it only has 1 "Browse" button, and I want there to be unlimited. But instead of duplicating the "Browse" code a bunch of times, I'd rather it create a NEW browse button once the user has used the old one (uploaded a file).
How do I create another button in real-time?
Here is a full demo of the form: http://www.html-form-guide.com/files/contact-form/contact-form-attachment-1/contactform.php
The form's code is below, my question relates to upload button. Thank you!!
<form id='contactus' action='<?php echo $formproc->GetSelfScript(); ?>' method='post' enctype="multipart/form-data" accept-charset='UTF-8'>
<fieldset >
<legend>Describe the issue:</legend>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<input type='hidden' name='<?php echo $formproc->GetFormIDInputName(); ?>' value='<?php echo $formproc->GetFormIDInputValue(); ?>'/>
<input type='text' class='spmhidip' name='<?php echo $formproc->GetSpamTrapInputName(); ?>' />
<div class='short_explanation'>*All fields are required.</div>
<div><span class='error'><?php echo $formproc->GetErrorMessage(); ?></span></div>
<div class='container'>
<label for='name' >Full Name: </label><br/>
<input type='text' name='name' id='name' value='<?php echo $formproc->SafeDisplay('name') ?>' maxlength="50" /><br/>
<span id='contactus_name_errorloc' class='error'></span>
</div>
<div class='container'>
<label for='email' >Email Address:</label><br/>
<input type='text' name='email' id='email' value='<?php echo $formproc->SafeDisplay('email') ?>' maxlength="50" /><br/>
<span id='contactus_email_errorloc' class='error'></span>
</div>
<div class='container'>
<label for='message' >Message:</label><br/>
<span id='contactus_message_errorloc' class='error'></span>
<textarea rows="10" cols="50" name='message' id='message'><?php echo $formproc->SafeDisplay('message') ?></textarea>
</div>
<div class='container'>
<label for='photo' >Upload your file:</label><br/>
<input type="file" name='photo' id='photo' /><br/>
<span id='contactus_photo_errorloc' class='error'></span>
</div>
<div class='container'>
<input type='submit' name='Submit' value='Submit' />
</div>
</fieldset>
</form>
Suppose you have one upload button in html like this:
<body>
<form>
<input type="file" name="upload1" id="upload1"/>
</form>
</body>
Then, you can add another upload button on Click event on previous button using jquery:
$(function(){
$('#upload1').on('click',function(){
var r= $('<input type="file" value="new button"/>');
$("form").append(r);
});
});
JSFIDDLE DEMO HERE
If you are not familiar with how to use Jquery, This is the place where you can learn:Learn jquery

PHP Image Upload Problem

Getting Undefined index: filename error in the below image upload php code. Is there any problem in the below code?
<div id="content">
<form class="wufoo" action=<?php echo (BASE_PATH. 'admin/addbusinessdetail'); ?> method="post">
<input type="hidden" name="maxSize" value="9999999999" />
<input type="hidden" name="maxW" value="200" />
<input type="hidden" name="fullPath" value="<?php echo (BASE_PATH. 'public/img/uploads/'); ?>" />
<input type="hidden" name="relPath" value="<?php echo (BASE_PATH. 'public/img/uploads/'); ?>" />
<input type="hidden" name="colorR" value="255" />
<input type="hidden" name="colorG" value="255" />
<input type="hidden" name="colorB" value="255" />
<input type="hidden" name="maxH" value="300" />
<ul>
<li>
<label class="desc">Business Type</label>
<br />
<div>
<select class="field select" name="ddltype" style="width:300px; height: 30px;">
<?php
$types = $this->_data;
foreach ($types as $value) {
foreach($value as $innvalue){
$businessname[] = $innvalue;
}
echo('<option value="'.$businessname[0].'">'.$businessname[1].'</option>');
unset($businessname);
}
?>
</select>
</div>
</li>
<li>
<label class="desc">Business Detail <span class="req">*</span></label>
<br />
<div>
<input type="text" class="field text" name="businessname" style="width: 300px; height: 20px;" />
</div>
</li>
<li>
<label class="desc">Business Website <span class="req">*</span></label>
<br />
<div>
<input type="text" class="field text" name="website" style="width: 300px; height: 20px;" />
</div>
</li>
<li>
<label class="desc">Business Email <span class="req">*</span></label>
<br />
<div>
<input type="text" class="field text" name="email" style="width: 300px; height: 20px;" />
</div>
</li>
<li>
<label class="desc">Business Image <span class="req">*</span></label>
<br />
<div>
<input type="file" name="filename" />
</div>
</li>
<li>
<label class="desc">Address <span class="req">*</span></label>
<br />
<div>
<textarea name="address" cols="50" rows="8" ></textarea>
</div>
</li>
<li class="buttons">
<input class="submit" type="submit" value="Save" /> <input class="submit" type="button" value="Cancel" onClick="history.back()" />
</li>
</ul>
</form>
addbusinessdetail controller
function addbusinessdetail()
{
print_r($_FILES['filename']);
$this->Admin->addbusinessdetail();
$this->businessdetails(0,0);
}
add this to your form tag:
enctype="multipart/form-data"
If you're doing a file upload, you need this form attribute so the web server knows to expect file data.Here's some more info on file uploads: http://www.tizag.com/phpT/fileupload.php