inserting different data with different id on single save button - php

I do have three fields which are text input which is of type number.these three data are being saved with different ids but on the same save button.i.e i am inserting data into all the field and then clicking on the save button but the my first data is being saved by different id and the same for the rest of two data.for example if i put 1 in first input,2 in second and 3 in the next since these are number type.but 1 is being saved by say by id:11,2 is being saved by say by id:12,3 is being saved by say by id:13.
my view is like below:
<form class="form">
<div class="control-group">
<label class="control-label">High Priority</label>
<div class="controls">
<input type="number"name="sval"id="sval"/>Days
</div>
</div>
<div class="control-group">
<label class="control-label ">Low Priority</label>
<div class="controls">
<input type="number"name="sval" id="sval"/>Days</div>
</div>
<div class="control-group">
<label class="control-label ">Normal</label>
<div class="controls">
<input type="number" name="sval" id="sval"/>Days </div>
</div>
<button id="btn" class="btn btn-primary insert">Save</button>
</form>
and the queries are:
var sqld:String;
sqld = "Delete from app_settings where kunnr = '"+kunnr+"' and ( skey = 'hp_days' or skey = 'np_days' or skey = 'lp_days' )";
wcisql.query(sqld,'clearRDays');
}
public function saveRDays():void{
var sqlu:String;
sqlu = "Insert into app_settings(kunnr,skey,sval) Values ('"+kunnr+"','hp_days','"+hp_days.value+"')";
wcisql.query(sqlu,'saveRDays');
sqlu = "Insert into app_settings(kunnr,skey,sval) Values ('"+kunnr+"','np_days','"+np_days.value+"')";
wcisql.query(sqlu,'saveRDays');
sqlu = "Insert into app_settings(kunnr,skey,sval) Values ('"+kunnr+"','lp_days','"+lp_days.value+"')";
wcisql.query(sqlu,'saveRDays');
$sql = "Select * from app_settings where kunnr = '$kunnr'";
}
i am adding image as well so that u can get better idea:
how to do this please suggest..
and for my view:

use Multiple Insert statement
ckeck out this referenced link:
Multiple INSERT statements vs. single INSERT with multiple VALUES
&
http://www.techonthenet.com/sql/insert.php

The problem is you can only use one ID for each HTML element.
So there are two ways to achieve this, one is dynamic the second is static.
Static Solutions:
<div class="control-group">
<label class="control-label">High Priority</label>
<div class="controls">
<input type="number"name="sval1"id="sval1"/>Days
</div>
</div>
<div class="control-group">
<label class="control-label ">Low Priority</label>
<div class="controls">
<input type="number"name="sval2" id="sval2"/>Days</div>
</div>
<div class="control-group">
<label class="control-label ">Normal</label>
<div class="controls">
<input type="number" name="sval3" id="sval3"/>Days </div>
</div>
<button id="btn" class="btn btn-primary insert">Save</button>
Dynamic Solution
<div class="control-group">
<label class="control-label">High Priority</label>
<div class="controls">
<input type="number" name="sval[]"/>Days
</div>
</div>
<div class="control-group">
<label class="control-label ">Low Priority</label>
<div class="controls">
<input type="number" name="sval[]"/>Days</div>
</div>
<div class="control-group">
<label class="control-label ">Normal</label>
<div class="controls">
<input type="number" name="sval[]"/>Days </div>
</div>
<button id="btn" class="btn btn-primary insert">Save</button>
Now when you post the form the items will come in array so you have an array
$_GET['sval'] or $_POST['sval'] contains array(1,2,3)

Related

Can I block one table from updating?

I have two tables in my database one practitioner and the second one practitioner_specialty, both of them have fields effective_date and expiry_date. When I use the form to update both if those tables the last effective_date and expiry_date are being saved to both of the tables instead of two separate ones.
Is there a way to block one table from updating so I can update only the second one, or maybe is there a way to save it using different id/name so they will be unique ones for practitioner and practitioner_specialty?
Here are my form and controller used for updating tables.
Controller:
public function updatePractitioner(Request $request, $id)
{
$this->validate($request, [
'effective_date' => 'required',
]
);
$fields = $request->all();
$primary_key = $this->PractitionerRepository->getIdName();
$primary_key_specialty = $this->PractitionerSpecialtyRepository->getIdName();
$practitioner_specialty_id = PractitionerSpecialty::where('practitioner_id', $id)->value('practitioner_specialty_id');
$fields[$primary_key] = $id;
$this->PractitionerRepository->update($fields);
$fields[$primary_key_specialty] = $practitioner_specialty_id;
$this->PractitionerSpecialtyRepository->update($fields);
return back()->with('successUpdate', 'Practitioner has been updated!');
}
update form in blade.php :
<div class="edit-practitioner" style="display: none;">
<form style="box-shadow: none;" action="/practitioner/update/{{$practitioner->practitioner_id}}" method="post"
class="j-pro" id="update-practitioner-form">
{{ csrf_field() }}
<div class="j-content">
<div id="j-row-id" class="j-row">
<div class="row">
<div class="col-sm-12 col-lg-12 col-xl-5">
<div class=" j-unit">
<div class="j-divider-text j-gap-top-20 j-gap-bottom-45">
<span>Practitioner Information</span>
</div>
<label class="j-label">{{trans('personalData.effectiveDate')}}</label>
<div class="j-input">
<input type="date" value="{{$practitioner->effective_date}}"
name="effective_date" id="effective_date">
</div>
<label class="j-label">{{trans('personalData.expiryDate')}}</label>
<div class="j-input">
<input type="date" value="{{$practitioner->expiry_date}}"
name="expiry_date" id="expiry_date">
</div>
<label class="j-label">{{trans('personalData.phoneNumber')}}</label>
<div class="j-input">
</label>
<input type="tel" value="{{$practitioner->phone}}"
name="phone" id="phone">
</div>
<label class="j-label">{{trans('personalData.mobileNumber')}}</label>
<div class="j-input">
<input type="tel" value="{{$practitioner->mobile}}"
name="mobile" id="mobile">
</div>
<label class="j-label">{{trans('personalData.email')}}</label>
<div class="j-input">
<input type="email" value="{{$practitioner->email}}"
name="email" id="email">
</div>
</div>
</div>
<div class="col-xl-1 j-unit"></div>
<div class="col-sm-12 col-lg-12 col-xl-6">
<div class="j-divider-text j-gap-top-20 j-gap-bottom-45">
<span>{{trans('settings.specialty')}}</span>
</div>
<select name="practitioner_specialty_id_update"
id="practitioner_specialty_id_update"
class="form-control-practitioner required">
#foreach($specialties as $specialty)
<option
value="{{$specialty->specialty_id}}">{{$specialty->name}}</option>
#endforeach
</select>
<label class="j-label">{{trans('personalData.effectiveDate')}}</label>
<div class="j-input">
#isset($practitioner_specialty->practitioner_specialty_id)
<input type="date" value="{{$practitioner_specialty->effective_date}}"
name="effective_date" id="effective_date">
#endisset
#empty($practitioner_specialty->practitioner_specialty_id)
<input type="date" name="effective_date" id="effective_date">
#endempty
</div>
<label class="j-label">{{trans('personalData.expiryDate')}}</label>
<div class="j-input">
#isset($practitioner_specialty->practitioner_specialty_id)
<input type="date" value="{{$practitioner_specialty->expiry_date}}"
name="expiry_date" id="expiry_date">
#endisset
#empty($practitioner_specialty->practitioner_specialty_id)
<input type="date" name="expiry_date" id="expiry_date">
#endempty
</div>
</div>
</div>
</div>
<div class="j-divider j-gap-bottom-45 j-gap-top-10"></div>
<button type="submit"
class="btn btn-editpanel btn-success btn-round">Save changes
</button>
<!-- end /.footer -->
<button id="update-cancel-button-practitioner" href="javascript:window.location.href=window.location.href" type="button"
class="btn btn-editpanel btn-danger btn-round">Cancel
</button>
</div>
</form>
</div>
Well you use the same array for both of the tables, hence the reason to update all the fields. You can try to exclude the ones for one form and add them to the other, for example:
$practictionerFields = $request->except('expiry_date', 'effective_date');
$practictionerFields[$primary_key] = $id;
$this->PractitionerRepository->update($practictionerFields);
// and use the other $fields array for the PractitionerSpecialty model.
You can use LOCK query here.
lock is a flag associated with a table. MySQL allows a client session to explicitly acquire a table lock for preventing other sessions from accessing the same table during a specific period. A client session can acquire or release table locks only for itself. It cannot acquire or release table locks for other sessions.
You can read more here: http://mysqltutorial.org/mysql-table-locking

Data from JSON response not displaying after assigning to instance variable

So, I have my SPA at about 98% functional. The app pulls data from a MySQL database and allows the user to edit/delete records. For the page in question, it will edit/delete data of the specified student ID but it will not properly display the data in the text fields.
If you do not input a value it will display the first item in the JSON array but not the one you specify in the search field.
I did not do a very good job at explaining that but here is the HTML page that uses a function to pass data to the controller which then selects the corresponding student by ID and assigns it to the variable $scope.student. I then try to display the student data on the HTML page by using student.first_name (or any property) but it does not work correctly.
<h3>Edit/Delete Student with ID: {{student.student_id}}</h3>
<div class="form-group">
<label for="sid">Student ID:</label>
<input type="text" class="form-control" id="sid" ng-model="sid">
</div>
<p><button type="button" class="btn btn-primary" ng-click="getRecord(sid)">
Get Student Info </button> </p>
<div class='row'>
<div class="col-md-6">
<div class="form-group">
<label for="first_name">First Name:</label>
<input type="text" class="form-control" id="first_name" ng-model="student.first_name">
</div>
<div class="form-group">
<label for="last_name">Last Name:</label>
<input type="text" class="form-control" id="last_name" ng-model="student.last_name">
</div>
<div class="form-group">
<label for="hrs_completed">Hrs Completed:</label>
<input type="text" class="form-control" id="hrs_completed" ng-model= "student.hrs_completed">
</div>
<div class="form-group">
<label for="hrs_attempted">Hrs Attempted:</label>
<input type="text" class="form-control" id="hrs_attempted" ng-model= "student.hrs_attempted">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="gpa_points">GPA Points:</label>
<input type="text" class="form-control" id="gpa_points" ng-model= "student.gpa_points">
</div>
<div class="form-group">
<label for="major">Major:</label>
<input type="text" class="form-control" id="major" ng-model="student.major">
</div>
<div class="form-group">
<label for="advisor_id">Advisor ID:</label>
<input type="text" class="form-control" id="advisor_id" ng-model="student.advisor_id">
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="text" class="form-control" id="email" ng-model="student.email">
</div>
</div>
<button type="button" class="btn btn-primary" ng-click="updateRecord()">Update</button>
<button type="button" class="btn btn-primary" ng-click="deleteRecord()">Delete</button>
And here is my controller on my Javascript page:
app.controller('editCtrl', function($scope, $http) {
$http.get("getStudentData.php")
.then(function (response) {
$scope.students = response.data;
});
$scope.getRecord = function(sid) {
id = sid;
$scope.student = $scope.students.find(s=>s.id == sid);
};
Do I need to make a seperate GET request to the server for this to work properly or do I just need to reference the student object differently?
I think there is mismatch in what you are getting as response.data and what you are trying to .find() and then what you are binding on html.
Check this plunkr.
You are trying to render by searching id property.
$scope.students.find(s=>s.id == sid);
where as you are rendering on UI using student_id property.
{{student.student_id}}
So, surely there is mismatch in what you are getting as response.data and what you are rendering using $scope.student properties. I think my plunkr will show that your function is correct.
In case this answer doesn't work, share your response.data.

how to populate data in bootstrap form from JSON object returned by PHP using jQuery

I am sending data successfully using ajax method of jQuery to a PHP file.
Now, my problem is that I want to populate a modal form for editing an existing database record based on event ID that I am sending to my PHP page.
the snippet I use to call the PHP page is:
$.ajax({
url: 'dbget.php',
data: 'eventid='+event.id,
type: 'POST',
dataType: 'json',
cache: false,
success: function(json_resp){
//populate_data('#update_event', json_resp);
$('#updateModal').modal('show');
},
error: function(e){
alert('Error processing your request: '+e.responseText);
}
});
As you can see that I can't seem to get the data to populate in the form in success section of the ajax method.
Here is the data returned from PHP file:
[{"u_id":"21","u_eventName":"Ready Ply","u_eventDate":"2017-05-11","u_customerName":"Fassoooggg","u_customerMobile":"9383838383","u_customerEmail":"ffgg#gmaks.com","u_totalAmount":"1000","u_advanceAmount":"500","u_balanceAmount":"500"}]
Here is the PHP file snippet processing DB request and sending json encoded data:
//Get the evenId from the POST request
$eventId = $_POST['eventid'];
$events = array();
$getQuery = mysqli_query($con, "SELECT eventmaster.id, eventmaster.eventName, eventmaster.startDate, eventmaster.customerName, "
."eventmaster.customerMobile, eventmaster.customerEmail, eventdetail.totalAmount, eventdetail.advanceAmount, "
."eventdetail.balanceAmount FROM eventMaster INNER JOIN eventdetail ON eventmaster.id = eventdetail.eventId "
."WHERE eventmaster.id= '$eventId'");
while($fetch = mysqli_fetch_array($getQuery, MYSQLI_ASSOC))
{
$e = array();
$e['u_id'] = $fetch['id'];
$e['u_eventName'] = $fetch['eventName'];
$eventDate = substr($fetch['startDate'],0,10); //extract the eventDate in yyyy-mm-dd format from the table date
$e['u_eventDate'] = $eventDate;
$e['u_customerName'] = $fetch['customerName'];
$e['u_customerMobile'] = $fetch['customerMobile'];
$e['u_customerEmail'] = $fetch['customerEmail'];
$e['u_totalAmount'] = $fetch['totalAmount'];
$e['u_advanceAmount'] = $fetch['advanceAmount'];
$e['u_balanceAmount'] = $fetch['balanceAmount'];
array_push($events, $e);
}
//printf("Data sent to client: " );
echo json_encode($events); //return data in JSON array
Please note that the keys in the json data match the name of the form fields. Here is the form snippet. This is the form I am trying to populate:
<!-- Update Event Modal Starts -->
<div id="updateModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header"><!-- Modal Header -->
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Update Event</h4>
</div>
<div class="modal-body"><!-- Modal Body -->
<p class="statusMsg"></p>
<form method="post" id="update_event">
<div class="form-group">
<input type="text" name="u_id" id="u_id" class="form-control" />
</div>
<div class="form-group">
<label for="u_eventName">Event Name</label>
<input type="text" name="u_eventName" id="u_eventName" class="form-control" placeholder="Event Name"/>
</div>
<label for="u_startDate">Event Date</label>
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" name="u_startDate" id="u_startDate" readonly />
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
<br />
<div class="form-group">
<label for="u_customerName">Customer Name</label>
<input type="text" name="u_customerName" id="u_customerName" class="form-control" placeholder="Customer Name"/>
</div>
<div class="form-group">
<label for="u_customerMobile">Customer Mobile</label>
<input type="text" name="u_customerMobile" id="u_customerMobile" class="form-control" />
</div>
<div class="form-group">
<label for="u_customerEmail">Customer Email</label>
<input type="text" name="u_customerEmail" id="u_customerEmail" class="form-control" placeholder="customer#email.com"/>
</div>
<div class="form-group">
<label for="u_totalAmount">Total Amount</label>
<input type="text" name="u_totalAmount" id="u_totalAmount" class="form-control" placeholder="0"/>
</div>
<div class="form-group">
<label for="u_advanceAmount">Advance Amount</label>
<input type="text" name="u_advanceAmount" id="u_advanceAmount" class="form-control" placeholder="0"/>
</div>
<div class="form-group">
<label for="u_balanceAmount">Balance Amount</label>
<input type="text" name="u_balanceAmount" id="u_balanceAmount" class="form-control" placeholder="0"/>
</div>
<div class="form-group">
<input type="submit" name="updateBtn" id="updateBtn" value="Update" class="btn btn-success" />
</div>
</form>
</div>
<div class="modal-footer"><!--Modal Footer -->
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Update Event Modal Ends -->
So, once again, after you look at the above code snippets, please help me to populate the form with the JSON object sent from the PHP file containing one row record from database to be populated in the form.
Am I missing something or what? Also, if I try to print the JSON object in the html page, I only get an OBJECT printed instead of the data.
The sample I posted here was what I echoed from PHP.
Anyone's help will be highly appreciated. Thanks.

Inserting data into MySQL server

I'm doing a e-commerce admin panel and I need a quick script for inserting data into MySQL. Here's what i've done and it does nothing.
<form action="#" id="form_sample_1" class="form-horizontal" method="post">
<div class="control-group">
<label class="control-label">Package Name<span class="required">*</span></label>
<div class="controls">
<input type="text" name="pkg_name" data-required="1" class="span6 " value=""/>
</div>
</div>
<div class="control-group">
<label class="control-label">Package Price <span class="required">*</span><small>(In Dollars)</small></label>
<div class="controls">
<input name="pkg_price" type="number" class="span6 " value=""/>
</div>
</div>
<div class="control-group">
<label class="control-label">Package Contains</label>
<div class="controls">
<input name="pkg_contains" type="text" class="span6 " value=""/>
</div>
</div>
<div class="control-group">
<label class="control-label">Your Password</label>
<div class="controls">
<input name="sifre" type="password" class="span6 " value=""/>
</div>
</div>
<div class="form-actions">
<button type="button"name="btn" class="btn btn-primary">Send request to server.</button>
</div>
</form>
<!-- END FORM-->
</div> <!--widget box light-grey end-->
<!-- Mass PHP starts here! -->
<?php
echo mysql_error();
include("include/baglan.php");
// set posts here.
$_POST['pkg_name'] = $pkg_name;
$_POST['pkg_price'] = $pkg_price;
$_POST['pkg_contains'] = $pkg_contains;
$sifre = mysql_real_escape_string(md5($_POST['sifre']));
if($_POST['btn'] and $_POST["sifre"] = $sifre){
mysql_query("INSERT INTO packages (pkg_name, pkg_price,pkg_contains) VALUES $pkg_name $pkg_price $pkg_contains");
echo "Success.";
}
else {
echo mysql_error();}
It returns nothing! I've re-written all code but nothing! please help me. The databae variables are;
id, auto incerment
pkg_name text
pkg_price int
pkg_contains mediumtext
Assign variable name should be the left side.
// set posts here.
$pkg_name=$_POST['pkg_name'];
$pkg_price=$_POST['pkg_price'];
$pkg_contains=$_POST['pkg_contains'];
Values() is function, put all vars in bracket and split them with ','.
mysql_query("INSERT INTO packages (pkg_name, pkg_price,pkg_contains) VALUES($pkg_name,$pkg_price,$pkg_contains)");

My php and form will not connect to my database to add values

I have created a form using Bootstrap modal, a database connection via PHP as well as a simple form validation. When I fill out form and hit submit, it seems to connect to database and no form errors come back. It states: "-1 rows are affected. Thank you for your RSVP" but when I look on PHPMyAdmin there are no values inputted into my database.
Below is my PHP:
<?php
//check if form is submitted and not a hack/bot. Checks to see if form is submitte by the post method then runs fxn.
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
//grab all values that come from form in these variables. Each line below grabs info typed/selected in each form input. The value in square brackets is the name value of each input. Keep the $variables different from input names.
$rsvpvar = $_POST['rsvpBox'];
$fullnamevar = $_POST['fullName'];
$emailvar = $_POST['emailBox'];
$attendvar = $_POST['attend'];
$guestsvar = $_POST['extraGuests'];
$commentsvar = $_POST['additionals'];
//If fxn checks to see if all above variables have values stored in them using !empty fxn and if not if runs the echo. Use !empty (not empty) and not isset because isset will allow db connection even if some form values are blank. If there is a value stored in all form inputs then we incude this php or run the connetion to database.
if(!empty($rsvpvar) && !empty($fullnamevar) && !empty($emailvar) && !empty($attendvar) && !empty($guestsvar) && !empty($commentsvar)){
//Define the below vaiables within parenthesis.
$hostname = "rsvp.db";
$username = "******";
$password = "******";
$dbname = "rsvp";
//Connection to mysql database. OR die drops connection to database for security reasons. Connect error gives message.
$dbc = mysqli_connect($hostname, $username, $password, $dbname) OR die("Could not connect to database, ERROR: ".mysqli_connect_error());
//Set encoding
mysqli_set_charset($dbc, "utf8");
//insert into table "rsvp" by getting or querying values stored in $dbc variable (db info). You insert into the corresponding rows of the db table (i.e. RSVP), then you grab what you're inserting using the VALUES. What you're inserting comes from the above variables.
mysqli_query($dbc, "INSERT INTO rsvp(RSVP, FULLNAME, EMAIL, ATTEND, GUESTS, COMMENTS) VALUES('$rsvpvar', '$fullnamevar', '$emailvar', '$attendvar', $guestsvar', '$commentsvar')");
//define variable $registered which checks database to make sure values were inserted and rows were affected then outputs how many rows affected. Make sure the $dbc or connection info is inside parenthesis.
$registered = mysqli_affected_rows($dbc);
echo $registered." rows are affected. Thank you for your RSVP";
}else{
echo "ERROR: You did not fill out each section";
}
}else{
echo "Please fill out everything on the RSVP form";
}
?>
and my html:
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h2 class="modal-title" id="myModalLabel">RSVP</h2>
</div>
<form role="form" method="post" action="php/rsvp.php">
<div class="modal-body">
<div class="form-inline row response">
<div class="col-sm-12">
<h2>Ya Comin'?</h2>
<div class="radio-inline">
<label class="control-label">
<input type="radio" name="rsvpBox" id="attending" value="option1">
I'll be there with bells on!
</label>
</div>
<div class="radio-inline">
<label class="control-label">
<input type="radio" name="rsvpBox" id="notAttending" value="option2">
Sorry, wish I was cooler...
</label>
</div>
</div>
</div>
<hr>
<div class="deets row">
<div class="col-sm-12">
<h2>Your Deets</h2>
<div class="form-group col-lg-6">
<label class="control-label" for="fullName">Full Name</label>
<input type="text" name="fullName" class="form-control" id="fullName" placeholder="FULL NAME">
</div>
<div class="form-group col-lg-6">
<label class="control-label" for="email">Email</label>
<input type="email" name="emailBox" class="form-control" id="emailBox" placeholder="EMAIL#EXAMPLE.COM">
</div>
</div>
</div>
<hr>
<div class="row days">
<div class="col-sm-12">
<h2>Days Attending</h2>
<div class="checkbox">
<label class="control-label">
<input type="checkbox" name="attend" value="option1">
Friday: Rehersal Dinner & Beach Party
</label>
</div>
<div class="checkbox">
<label class="control-label">
<input type="checkbox" name="attend" value="option2">
Saturday: Wedding & Reception
</label>
</div>
</div>
</div>
<hr>
<div class="guests row">
<div class="col-sm-12">
<h2>Number of Additional Guests</h2>
<select id="extraGuests" name="extraGuests" class="form-control">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>
</div>
<div class="extras row">
<div class="col-sm-12">
<h2>Anything Else?</h2>
<h4>Main Course Served Will be Chicken</h4>
<div class="form">
<div class="form-group">
<label class="control-label" for="message"></label>
<textarea name="additionals" id="additionals" class="form-control" rows="3" placeholder="Food specifications, allergies, guest names, etc..."></textarea>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" name="submit" id="submit" value="send" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>
Please help as I am not an expert on databases...
Your all POST variable is :
$rsvpvar = $_POST['attending'];
$emailvar = $_POST['emailBox'];
$fullnamevar = $_POST['fullName'];
$attend1var = $_POST['friday'];
$attend2var = $_POST['saturday'];
$guestsvar = $_POST['extraGuests'];
$commentsvar = $_POST['additionals'];
SO, should be condition :
if(!empty($rsvpvar) && !empty($emailvar) && !empty($fullnamevar) && !empty($attend1var) && !empty($attend2var) && !empty($guestsvar) && !empty($commentsvar)){
Please use same name in 2 radio input field :
<input type="radio" name="attending" id="attending" value="option1" checked>.
<input type="radio" name="attending" id="notAttending" value="option2">
Note : your code is open for SQL Injection.

Categories