I am creating a website and I was making a appointment form with PHP. It is turning up no errors on the page itself but the email never shows up in the inbox or spam folder of my email. The code I have for it is:
`
<form action="contact.php" method="POST">
<div class="row g-3">
<div class="col-12 col-sm-6">
<select name="Doctor" class="form-select bg-light border-0 mb-3" style="height: 55px;">
<option selected>Select A Doctor</option>
<option value="PROF DR AZFAR FAROGH">PROF DR AZFAR FAROGH (MEDICINE)</option>
<option value="PROF DR AJWAD FAROGH">PROF DR AJWAD FAROGH (CARDIAC SURGERY)</option>
<option value="PROF DR IRFAN KHAN">PROF DR IRFAN KHAN (HEMATOLOGY)</option>
<option value="DR ASMA HASSAN">DR ASMA HASSAN (PULMONOLOGY)</option>
<option value="DR USAMA MUNIR">DR USAMA MUNIR (CARDIOLOGY)</option>
<option value="DR AWAIS NIZAMI">DR AWAIS NIZAMI (CARDIOLOGY)</option>
<option value="DR SUMYYA ASHRAF">DR SUMYYA ASHRAF (FAMILY PHYSICIAN)</option>
<option value="DR SABAHAT GUL">DR SABAHAT GUL (CARDIOLOGY)</option>
<option value="DR MUHAMMAD BURHAN BARKAT">DR MUHAMMAD BURHAN BARKAT (UROLOGY)</option>
<option value="DR MADIHA AZHAR">DR MADIHA AZHAR (DERMATOLOGY)</option>
<option value="DR FAHAD QAISAR">DR FAHAD QAISAR (MEDICINE)</option>
<option value="DR MAHTAB AHMED MUKTAR PATAFI">DR MAHTAB AHMED MUKTAR PATAFI (PHYSIOTHERAPY)</option>
<option value="DR NASIR MAHMOOD">DR NASIR MAHMOOD (PHYSIOTHERAPY)</option>
<option value="DR SHEHR BANO">DR SHEHR BANO (PHYSIOTHERAPY)</option>
<option value="DR MUHAMMAD WASSAM">DR MUHAMMAD WASSAM (PHYSIOTHERAPY)</option>
<option value="DR SARAH NISAR">DR SARAH NISAR (RADIOLOGY)</option>
<option value="DR SARAH NISAR">DR AHMAD BILAL (RADIOLOGY)</option>
<option value="DR ZAFAR JAM">DR ZAFAR JAM (CARDIOLOGY)</option>
<option value="DR ANWAAR UL HASSAN">DR ANWAAR UL HASSAN (CARDIOLOGY)</option>
<option value="DR JUNAID AKHTER">DR JUNAID AKHTER (CARDIOLOGY)</option>
<option value="DR M ZUBAIR AHMAD">DR M ZUBAIR AHMAD (PEDIATRIC SURGERY)</option>
<option value="DR GOHAR BASHIR">DR GOHAR BASHIR (CARDIAC SURGERY)</option>
</select>
</div>
<div class="col-12 col-sm-6">
<input type="text" name="Name" class="form-control bg-light border-0" placeholder="Your Name" style="height: 55px;" required>
</div>
<div class="col-12 col-sm-6">
<input type="email" name="Email" class="form-control bg-light border-0" placeholder="Your Email" style="height: 55px;" required>
</div>
<div class="col-12 col-sm-6">
<input type="number" name="Number" class="form-control bg-light border-0" placeholder="Your Phone Number" style="height: 55px;" required>
</div>
<div class="col-12 col-sm-6">
<input type="number" name="CNIC" class="form-control bg-light border-0" placeholder="Your CNIC Number" style="height: 55px;" required>
</div>
<div class="col-12 col-sm-6">
<SELECT name="Gender" class="form-control bg-light border-0" placeholder="Select Your Gender" style="height: 55px;" required>
<option name="MALE">MALE</option>
<option name="FEMALE">FEMALE</option>
<option name="NEUTER">NEUTER</option>
</SELECT>
</div>
<div class="col-12 col-sm-6">
<input type="number" name="AGE" class="form-control bg-light border-0" placeholder="AGE" style="height: 55px;" required>
</div>
<div class="col-12 col-sm-6">
<div class="date" id="date1" data-target-input="nearest">
<input type="text" name="Date" class="form-control bg-light border-0 datetimepicker-input" placeholder="Appointment Date" data-target="#date1" data-toggle="datetimepicker" style="height: 55px;" required>
</div>
</div>
<div class="col-12 col-sm-6">
<input type="text" name="Comments" class="form-control bg-light border-0" placeholder="Additional Comments" style="height: 55px;">
</div>
<div class="col-12">
<button class="btn btn-dark w-100 py-3" type="submit">Make Appointment</button>
</div>
</div>
</form>
this is my php file:
<?php
header("Location: ../appointment.html");
if(isset($_POST['Name']) &&
isset ($_POST['Email']) &&
isset ($_POST['Doctor']) &&
isset ($_POST['CNIC']) &&
isset ($_POST['Number']) &&
isset ($_POST['Gender']) &&
isset ($_POST['Age']) &&
isset ($_POST['Date']) &&
isset ($_POST['Comments'])) {
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$Doctor = $_POST['Doctor'];
$CNIC = $_POST['CNIC'];
$Number = $_POST['Number'];
$Gender = $_POST['Gender'];
$Age = $_POST['Age'];
$Date = $_POST['Date'];
$Comments = $_POST['Comments'];
$to = '********#gmail.com';
$subject = 'Appointment' . $name;
$body = $message;
$headers = 'From:' . $email . "\r\n" . "CC: ********#gmail.com";
if (mail($to, $subject, $body, $headers)) {
echo 'your message has been sent!';
} else {
echo 'There was an error sending your message.';
}
}
?>
I tired sending just name and message ,it worked but then i tired on this form ,it doesn't worked.
Related
I want to filter the data between dates. I have so many columns from the front end.
Screenshot of front end columns
I have the following code that works fine unless the date filter comes.
How can I add the date filter in this code and that will work.
I have provided the blade file code and the controller's function code below.
** BLADE FILE**
<form action="/filter/companies/data" method="get" >
<h5 class="text-center">Basic Filters</h5>
<input type="text" name="company_name" id="" placeholder="Company Name" class="form-control">
<input type="text" name="cin" id="" placeholder="CIN" class="form-control my-2">
<div class="form-group">
<label for="">Company Status</label>
<select class="select2 select2-hidden-accessible" multiple="" data-placeholder="Company Status" style="width: 100%;" tabindex="-1" name="company_status[]" aria-hidden="true">
<option value="Active">Active</option>
<option value="Inactive ">Inactive </option>
</select>
</div>
<div class="form-group">
<label for="">Company Category</label>
<select class="select2 select2-hidden-accessible" multiple="" data-placeholder="Company Category" style="width: 100%;" tabindex="-1" name="company_category[]" aria-hidden="true">
#foreach($company_category2 as $key => $item)
<option value="{{$item}}">{{$item}}</option>
#endforeach
</select>
</div>
<div class="form-group">
<label for="">Activity Code</label>
<select class="select2 select2-hidden-accessible" multiple="" data-placeholder="Activity Code" style="width: 100%;" tabindex="-1" name="activity_code[]" aria-hidden="true">
#foreach($activity_code2 as $key => $item)
<option value="{{$item}}">{{$item}}</option>
#endforeach
</select>
</div>
<input type="text" name="roc" id="" placeholder="ROC" class="form-control my-2">
<hr/>
<h5 class="text-center">Company Details</h5>
<div class="form-group">
<label for="">Company Class</label>
<select class="select2 select2-hidden-accessible" multiple="" data-placeholder="Company Class" style="width: 100%;" tabindex="-1" name="company_class[]" aria-hidden="true">
<option value="Public Company">Public Company</option>
<option value="Private Company">Private Company</option>
</select>
</div>
<div class="form-group">
<label for="">Company Type</label>
<select class="select2 select2-hidden-accessible" multiple="" data-placeholder="Company Type" style="width: 100%;" name="company_type[]" aria-hidden="true">
#foreach($company_type2 as $key => $item)
<option value="{{$item}}">{{$item}}</option>
#endforeach
</select>
</div>
<input type="text" name="office_type" id="" placeholder="Office Type" class="form-control my-2">
<input type="text" name="llpin" id="" placeholder="LLP IN" class="form-control my-2">
<input type="text" name="llp_name" id="" placeholder="LLP NAME" class="form-control my-2">
<input type="text" name="industrial_activity" id="" placeholder="Industrial Activity" class="form-control my-2">
<hr/>
<h5 class="text-center">Filter using Contact Details</h5>
<input type="text" name="email" id="" placeholder="Email" class="form-control mb-2">
<input type="text" name="mobile_number" id="" placeholder="Mobile Number" class="form-control my-2">
<hr/>
<h5 class="text-center">Filter using Authorized Capital</h5>
<input type="text" name="from_authorized_capital" id="" placeholder="From Authorized Capital" class="form-control mb-2">
<input type="text" name="to_authorized_capital" id="" placeholder="To Authorized Capital" class="form-control my-2">
<hr/>
<h5 class="text-center">Filter using Locations</h5>
<div class="form-group">
<label for="">Select State</label>
<select class="select2 select2-hidden-accessible" multiple="" data-placeholder="Select a State" style="width: 100%;" tabindex="-1" name="state[]" aria-hidden="true">
#foreach($states as $key => $item)
<option value="{{$item}}">{{$item}}</option>
#endforeach
</select>
</div>
<div class="form-group">
<label for="">Select District</label>
<select class="select2 select2-hidden-accessible" multiple="" data-placeholder="Select a District" style="width: 100%;" tabindex="-1" name="district[]" aria-hidden="true">
#foreach($districts as $key => $item)
<option value="{{$item}}">{{$item}}</option>
#endforeach
</select>
</div>
<input type="text" name="city" id="" placeholder="City" class="form-control my-2">
<hr/>
<h5 class="text-center">Dates Of Registration</h5>
<label for="">Start Date</label>
<input type="date" name="date_of_registration[start]" id="" class="form-control my-2 mb-2">
<label for="">End Date</label>
<input type="date" name="date_of_registration[end]" id="" class="form-control my-2 mb-2">
<hr/>
<button type="submit" class="btn btn-success my-2">Filter</button>
<button type="reset" class="btn btn-secondary my-2">Reset</button>
</form>
CONTROLLER FUNCTION
$data = tbl_company::query()->where(function ($query) use ($req) {
foreach ($req->only('state', 'district', 'city', 'company_status', 'activity_code', 'company_category', 'company_class', 'company_type', 'office_type', 'date_of_registration') as $filterField => $filterFieldValue) {
if ($req['date_of_registration']['start'] && $req['date_of_registration']['end']) {
$from = Carbon::parse($req['date_of_registration']['start']);
$to = Carbon::parse($req['date_of_registration']['end']);
$query->whereBetween(
DB::Raw("STR_TO_DATE(date_of_registration,'%d-%m-%Y')"),
[$from, $to]
);
} elseif (!empty($filterFieldValue) && is_array($filterFieldValue)) {
$query->wherein($filterField, $filterFieldValue);
} elseif (!empty($filterFieldValue)) {
$query->where($filterField, "LIKE", "%{$filterFieldValue}%");
}
}
})->paginate(100);
I found the answer. I solved this problem using Pipeline Design Pattern
$query = tbl_company::query();
if ($req->has('state')) {
$query->whereIn('state', $req->input('state'));
}
if ($req->has('district')) {
$query->whereIn('district', $req->input('district'));
}
if ($req['date_of_registration']['start'] && $req['date_of_registration']['end']) {
$from = Carbon::parse($req['date_of_registration']['start']);
$to = Carbon::parse($req['date_of_registration']['end']);
$query->whereBetween(
DB::Raw("STR_TO_DATE(date_of_registration,'%d-%m-%Y')"),
[$from, $to]
);
}
if ($req['authorized_capital']['start'] && $req['authorized_capital']['end']) {
$query->whereBetween(
"authorized_capital",
[$req['authorized_capital']['start'], $req['authorized_capital']['end']]
);
}
// filtered data.
$data = $query->paginate(100);
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 a contact form on my website, however I have very little PHP experience. I was able to get the email sending but there are errors. I cannot select an email from the dropdown to send to, The file attachment isn't functioning, the fields are showing up like this in my email- Name: . except for the "firstname field" that shows up First Name : "Correct Name"... any help or direction would be much appreciated.
HTML:
<form name="secure" class="form-secure" action="contact.php"
method="POST" enctype="multipart/form-data" role="form">
<h4 class="secure-header pb-2 text-dark">Secure Email Form</h4>
<p class="text-secondary let-p font-italic">Please fill out
the form below to send your representative or department a
secure email</p>
<form class="form secure-email-form">
<div class="form-row">
<div class="form-group col-md-4 top-row">
<p><select name="recipient" id="recipient">
<option value="" class="form-control">Select Recipient *
</option>
<option
value="implementations#masspay.net">Implementation</option> .
<option
value="operations#masspay.net">Operations</option><option
value="tax#masspay.net">Tax</option><option
value="training#masspay.net">Training</option><option
value="sales#masspay.net">Sales</option><option
value="josh#masspay.net">Josh Soroko</option><option
value="jason#masspay.net">Jason Maxwell</option><option
value="jcarini#masspay.net">Jacklyn Carini</option><option
value="katie#masspay.net">Katie Rogers</option><option
value="jpowers#masspay.net">Jourdan Powers</option><option
value="brogers#masspay.net">Brittany Rogers</option><option
value="cflint#masspay.net">Charmaine Flint</option><option
value="knegron#masspay.net">Karina Negron</option><option
value="afox#masspay.net">Andrew Fox</option><option
value="paula#masspay.net">Paula Papalambros</option><option
value="mmcloy#masspay.net">Missy McLoy</option></select>
</p>
</div>
<div class="form-group col-md-6">
<p><input name="subject" id="subject" class="form-
control" type="text" placeholder="Subject *"></p>
</div>
</div>
<div class="form-group second-row">
<p><label><span class="attachment">Attachment </span>
<input name="fileMain" class="form-control" id="fileMain"
type="file"></label></p>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<p><input name="firstname" id="firstname"
class="form-control" type="text" placeholder="First Name *"></p>
</div>
<div class="form-group col-md-6">
<p><input name="lastname" id="lastname"
class="form-control" type="text" placeholder="Last Name *"></p>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<p><input name="email" type="text" class="form-
control" id="email" placeholder="Email *"></p>
</div>
<div class="form-group col-md-6">
<p><input name="emailC" type="text" class="form-
control" id="emailC" placeholder="Confirm Email *"></p>
</div>
</div>
<div class="form-group">
<p class="form-field organization">
<input type="text" value="" class="text email-
org form-control" size="56" maxlength="255" onchange="" .
placeholder="Organization">
</p>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<p><input name="phone" class="form-control" type="tel" value="" placeholder="Phone"></p>
</div>
<div class="form-group col-md-6">
<p>
<select name="stateSelect" id="state" class="form-control">
<option value="">Select Your State *</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
</p>
</div>
</div>
<div class="form-group">
<textarea class="form-control form-field mb-3" type="textarea" name="message" id="how-can-we-help-you" placeholder="How Can We Help You?" cols="55" rows="3"></textarea>
</div>
<div class="form-group">
<div class="prefered-contact">
<p>Prefered method of contact: <br>
<label class="mr-2">
<input name="contactmethod" id="contactmethod" class="form-control" type="radio" value="Phone"> Phone
</label>
<label>
<input name="contactmethod" class="form-control" id="contactmethod" type="radio" value="Email" checked="checked"> Email
</label>
</p>
</div>
</div>
<div class="form-group">
<p class="form-field %%form-field-css-classes%% pd-captcha required hidden %%form-field-dependency-css%%">
</p>
<div class="g-recaptcha" data-sitekey="6Lcw2H0UAAAAAPtObq6EBHb0JfBDaQcXcA1Esr-8"></div>
<p></p>
<div id="error_for_Recaptchapi_Recaptcha" style="display:none"></div>
</div>
<div class="form-group">
<input name="_utf8" type="hidden" value="☃">
<p class="submit submit-email">
<input type="submit" accesskey="s" value="Submit" class="submit-form">
</p>
</div>
<input type="hidden" name="hiddenDependentFields" id="hiddenDependentFields" value="">
</form>
</form>
php:
<?php
$name = $_POST['name'];
$subject = $_POST['subject'];
$fileMain = $_POST['fileMain'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$emailC = $_POST['emailC'];
$organization = $_POST['organization'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$email_from = 'MP Secure Email';
$email_subject = 'New Message From MP Secure Email';
$email_body = "Name: $name.\n".
"Subject: $name.\n".
"File: $fileMain.\n".
"First Name: $firstname.\n".
"Last Name: $lasttname.\n".
"Email: $email.\n".
"Email Confirm: $emailC.\n".
"Organization: $organization.\n".
"Phone: $phone.\n".
"Message: $message.\n";
$to ="mdonatelli#masspay.net";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $email \r\n";
mail($to,$email_subject,$email_body,$headers);
header("location: index.html");
if(isset($_POST['submit-form'])){
$selected_val = $_POST['recipient']; // Storing Selected Value In Variable
echo "You have selected :" .$selected_val; // Displaying Selected Value
}
if(isset($_POST['submit-form']) )
{
$varGender = $_POST['stateSelect'];
$errorMessage = "";
}
if (isset($_POST['submit-form'])) {
if(isset($_POST['radio']))
{
echo "You have selected :".$_POST['radio']; // Displaying Selected Value
}
}
?>
i have a php form, that adds a 'review' to a 'guide' in an SQL database.
i finally figured out my problem, and it is when i use copy paste in the input areas.
what can cause this??
any help appreciated!!
this is the link
this is my code:
<body >
<form class="form-horizontal" method="POST" >
<div class="form-group" >
<div class="col-sm-1">
<a href="." > <img src="Pictures/Design/בחזרה לאתר.png" height="100" width="100"/> </a>
</div>
<div class="col-sm-10">
<h2>הוספת ביקורת ל: <?php if(isset($_SESSION ['name'])){echo $_SESSION ['name'];} else {echo $gname;}?></label>
</h2>
</div>
</div>
<hr>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-4 " align="right">
<?php $val="uploads/guides/".$row['Picture'];?>
<image src='<?php echo $val;?>' height="130px" width="100px">
</div>
<div class="col-sm-7 " align="right">
<div><label class=" control-label" ><?php if(isset($_SESSION ['name'])){echo $_SESSION ['name'];} else {echo $gname;}?></label><label class=" control-label" >   :שם המדריך</label></div>
<div><label class=" control-label" ><?php if(isset($_SESSION ['attraction'])){echo $_SESSION ['attraction'];} else {echo $gattraction;}?></label><label class=" control-label" >   :אטרקציה</label></div>
<div><label class=" control-label" ><?php if(isset($_SESSION ['email'])){echo $_SESSION ['email'];} else {echo $gemail;}?></label><label class=" control-label" >   :אימייל</label></div>
<div><label class=" control-label" ><?php if(isset($_SESSION ['phone'])){echo $_SESSION ['phone'];} else {echo $gphone;}?></label><label class=" control-label" >   :טלפון</label></div>
</div>
</div>
</div>
<hr>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >שמך המלא</label>
</div>
<div class="col-sm-12">
<input type="text" class="form-control" name="name" placeholder="" />
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >מתי השתמשת בשירותי המדריך</label>
</div>
<div class="col-sm-6 " align="right">
<select class="form-control" name="year">
<option value="בחר/י שנה">בחר/י שנה</option>
<option value="2016">2016</option>
<option value="2015">2015</option>
<option value="2014">2014</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
</select>
</div>
<div class="col-sm-6 " align="right">
<select class="form-control" name="month">
<option value="בחר/י חודש">בחר/י חודש</option>
<option value="ינואר">ינואר</option>
<option value="פברואר">פברואר</option>
<option value="מרץ">מרץ</option>
<option value="אפריל">אפריל</option>
<option value="מאי">מאי</option>
<option value="יוני">יוני</option>
<option value="יולי">יולי</option>
<option value="אוגוסט">אוגוסט</option>
<option value="ספטמבר">ספטמבר</option>
<option value="אוקטובר">אוקטובר</option>
<option value="נובמבר">נובמבר</option>
<option value="דצמבר">דצמבר</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >ציון 1-5</label>
</div>
<div class="col-sm-3 col-sm-offset-9 " align="right">
<select class="form-control " name="rating">
<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>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >כמה שילמת ומה זה כלל</label>
</div>
<div class="col-sm-12">
<textarea class="form-control" name="pay" cols="40" rows="2"></textarea>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >פרטו את חוויתכם עם המדריך בהרחבה</label>
</div>
<div class="col-sm-12">
<textarea class="form-control" name="exp" cols="40" rows="5" required></textarea>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 " >
</div>
</div>
<div class="form-group" >
<div class="col-sm-12 col-sm-offset-5"><button type="submit" class="btn btn-primary btn-sm" name="addreview" value="Submit Record">הוספת ביקורת</button></div>
</div>
<?php
if(isset($_POST['addreview'])){
$name = $_POST['name'];
$name = str_replace("'","''",$name);
$monthh = $_POST['month'];
$yearr = $_POST['year'];
$pay = $_POST['pay'];
$pay = str_replace("'","''",$pay);
$exp= $_POST['exp'];
$exp = str_replace("'","''",$exp);
$rating=$_POST['rating'];
$query1="INSERT INTO review (ReviewerName,ServiceMonth,ServiceYear,Rating,Payment,Experience,Guide_ID) VALUES ";
$query1.="('$name','$monthh','$yearr','$rating','$pay','$exp','$guideid')";
$result=mysqli_query($conn,$query1);
if($result){
?>
<script type="text/javascript">
window.location = "./review_added_successfully.php";
</script>
<?php
}
else{
echo "not submitted";
}
} ?>
</form>
</body>
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.