Currently I have created a form on a PHP form that posts to the send PHP code. All of the textareas/fields ETC work fine. The issue I have is that I have 3 file fields. The aim is to add 3 file attachments to the email. I just cant work out how to do it.
(Attachment areas at the bottom of the form)
<form method="post" action="quote_send.php">
<form class="form-light mt-20" role="form">
<div class="form-group">
<label>Title</label><br />
<select name="Title">
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Ms">Ms</option>
</select>
</div> <div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Forename</label>
<input type="text" class="form-control" name="forename" placeholder="Your Forename">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Surname</label>
<input type="text" class="form-control" name="surname" placeholder="Your Surname">
</div>
</div>
</div>
<!----CONTACT DETAILS------>
<h3>Your Contact Details</h3>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Email Address</label>
<input type="text" class="form-control" name="visitormail" placeholder="Your Email Address">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Contact Number</label>
<input type="text" class="form-control" name="number" placeholder="Your Contact Number">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Address Line 1</label>
<input type="text" class="form-control" name="address1" placeholder="Address Line 1">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Address Line 2</label>
<input type="text" class="form-control" name="address2" placeholder="Address Line 2">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>City</label>
<input type="text" class="form-control" name="city" placeholder="City">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>Post Code</label>
<input type="text" class="form-control" name="pcode" placeholder="Post Code">
</div>
</div>
</div>
<!----SITE DETAILS----->
<h3>Site Contact Details</h3>
<div class="form-group">
<label>Title</label><br />
<select name="siteTitle">
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Ms">Ms</option>
</select>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Site Contact Forename</label>
<input type="text" class="form-control" name="scforename" placeholder="Site Contact Forename">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Site Contact Surname</label>
<input type="text" class="form-control" name="scsurname" placeholder="Site Contact Surname">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Email Address</label>
<input type="text" class="form-control" name="scvisitormail" placeholder="Site Email Address">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Contact Number</label>
<input type="text" class="form-control" name="scnumber" placeholder="Site Contact Number">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Address Line 1</label>
<input type="text" class="form-control" name="scaddress1" placeholder="Site Address Line 1">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Address Line 2</label>
<input type="text" class="form-control" name="scaddress2" placeholder="Site Address Line 2">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>City</label>
<input type="text" class="form-control" name="sccity" placeholder="City">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>Post Code</label>
<input type="text" class="form-control" name="scpcode" placeholder="Post Code">
</div>
</div>
</div>
<!----SITE DETAILS----->
<h3>Site Details</h3>
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label>Number of Domestic Plots</label><br />
<select name="numdp">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5+">5+</option>
</select></div></div>
<div class="col-md-2">
<div class="form-group">
<label>Number of Commercial Plots</label><br />
<select name="numcp">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5+">5+</option>
</select>
</div></div>
<div class="col-md-2">
<div class="form-group">
<label>Is The Site Visit Required?</label><br />
<select name="sitevisitr">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div></div>
<div class="col-md-3">
<div class="form-group">
<label>Is The Site a Brownfield/Regeneration?</label><br />
<select name="brownregen">
<option value="Brownfield">Brownfield</option>
<option value="Regeneration">Regeneration</option>
</select>
</div></div>
<div class="col-md-3">
<div class="form-group">
<label>Is The Site Contaminated?</label><br />
<select name="contam">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div></div>
<div class="col-md-2">
<div class="form-group">
<label>Property Type</label><br />
<select name="proptype">
<option value="Commercial">Commercial</option>
<option value="Flat">Flat</option>
<option value="Detached">Detached</option>
<option value="Semi-Detached">Semi-Detached</option>
<option value="Terraced">Terraced</option>
</select>
</div></div>
<div class="col-md-2">
<div class="form-group">
<label>Rooms In The Property</label><br />
<select name="nrooms">
<option value="N/A">N/A</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10+">10+</option>
</select>
</div></div>
<div class="col-md-2">
<div class="form-group">
<label>Do You Have A Gas Supplier? *</label><br />
<select name="gsupplier">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div></div>
<div class="col-md-3">
<div class="form-group">
<label>If Yes. Who Is Your Gas Supplier?</label>
<input type="text" class="form-control" name="gsuppliername" placeholder="Gas Supplier">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Who Will Be Carrying Out The Excavation?</label><br />
<select name="erxcav">
<option value="MDL">MDL</option>
<option value="Customer">Customer</option>
</select>
</div></div>
<br /><p> * NOTE: If you do not have a gas supplier in place, you will need to obtain one before any works can be carried out. You can find a gas supplier here.</p>
<div class="col-md-2">
<div class="form-group">
<label>What Service Do You Require?</label><br />
<select name="servicer">
<option value="Gas Connection(s)">Gas Connection(s)</option>
<option value="Gas Disconnection(s)">Gas Disconnection(s)</option>
<option value="Meter Fitting / Exchange">Meter Fitting / Exchange</option>
<option value="Directional Drilling">Directional Drilling</option>
<option value="Outlet Pipework">Outlet Pipework</option>
</select>
</div></div>
<div class="col-md-3">
<div class="form-group">
<label>What Is Your Hourly Load? (KWh)</label>
<input type="text" class="form-control" name="hourl" placeholder="Hourly Load (KWh)">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>What Is Your Annual Load? (KWh)</label>
<input type="text" class="form-control" name="annl" placeholder="Annual Load? (KWh)">
</div>
</div> <br /><br /><br /><br />
<p> * NOTE: We require specific documents so we can proceed with your quote. These documents can be seen in the upload section below</p>
<div class="col-md-4">
<div class="form-group">
<label>Scaled Site Location Plan</label>
<input name="sslp" type="file">
</div></div>
<div class="col-md-4">
<div class="form-group">
<label>Domestic Property Schedule</label>
<input name="dps" type="file">
</div></div>
<div class="col-md-4">
<div class="form-group">
<label>Site Boundary Drawing</label>
<input name="sbd" type="file">
</div></div>
<p> * NOTE: We require specific documents so we can proceed with your quote. These documents can be seen in the upload section below</p>
<div class="col-md-6">
<div class="form-group">
<label>Is There Any Other Information You Think Would Help Us?</label><br />
<textarea class="form-control" name="notes" placeholder="Write you message here..." style="height:100px;"></textarea>
</div></div>
</div>
<br / >
<button type="submit" class="btn btn-two">SUBMIT</button>
</form>
THE PHP send code.-----------------------
<?php
$Title = $_POST['Title'];
$forename = $_POST['forename'];
$surname = $_POST['surname'];
$visitormail = $_POST['visitormail'];
$number = $_POST['number'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$pcode = $_POST['pcode'];
$siteTitle = $_POST['siteTitle'];
$scforename = $_POST['scforename'];
$scsurname = $_POST['scsurname'];
$scvisitormail = $_POST['scvisitormail'];
$scnumber = $_POST['scnumber'];
$scaddress1 = $_POST['scaddress1'];
$scaddress2 = $_POST['scaddress2'];
$sccity = $_POST['sccity'];
$scpcode = $_POST['scpcode'];
$numdp = $_POST['numdp'];
$numcp = $_POST['numcp'];
$sitevisitr = $_POST['sitevisitr'];
$brownregen = $_POST['brownregen'];
$contam = $_POST['contam'];
$proptype = $_POST['proptype'];
$nrooms = $_POST['nrooms'];
$gsupplier = $_POST['gsupplier'];
$gsuppliername = $_POST['gsuppliername'];
$erxcav = $_POST['erxcav'];
$servicer = $_POST['servicer'];
$hourl = $_POST['hourl'];
$annl = $_POST['annl'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
$sslp = $_POST['sslp'];
$dps = $_POST['dps'];
$sbd = $_FILES['sbd'];
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"#") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}
if(empty($forename) || empty($visitormail) || empty($notes )) {
echo "<h2>You have missed out required fields, please go back to them and fill them in</h2>\n";
die ("Use back! ! ");
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = "New $servicer Quote Request";
$notes = stripcslashes($notes);
$message = "Section 1 - Customer Details \n
Customer Title: $Title
Customer Forname: $forename
Customer Surname: $surname
Customer Email: $visitormail
Customer Contact Number: $number
Contact Postal Address:\n $address1 \n $address2 \n $city \n $pcode \n
Section 2 - Site Contact Details \n
Site Contact Title: $siteTitle
Site Contact Forname: $scforename
Site Contact Surname: $scsurname
Site Contact Email Address: $scvisitormail
Site Contact Number: $scnumber
Site Current Postal Address:\n $scaddress1 \n $scaddress2 \n $sccity \n $scpcode \n
Section 3 - Site Work Details \n
Number of Domestic Plots: $numdp
Number of Commercial Plots: $numcp
Site Visit Required: $sitevisitr
Site a Brownfield/Regeneration: $brownregen
Site Contaminated: $contam
Property Type: $proptype
Number of Rooms in The Property: $nrooms
Gas Supplier Organised: $gsupplier
Gas Supplier Name: $gsuppliername
Who Will Be Carrying Out The Excavation: $erxcav
Service Rquired: $servicer
Hourly Load: $hourl
Annual Load: $annl
Extra Information: $notes
Attached Files: $sslp \n $dps \n $sbd
Please reply to this email within 24 hours to maximise our chances of turning enquiries in to sales.
";
$_FILES ="$sbd";
$from = "From: $visitormail\r\n";
mail("ash.manterfield#btinternet.com", $subject, $message, $from, $_FILES);
?>
</span>Thank you <?php echo $visitor ?> for contacting us regarding <?php echo $attn ?>.
Any help would be appreciated I've tried a few approaches and cant work out how to do it.
Related
i am trying to add data from form with get method but when i submit it, datas doesnt show up in the url like this
addcustomers_token=vkmH0qnA6g2mfVcQzYUU3ZE0ZQvkQYs4DuCtKteX&company_name=Hebert+Frank+Inc&customer_name=Beau+Nixon&customer_surname=Schneider&customer_phone1=19655489736&customer_phone2=16612429699&customer_phone3=14871428281&customer_email1=qycuhuva%40mailinator.com&customer_score=2&customer_job=Doloribus+facilis+no&customer_gender=Woman&customer_source=Tawk+Canlı+Destek&user_id=1&user_company_id=1&tag_id=1&company_id=1
but its shows like that
/addcustomers
my controller
public function store(Request $req)
{
//
// Form validation (Zorunlu Alanlar)
$this->validate(request(), [
'customer_phone1' => 'required',
]);
$customers = new Customers;
$customers->customer_name = $req->input('customer_name');
$customers->customer_surname = $req->input('customer_surname');
$customers->customer_phone1 = $req->input('customer_phone1');
$customers->customer_phone2 = $req->input('customer_phone2');
$customers->customer_phone3 = $req->input('customer_phone3');
$customers->customer_email1 = $req->input('customer_email1');
$customers->customer_score = $req->input('customer_score');
$customers->customer_job = $req->input('customer_job');
$customers->customer_gender = $req->input('customer_gender');
$customers->customer_source = $req->input('customer_source');
$customers->customer_ref = "";
$customers->company_id = $req->input('company_id');
$customers->user_company_id = $req->input('user_company_id');
$customers->user_id = $req->input('user_id');
$customers->tag_id = $req->input('tag_id');
if(!empty($req->company_name)){
$companies = new Companies;
$companies->company_name = $req->input('company_name');
$companies->company_type = "";
$companies->company_address = "";
$companies->company_country = "";
$companies->company_city = "";
$companies->company_phone = "";
$companies->company_email = "";
$companies->company_tax_office = "";
$companies->company_tax_no = "";
$companies->company_website = "";
$companies->company_score = "";
$companies->company_status = "";
$companies->user_company_id = "1";
$companies->user_id = $req->input('user_id');
$companies->tag_id = "1";
$companies->updateTimestamps();
$companies->save();}
$customers->updateTimestamps();
$customers->save();
return redirect()->back()->with('success', true);
}
related routes
Route::get('/addcustomers', function () {
$companies = App\Models\Companies::all();
return view('addcustomers' , compact('companies'));
});
Route::get('/addcustomers2', [App\Http\Controllers\CustomersController::class, 'store']);
my form
<form action="/add-customers2" method="GET">
#csrf
<div class="row">
<div class="col-md-12 mb-4">
<label> <strong> Company Name </strong></label>
<input type="text" name="company_name" class="form-control" placeholder="Company Name">
</div>
<div class="col-md-6 mb-4">
<label> <strong> Customer Name </strong></label>
<input type="text" name="customer_name" class="form-control" placeholder="Customer Name">
</div>
<div class="col-md-6 mb-4">
<label> <strong> Customer Surname </strong></label>
<input type="text" name="customer_surname" class="form-control"
placeholder="Customer Surname">
</div>
<div class="col-md-4 mb-4">
<label> <strong>Phone 1</strong> *</label>
<input type="text" maxlength="11"
oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');"
name="customer_phone1" class="form-control" placeholder="Phone" reqiured>
</div>
<div class="col-md-4 mb-4">
<label> <strong> Phone 2 </strong></label>
<input type="text" maxlength="11"
oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');"
name="customer_phone2" class="form-control" placeholder="Phone">
</div>
<div class="col-md-4 mb-4">
<label> <strong> Phone 3 </strong></label>
<input type="text" maxlength="11"
oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');"
name="customer_phone3" class="form-control" placeholder="Phone">
</div>
<div class="col-md-6 mb-4">
<label> <strong> Customer Email </strong></label>
<input type="text" name="customer_email1" class="form-control" placeholder="Email">
</div>
<div class="form-group col-md-6 mb-4 ">
<label class="control-label" for="customer_score"> <strong> Customer Score
</strong></label>
<select class="form-control " name="customer_score">
<option selected="true" disabled="disabled" hidden>Choose..</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<div class="col-md-6 mb-4">
<label> <strong> Customer Job </strong></label>
<input type="text" name="customer_job" class="form-control" placeholder="Customer Job">
</div>
<!--
<div class="col-md-6 mb-4">
<label> <strong> Call Later </strong></label>
<input type="text" name="call_later" class="form-control" placeholder="Call Later">
</div>
-->
<div class="form-group col-md-6 mb-4 ">
<label class="control-label" for="customer_gender"> <strong> Customer Gender
</strong></label>
<select class="form-control select2" name="customer_gender">
<option value="Man" selected="selected">Man</option>
<option value="Woman">Woman</option>
</select>
</div>
<div class="form-group col-md-12 mb-4 ">
<label class="control-label" for="customer_source"> <strong> Customer Source
</strong></label>
<select class="form-control " name="customer_source">
<option selected="true" disabled="disabled" hidden >Choose..</option>
<option value="Gelen Arama">Gelen Arama</option>
<option value="Tawk Canlı Destek">Tawk Canlı Destek</option>
<option value="WhatsApp">WhatsApp</option>
<option value="Formlar">Formlar</option>
<option value="E-Posta">E-Posta</option>
<option value="Referans">Referans</option>
</select>
</div>
<!--
<div class="col-md-6 mb-4">
<label> <strong> Customer Ref </strong></label>
<input type="text" name="customer_ref" class="form-control" placeholder="City">
</div>
-->
<?php $userId = Auth::id(); ?>
<input type="hidden" name="user_id" class="form-control" value="<?php echo $userId; ?>">
<input type="hidden" name="user_company_id" class="form-control" value="1">
<input type="hidden" name="tag_id" class="form-control" value="1">
<input type="hidden" name="company_id" class="form-control" value="1">
<button type="submit" class="btn btn-dark mb-3 ">Kaydet</button>
</div>
</form>
and i want to add records to database and redirect back to /addcustomers url
what am i doing wrong ?
Most likely why you see /addcustomers in the url is because after the submission you have:
return redirect()->back()->with('success', true);
I suppose your blade/html form submission page is on /addcustomers, and after you submit it to /addcustomers2 it redirects back to /addcustomers due to the above code. You can confirm this by opening the inspector on your browser and checking the networking tab (you might need to click an option to keep the history). There you will probably see the /addcustomers2 with all the parameters.
As others said you should use POST and rename your routes:
GET /addcustomers -> GET /customers
GET /addcustomers2 -> POST /customer
This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 3 years ago.
My form throws an error in PHP when submitting form data via email. Not sure what I did wrong/am missing.
Form:
<div class="row">
<div class="col">
<form id="msform" action="submit.php" method="post" data-autosubmit>
<!-- Step 1 -->
<fieldset>
<h2 class="fs-title">Step 1</h2>
<h3 class="fs-subtitle">Tell us about your device.</h3>
<div class="form-group">
<label for="brand">Brand</label>
<select class="form-control" id="brand" name="brand" required>
<option value="" selected data-default>- Device Brand -</option>
<option value="Apple">Apple</option>
<option value="Samsung">Samsung</option>
</select>
</div>
<div class="form-group">
<label for="model">Model</label>
<select class="form-control" id="model" name="model" required>
<option value="" selected data-default>- Device Model -</option>
<option value="iPhone 8">iPhone 8</option>
<option value="iPhone X">iPhone X</option>
<option value="Galaxy S8">Galaxy S8</option>
<option valaue="Galaxy S9">Galaxy S9</option>
<option value="Galaxy S10">Galaxy S10</option>
</select>
</div>
<div class="form-group">
<label for="variant">Storage</label>
<select class="form-control" id="variant" name="variant" required>
<option value="" selected data-default>- Storage Size -</option>
<option value="iPhone 8 - 64GB">iPhone 8 - 64GB</option>
<option value="iPhone 8 - 256GB">iPhone 8 - 256GB</option>
<option value="iPhone X - 64GB">iPhone X - 64GB</option>
<option value="iPhone X - 256GB">iPhone X - 256GB</option>
<option value="Galaxy S8 - 64GB">Galaxy S8 - 64GB</option>
<option valaue="Galaxy S9 - 64GB">Galaxy S9 - 64GB</option>
<option value="Galaxy S10 - 128GB">Galaxy S10 - 128GB</option>
</select>
</div>
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<!--Step 1 End-->
<!--Step 2-->
<fieldset>
<h2 class="fs-title">Step 2</h2>
<h3 class="fs-subtitle">Now we need to know more about your device's condition.</h3>
<div class="form-group">
<label for="screen">How is your device's <b>screen</b>?</label>
<select class="image-picker form-control" id="screen" name="screen" required>
<option value="0" data-img-src="">Flawless, no scratches!</option>
<option value="1" data-img-src="">1-2 light scratches</option>
<option value="2" data-img-src="">3 or more scratches</option>
<option value="3" data-img-src="">Cracked or damaged</option>
</select>
</div>
<div class="form-group">
<label for="body">How is your device's <b>housing</b>?</label>
<select class="form-control" id="body" name="body" required>
<option value="0">Flawless, no scratches or bends!</option>
<option value="1">1-2 light scratches</option>
<option value="2">3 or more scratches</option>
<option value="3">Bent or severely damaged</option>
</select>
</div>
<div class="form-group">
<label for="power">Is your device able to <b>power on</b>?</label>
<select class="form-control" id="power" name="power" required>
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<input type="button" name="previous" class="previous action-button-previous" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<!--Step 2 End-->
<!--Step 3-->
<fieldset>
<h2 class="fs-title">Step 3</h2>
<h3 class="fs-subtitle">Just a little more information needed, almost there!</h3>
<div class="form-group">
<label for="battery">Does your device have a faulty battery?</label>
<select class="form-control" id="battery" name="battery" required>
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<div class="form-group">
<label for="charge">Is your device able to <b>charge</b>?</label>
<select class="form-control" id="charge" name="charge" required>
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<div class="form-group">
<label for="calls">Is your device able to <b>make and receive calls</b>?</label>
<select class="form-control" id="calls" name="calls">
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<div class="form-group">
<label for="fcamera">Does your <b>front camera work</b>?</label>
<select class="form-control" id="fcamera" name="fcamera">
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<div class="form-group">
<label for="rcamera">Does your <b>rear camera work</b>?</label>
<select class="form-control" id="rcamera" name="rcamera">
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<div class="form-group">
<label for="water">Is your device <b>water damaged</b>?</label>
<select class="form-control" id="water" name="water">
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<div class="form-group">
<label for="wifi">Is your device able to connect using WiFi?</label>
<select class="form-control" id="wifi" name="wifi">
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<input type="button" name="previous" class="previous action-button-previous" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" onclick="getFinalPrice();" />
</fieldset>
<!--End Step 3-->
<!--Final-->
<fieldset>
<h2 class="fs-title">Value</h2>
<h3 class="fs-subtitle">Here's how much we can offer for your device.</h3>
<h2 id="finalValue"></h2>
<hr>
<h3 class="fs-subtitle">If you're happy with our offer, please fill in your contact details below and we'll arrange for free a pickup of your device.</h3>
<div class="form-group">
<label for="firstname">Name</label>
<input type="text" class="form-control" placeholder="Full Name" name="name" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" placeholder="example#example.com" name="email" required>
</div>
<div class="form-group">
<label for="number">Phone Number</label>
<input type="number" class="form-control" placeholder="91234567" name="number" required>
<small id="numberHelp" class="form-text text-muted">We'll never share your email and phone number with anyone else.</small>
</div>
<input type="button" name="previous" class="previous action-button-previous" value="Previous" />
<input type="submit" name="submit" class="submit action-button" value="Submit" />
</fieldset>
<!--Final End-->
</form>
</div>
</div>
<!-- /.MultiStep Form -->
</body>
</html>
PHP Script:
<?php
$name = $_POST['name'];
$number = $_POST['number'];
$email = $_POST['email'];
$brand = $_POST['brand'];
$model = $_POST['model'];
$variant = $_POST['variant'];
$screen = $_POST['screen'];
$body = $_POST['body'];
$power = $_POST['power'];
$battery = $_POST['battery'];
$charge = $_POST['charge'];
$calls = $_POST['calls'];
$fcamera = $_POST['fcamera'];
$rcamera = $_POST['rcamera'];
$water = $_POST['water'];
$wifi = $_POST['wifi'];
$formcontent = "From: $name \n Contact: $number \n Device Brand: $brand \n Device Model: $model \n Device Variant: $variant \n How is your device's screen? $screen \n How is your device's housing? $body \n Is your device able to power on? $power \n Does your device have a fault battery? $battery \n Is your device able to charge? $charge \n Does your front camera work? $fcamera \n Does your rear camera work? $rcamera \n Is your device water damaged? $water \n Is your device able to connect using WiFi? $wifi";
$recipient = "example#example.com";
$subject = "Buyback Request";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank you! We'll be in contact soon. You'll now be redirected back to our main webpage.";
/* Redirect browser */
header("Location: https://example.com");
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
I gave the input options all a name value so that PHP knows where to find the data. Not sure if this is the correct way of doing it.
Currently, the form always throws an error on submission.
All help is appreciated, thank you!
I have been trying to process the inputs of a web form which submits to itself. Everything works fine except for chrome android browser. The code works well when accessed through browsers on PC and other mobile browsers like UC Browser. But miserably fails in chrome android. The submit button and "post" requests are not set on the first run. And more strangely the same code works on same chrome browser when reloaded. help will be greatly appreciated.
This is the code supposed to catch the values submitted
?php
require_once('connect_db.php');
require_once('functions.php');
$timezone = "Asia/Kolkata";
date_default_timezone_set($timezone);
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $mysqli->real_escape_string($_REQUEST['name']);
$gender = $mysqli->real_escape_string($_REQUEST['gender']);
$dob = $mysqli->real_escape_string($_REQUEST['dob']);
// And Some more Variables managed here
}
?>
And here is the html form part
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" data-toggle="validator">
<div class="form-group">
<label for="name" class="control-label">Name:</label>
<input class="form-control" onfocusout="this.value = this.value.toUpperCase();" autofocus="autofocus" id="name" placeholder="Name" data-error="Enter Your Name" name="name" required="" type="text">
<div class="help-block with-errors"></div>
</div>
<div class="form-group w3ls-opt">
<label for="Gender" class="control-label">Gender</label> <label class="w3layouts"> <input name="gender" id="gender1" value="male" checked="checked" type="radio">Male
</label> <label class="w3layouts label2"> <input name="gender" id="gender2" value="female" type="radio">Female </label> <label class="w3layouts"> <input name="gender" id="gender3" value="other" type="radio">Other
</label>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="dob" class="control-label">Date of Birth</label>
<input class="form-control" id="dob" placeholder="dd/mm/yyyy" name="dob" required="" max="31/05/1995" data-error="Enter Your Date of Birth in dd/mm/yyyy format" type="text" pattern="\d{1,2}/\d{1,2}/\d{4}">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="inputEmail" class="control-label">Email:</label> <input class="form-control" style="text-transform:lowercase" id="inputEmail" placeholder="Email" data-error="Enter a valid Email" name="email" required="" type="email">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="parent" class="control-label">Name
of Father/Parent/Guardian/Husband</label> <input class="form-control" id="father" placeholder="Name of Father" name="father" onfocusout="this.value = this.value.toUpperCase();" required="" data-error="Enter Your Parent's Name" type="text">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="mother" class="control-label">Name
of Mother</label> <input class="form-control" onfocusout="this.value = this.value.toUpperCase();" id="mother" placeholder="Name of Mother" name="mother" required="" data-error="Enter Your Mother's Name" type="text">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="address1">Address</label>
<textarea class="form-control" rows="3" id="address1" onfocusout="this.value = this.value.toUpperCase();" name="address1" data-error="Enter Address" required=""></textarea>
<div class="help-block with-errors"></div>
</div>
<div class="form-group"> <label class="control-label" for="address2">Address</label>
<textarea class="form-control" rows="3" id="address2" onfocusout="this.value = this.value.toUpperCase();" name="address2" data-error="Enter Address" required="" readonly="readonly">
OTTATHARA
KODUP PO
PIN:676504</textarea>
</div>
<div class="form-group">
<label for="Phone" class="control-label">Phone:</label> <input class="form-control" name="phone" id="Phone" placeholder="Phone" data-error="Enter a valid Phone Number" required="" min="0000000000" max="99999999999" type="number">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="address">Course
Presently Studying</label>
<select class="form-control" id="course" name="course" required="">
<option value="" selected="selected">Select</option>
<option value="hsc">+2</option>
<option value="vhsc">VHSC</option>
<option value="diploma">Diploma</option>
<option value="graduation">Graduation</option>
<option value="professional">Professional Degree</option>
<option value="bed">B.Ed</option>
<option value="pg">Postgraduation</option>
<option value="mphil">M Phil</option>
<option value="research">Research</option>
<option value="certificate">Certificate Course</option>
<option value="others">Others</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="course_details" class="control-label">Deatils of Course(Group/Main/Branch):</label> <input class="form-control" onfocusout="this.value = this.value.toUpperCase();" placeholder="Course Details" name="course_details" id="course_details" required="" type="text">
<div class="help-block with-errors" required=""></div>
</div>
<div class="form-group">
<label for="institution" class="control-label">Name of Institution:</label> <input class="form-control" onfocusout="this.value = this.value.toUpperCase();" id="institution" placeholder="Institution" name="institution" required="" type="text">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="duration_year">Course Duration(Year)</label>
<select class="form-control" id="duration_year" name="duration_year">
<option value="" selected="selected">Select</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="duration_year">Course Duration(Month)</label>
<select class="form-control" id="duration_month" name="duration_month">
<option value="" selected="selected">Select</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="financial status">Financial Status</label>
<select class="form-control" id="finance" name="finance">
<option value="" selected="selected">Select</option>
<option value="apl">APL</option>
<option value="bpl">BPL</option>
<option value="finance_not_say">Prefer not to Specify</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="if_working">Are you Working Now?</label>
<select class="form-control" id="if_working" name="if_working" required="" onchange="change_work_option(this)">
<option value="" selected="selected">Select</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="working_type">If working, details of employment</label>
<select class="form-control" id="working_type" name="working_type" disabled>
<option value="select" selected="selected">Select</option>
<option value="government">Government</option>
<option value="private">Private</option>
<option value="self employed">Self Employed</option>
<option value="others">Others</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group"> <label for="interest" class="control-label">Interests</label> <input onfocusout="this.value = this.value.toUpperCase();" class="form-control" id="interests" placeholder="Interests" name="interest" type="text"> </div>
<div class="form-group"> <label for="aspiration" class="control-label">Career Aspirations</label> <input onfocusout="this.value = this.value.toUpperCase();" class="form-control" id="aspiration" placeholder="Aspiration" name="aspiration" type="text"> </div>
<div class="form-group"> <input class="btn btn-primary btn-lg btn-block" id ="submit" name="submit" value="submit" type="submit">
</div>
</form>
Edited..
After posting above question I have been making a number of trail and errors and found that error is not with my form or code. Even so simple a form like given below fails. But when I reload it works..I read something about a bug in Chrome. Any solution or hack?
here is the simple form i tried in vain last
<html><body>
<?php echo $_POST["name"]." echoing"; ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" name="student_form" method="post" accept-charset="utf-8">
<input type="text" name="name" />
<input type="submit">
</form>
</body>
Thank you for your support. This is not exactly an answer to the cause of the issue, but simply how I managed to get out of it and set my form working. :)
As U guys pointed out, it should nt be a bug in chrome android( it could be more disastrous in that case). And when I tried many "deductive" debugging and trial and error I found something which may lead to clutch to the root of the error.
1. It works fine when I tested on another web host
2. In my erroneous host cum browser, when the form is submitted the url returned carries a strange get parameter Www.xxxx.com/?i=1
Since I had to solve the problem immediately, I manned a function in the controller file to reload the uri if the browser is android chrome and it is tab is "fresh" using
isset($_SERVER['HTTP_CACHE_CONTROL']) &&
($_SERVER['HTTP_CACHE_CONTROL'] === 'max-age=0' || $_SERVER['HTTP_CACHE_CONTROL'] == 'no-cache')
and it worked. But would be glad to know any insights u could share
I need to update students information.
when i click edit button from students view page it display/retrieve user info correctly.but after that editing when i click update/save it show pharse error.
here is my database.
Database info`s
This is edit.php
<?php
session_start();
if(isset($_SESSION['admin'])){
echo "";
}
else
{
header("location:logout.php");
}
require('dbcon.php');
$hjd=$_GET['s_id'];
/* getting link id from index page*/
$que = "SELECT * FROM stu_info WHERE s_id='".$_GET['s_id']."'"; /*selecting id from database*/
$resu = mysqli_query($conl, $que) or die ( mysqli_error());
$rlk = mysqli_fetch_assoc($resu);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
Edit Profile
</title>
<link rel="stylesheet" href="css/bootstrap.css" />
<script src="js/jquery.min.js">
</script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js">
</script>
<script src="date_picker/datetimepicker_css.js">
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form class="form-horizontal" method="GET" action="edit_action.php">
<input type="hidden" name="new" value="1" />
<input type="text" name="chk" value="<?php echo $rlk['s_id']; ?>" hidden="" />
<fieldset>
<!-- Form Name -->
<legend>
Add Student
</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="f_name">
First Name
</label>
<div class="col-md-4">
<input id="f_name" name="f_name" type="text" value="<?php echo $rlk['f_name'];?> " class="form-control input-md" required="">
<span class="help-block">
Student Name
</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="l_name">
Last Name
</label>
<div class="col-md-4">
<input id="l_name" name="l_name" type="text" value="<?php echo $rlk['l_name'];?>" class="form-control input-md" required="">
<span class="help-block">
Maybe Father Name
</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="roll_no">
Roll No
</label>
<div class="col-md-4">
<input id="roll_no" name="roll_no" type="number" value="<?php echo $rlk['Roll_no'];?>" value="3215" class="form-control input-md" required="">
<span class="help-block">
Student Roll Number
</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="dob">
Date Of Birth
</label>
<div class="col-md-4">
<input id="demo1" name="dob" type="text" value="<?php echo $rlk['dob'];?>" class="form-control input-md" required="" onclick="javascript:NewCssCal ('demo1','yyyyMMdd','','','','','')" style="cursor:pointer"/>
<span class="help-block">
Date Of Birth
</span>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="cls">
Select Class
</label>
<div class="col-md-4">
<select id="cls" name="cls" class="form-control">
<option value="1">
class 1
</option>
<option value="2">
class 2
</option>
<option value="3">
class 3
</option>
<option value="4">
class 4
</option>
<option value="5">
class 5
</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="Gender">
Select Gender
</label>
<div class="col-md-4">
<select id="gender" name="gender" class="form-control">
<option value="male">
male
</option>
<option value="femala">
female
</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="reli">
Religion
</label>
<div class="col-md-4">
<select id="reli" name="reli" class="form-control">
<option value="Hindhu">
Hindhu
</option>
<option value="Christian">
Christian
</option>
<option value="Muslim">
Muslim
</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="reli">
Community
</label>
<div class="col-md-4">
<select id="commu" name="commu" class="form-control">
<option value="OC">
OC
</option>
<option value="BC" >
BC
</option>
<option value="MBC">
MBC
</option>
<option value="SC">
SC
</option>
<option value="ST">
ST
</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="reli">
Blood Group
</label>
<div class="col-md-4">
<select id="blg" name="blg" class="form-control">
<option value="A Possitive">
A Possitive
</option>
<option value="A Negative" >
A Negative
</option>
<option value="A1 Possitive">
A1 Possitive
</option>
<option value="A1 Negative">
A1-
</option>
<option value="A1B Possitive">
A1B Possitive
</option>
<option value="A1B Negative">
A1B Negative
</option>
<option value="A2 Possitive">
A2 Possitive
</option>
<option value="A2 Negative">
A2 Negative
</option>
<option value="A1B Possitive">
A1B Possitive
</option>
<option value="A2B\+">
A2B+
</option>
<option value="A2B Negative">
A2B Negative
</option>
<option value="AB Possitive">
AB Possitive
</option>
<option value="AB Negative">
AB Negative
</option>
<option value="B Possitive">
B Possitive
</option>
<option value="B Negative">
B Negative
</option>
<option value="O Possitive">
O Possitive
</option>
<option value="O Negative">
O Negative
</option>
</select>
</div>
</div>
<!-- Textarea -->
<div class="form-group">
<label class="col-md-4 control-label" for="address">
Address
</label>
<div class="col-md-4">
<textarea class="form-control" id="address" required="" value="<?php echo $rlk['address'];?>" name="address">
default Address
</textarea>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="loc">
Location
</label>
<div class="col-md-4">
<input id="loc" name="loc" type="text" required="" value="<?php echo $rlk['loc'];?>" class="form-control input-md" required="">
<span class="help-block">
currently living in
</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="mobile">
Mobile
</label>
<div class="col-md-4">
<input id="phone" name="phone" type="number" value="<?php echo $rlk['phone'];?>" class="form-control input-md" required="">
<span class="help-block">
Mobile Number
</span>
</div>
</div>
<button type="submit" class="btn btn-primary" name="btn-save" id="btn-save">
<span class="glyphicon glyphicon-plus">
</span> Save this Record
</button>
</fieldset>
</form>
</body>
</html>
Kindly correct error please
Thanks in Advance
This Is Edit Action.php file which is save/update database :
<?php
$status = "";
require('dbcon.php');
if(isset($_GET['new']) && $_GET['new']==1)
{
/*Detecting Input Start */
$s_id =$_GET['chk'];
$f_name = $_GET['f_name'];
$l_name = $_GET['l_name'];
$dob = $_GET['dob'];
$rln = $_GET['roll_no'];
$cls = $_GET['cls'];
$gender = $_GET['gender'];
$address= $_GET['address'];
$reli = $_GET['reli'];
$commu = $_GET['commu'];
$loc = $_GET['loc'];
$phone = $_GET['phone'];
$blg = $_GET['blg'];
/*Detection Input End */
$update=UPDATE `school`.`stu_info` SET `Roll_no` = "$rln", `f_name` = "$f_name", `l_name` = "$l_name", `dob` = "$dob", `std` = "$cls", `gender` = "$gender", `address` = "$address", `loc` = "$loc", `phone` = "$phone", `blg` = "$blg", `commu` = "$commu" WHERE `stu_info`.`s_id` = "$s_id";
$df=mysqli_query($conl,$update);
if(!df){
echo "error";
}
else {
echo "success";
}
}
?>
Kindly Help me By Findout Error
Thanks In Advance
///I Updated My Recent Code
Still Not work Show error
Your code is very unsafe. E. g. reading directly from $_GET array is not recommended. Please consider using PDO with execute to increase security
else {
$update= 'UPDATE `school`.`stu_info` SET `Roll_no` = "$rln", `f_name` = "$f_name", `l_name` = "$l_name", `dob` = "$dob", `std` = "$cls", `gender` = "$gender", `address` = "$address", `loc` = "$loc", `phone` = "$phone", `blg` = "$blg", `commu` = "$commu" WHERE `stu_info`.`s_id` = "$s_id"';
$df=mysqli_query($conl,$update);
} // missing !
Line 25 should be
$update = "UPDATE `school` . `stu_info` SET `Roll_no` = '$rln', `f_name` = '$f_name', `l_name` = '$l_name', `dob` = '$dob', `std` = '$cls', `gender` = '$gender', `address` = '$address', `loc` = '$loc', `phone` = '$phone', `blg` = '$blg', `commu` = '$commu' WHERE `stu_info` . `s_id` = '$s_id''";
and you are missing a } at the end.
But please do not create the queries like this.
This issue is explained here mysql extension deprecated
I'm getting the nominee_role value from add_employee file.
In nominee_role im getting 7000 as a result, but when I'm trying to get the data value in alert it returns some html contents.
<?php
include('database.php');
include("header.php");
include("left_side_bar.php");
?>
<div class="row">
<!-- left column -->
<div class="col-xs-12">
<div class="box box-primary">
<div class="box-header">
<h3 class="box-title">
Add employee
</h3>
<?php
extract($_POST);
//echo $name;
$current_date=date("Y-m-d");
if(isset($_POST['submit']))
{
//echo "hi";
$select = "SELECT * FROM `emp_details` WHERE `branch_name` = '".$branch_code."' AND `emp_role` = '".$emp_role."' ORDER BY id DESC LIMIT 1";
//echo $select;
$exe_select=mysql_query($select);
$fetch=mysql_fetch_array($exe_select);
$rows = mysql_num_rows($exe_select);
$emp_id ='0001';
if($rows == 0)
{
$emp_id ='0001';
$emp_code=$branch_code.$emp_role.$emp_id;
//echo "employee code: ".$emp_code;
}
else
{
$emp_id=$fetch['emp_code'];
echo $emp_id;
//exit();
$emp_id= $emp_id +1;
$emp_code=$emp_id;
//echo "employee code: ".$emp_code;
}
//exit();
$sql="INSERT INTO `emp_details`
(`emp_name`, `emp_code`, `emp_role`, `dob`, `age`, `address`, `contact_number`, `gender`, `pan`, `bank_acc`, `ifsc_code`, `branch_name`,`intro_code`, `nom_name`, `nom_address`, `nom_age`, `nom_gender`, `relationship_status`, `created_date`)
VALUES
('".$name."', '".$emp_code."', '".$emp_role."', '".$dob."', '".$age."', '".$address."', '".$contact_num."', '".$gender."', '".$pan."', '".$acc_num."', '".$ifsccode."', '".$branch_code."', '".$intro_code."', '".$nom_name."', '".$nom_add."', '".$nom_age."', '".$nom_gender."', '".$rel_status."', '".$current_date."' )";
//print_r($sql);
//exit();
$exe_query=mysql_query($sql);
if($exe_query)
{
echo '<h3 class="msyqlsuccess">Employee Details Added Successfully</h3>';
}
else
{
echo '<h3 class="msyqlerror">Employee Details Not Added</h3>'; }
}
?>
</div>
</div>
<!-- form start -->
<form role="form" method="post" class="agentdetails" id="add_agent_details" enctype="multipart/form-data">
<div class="box-body clearfix">
<div class="form-group">
<label>Name</label>
<input type="text" placeholder="Enter Employee Name" id="name" required="required" name="name" class="form-control" />
</div>
<div class="form-group">
<label>DOB</label>
<input type="text" placeholder="Enter DOB" id="date_of_birth" required="required" name="dob" class="form-control" />
</div>
<div class="form-group">
<label>Age</label>
<input type="text" placeholder="Enter Employee Age" id="age" required="required" name="age" class="form-control" />
</div>
<div class="form-group">
<label>Address</label>
<input type="text" placeholder="Enter Employee Address" id="address" required="required" name="address" class="form-control" />
</div>
<div class="form-group">
<label>Contact Number</label>
<input type="text" placeholder="Enter Contact Number" id="contact_num" required="address" name="contact_num" class="form-control" />
</div>
<div class="form-group">
<label>Gender</label>
<select name="gender" id="gender" class="select">
<option value="Female">Female</option>
<option value="Male">Male</option>
</select>
</div>
<div class="form-group">
<label>Employee Role</label>
<select name="emp_role" id="" class="select">
<option value="">---Select User Role---</option>
<option value="1000">Adviser</option>
<option value="2000">Agency Manager</option>
<option value="3000">Sales Manager</option>
<option value="4000">Business Development Manager</option>
<option value="5000">Executive Manager</option>
<option value="6000">Senior Executive Manager</option>
<option value="7000">Director</option>
</select>
</div>
<div class="form-group">
<label>Branch Name</label>
<select name="branch_code" id="" class="select">
<option value="">--Select Branch--</option>
<option value="130">Chennai</option>
<option value="150">Pondicherry</option>
</select>
</div>
<div class="form-group">
<label>PAN Number</label>
<input type="text" placeholder="Enter PAN" id="pan" required="required" name="pan" class="form-control" />
</div>
<div class="form-group">
<label>Bank Account</label>
<input type="text" placeholder="Enter Bankacc" id="acc_num" required="required" name="acc_num" class="form-control" />
</div>
<div class="form-group">
<label>IFSC Code</label>
<input type="text" placeholder="Enter IFSC Code" id="ifsccode" required="required" name="ifsccode" class="form-control" />
</div>
<div class="form-group">
<label>Introducer Code</label>
<input type="text" placeholder="Enter Introducer Code" id="intro_code" required="required" name="intro_code" class="form-control" />
</div>
<div class="form-group">
<label>Nominee Role</label>
<select name="nominee_role" class="select nominee">
<option value="">---Select Nominee Role---</option>
<option value="1000">Adviser</option>
<option value="2000">Agency Manager</option>
<option value="3000">Sales Manager</option>
<option value="4000">Business Development Manager</option>
<option value="5000">Executive Manager</option>
<option value="6000">Senior Executive Manager</option>
<option value="7000">Director</option>
</select>
</div>
<div class="form-group">
<label>Nominee Name</label>
<select name="nom_name" id="" class="select nominee_name">
<option value="">---Select Nominee Role---</option>
<?php
echo $nominee_role = $_POST['nominee_role'];
//echo "hi";
//load nominee name
$get_nominee="SELECT * FROM `emp_details` WHERE `nom_role` = '".$nominee_role."'";
echo $get_nominee;
$exe_nominee=mysql_query($get_nominee);
$is_nominee=mysql_fetch_array($exe_nominee);
$nominee_row=mysql_num_rows($exe_nominee);
if($is_nominee)
{
echo '<option value="'.$is_nominee['emp_code'].'">'.$is_nominee['nom_name'].'</option>';
}
else
{
echo '<option value="">No names are found</option>';
}
?>
</select>
</div>
<div class="form-group">
<label>Nominee Age</label>
<input type="text" placeholder="Enter Nominee Age" id="nom_age" required="required" name="nom_age" class="form-control" />
</div>
<div class="form-group">
<label>Nominee Address</label>
<input type="text" placeholder="Enter Nominee Address" id="nom_add" required="required" name="nom_add" class="form-control" />
</div>
<div class="form-group">
<label>Nominee Gender</label>
<select name="nom_gender" id="" class="select">
<option value="female">Female</option>
<option value="male">Male</option>
</select>
</div>
<div class="form-group">
<label>Relationship Status</label>
<input type="text" placeholder="Enter Relationship Status" id="rel_status" required="required" name="rel_status" class="form-control" />
</div>
<div class="box-footer">
<?php //if($num){ ?>
<!-- <button class="btn btn-primary" id="next" value="Update" type="submit" name="submit" style="margin-top: 6%;">Update</button>
--> <?php //} else { ?>
<button class="btn btn-primary submit" id="add_agent_details" value="Submit" type="submit" name="submit">Submit</button>
<?php //} ?>
</div>
</div>
</form>
</div>
</div>
<?php
include("footer.php");
die;
?>
<script>
$('.nominee').change(function () {
var nominee_role = $('.nominee').val();
alert(nominee_role); // '7000'
//send nominee role
$.ajax({
type: "POST",
url: "add_employee.php",
data: {nomi_role: nominee_role},
success: function (data) {
alert(data);
}
});
return false;
});
</script>
Kindly help me to solve this! I really don't know where I leave a mistake!
Add die; at the end of add_employee.php file;
while you didnt include your add_employee file then lets say you have this in that file.
$your_var = 7000 ;
$other_value = 8000 ;
echo json_encode(array("val"=>$your_var , "val2"=>$other_value ));
then in your ajax you should have this :
$.ajax({
type: "POST",
url: "add_employee.php",
data: {nomi_role: nominee_role},
success: function (data) {
alert(data.val); //will give you 7000.
alert(data.val2); //will give you 8000.
}
});
Hope that helps .