how to save data in database using submit button? - php

I am new to html & php and I appreciate your help. I am trying to accept user input into a webpage and then after the user clicks the submit button, write a new record out to MySQL. I am using Wordpress so the tags are not exactly textbook.
So my first problem is that the submit button does not appear to execute the php code. I also would appreciate it if someone could check how I am passing my html field names to the php variables to make sure that I am on the right track. Thanks for your help!
<form
action="employee_list.php" method="post"
<input type="submit"
name="passport" id="passport" action="uraction" method="post" enctype="multipart/form-data"
<label for="upload" >Select Employee Passport</label><input type="file" id="upload" name="upload" accept="image/*">
<p/>
<div class="form-group">
<div class="form-row">
<div class="col-md-6">
<label for="name">Employee Full Name</label>
<input type="text" class="form-control" id="exampleInputName" aria-describedby="nameHelp" placeholder="Enter Full Name">
</div>
<div class="col-md-6">
<label for="gender">Gender</label>
<select type="text" class="form-control" id="exampleInputLastName" aria-describedby="nameHelp">
</select>
</div>
<div class="col-md-6">
<label for="maritalstatus">Marital Status</label>
<select type="text" class="form-control" id="exampleInputLastName" aria-describedby="nameHelp">
</select>
</div>
<div class="col-md-6">
<label for="department">Department</label>
<input type="text" class="form-control" id="Position" aria-describedby="nameHelp" placeholder="Enter The Department">
</div>
<div class="col-md-6">
<label for="salary">Salary</label>
<input type="number" class="form-control" id="salary" aria-describedby="nameHelp" placeholder="">
</div>
<div class="col-md-6">
<label for="certificate"> Highest Certificate Acquired</label>
<input type="text" class="form-control" id="salary" aria-describedby="nameHelp" placeholder="Enter Highest Certificate Acquired">
</div>
</div>
</div>
<div class="form-group">
<label for="Email">Email Address</label>
<input type="emai" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<div class="form-group">
<label for="address">House Address</label>
<input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter House Address">
</div>
<div class="form-group">
<div class="form-row">
<div class="col-md-6">
<label for="phonenumber">Phone Number</label>
<input type="number" class="form-control" id="phonenumber">
</div>
</form>
</div>
<!-- /.content-wrapper -->
PHP script:
<?php
if(isset($_POST['submit'])) {
$SQL = "INSERT INTO tbl_employee (name, gender,
marital_status,department,salary,certificate, email,address,phone_number)
VALUES ('$_POST[name]', '$_POST[gender]',
'$_POST[marital_status],'$_POST[department]','$_POST[salary]‌​
','$_POST[certificat‌​
e]','$_POST[email]',‌​'$_POST[address]','$‌​_POST[phone_numer]')‌​"; $result =
mysql_query($SQL);
}
?>

<html>
<head>
<title>Check</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<?php include('dbconnect.php');
if($_POST['submit']){
$fullname = $_POST['exampleInputName'];
$gender = $_POST['gender'];
$status = $_POST['status'];
$position = $_POST['position'];
$salary = $_POST['salary'];
$certificate = $_POST['certificate'];
$exampleInputEmail1 = $_POST['exampleInputEmail1'];
$phonenumber = $_POST['phonenumber'];
}
$data = "INSERT INTO test (`id`, `fullname`, `gender`, `matrial_status`, `department`, `salary`, `certificate`, `email`, `address`)VALUES ('', '$fullname', '$gender', '$status', '$position', '$salary', '$certificate', '$exampleInputEmail1', '$phonenumber')";
mysqli_query($con,$data);
?>
<form action="checkbox.php" method="POST" >
<div class="form-group">
<div class="form-row">
<div class="col-md-6">
<label for="name">Employee Full Name</label>
<input type="text" class="form-control" id="exampleInputName" name="exampleInputName" aria-describedby="nameHelp" placeholder="Enter Full Name">
</div>
<div class="col-md-6">
<label for="gender">Gender</label>
<select type="text" name="gender" class="form-control" id="gender" aria-describedby="nameHelp">
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</div>
<div class="col-md-6">
<label for="maritalstatus">Marital Status</label>
<select type="text" name="status" class="form-control" id="status" aria-describedby="nameHelp">
<option value="Married">Married</option>
<option value="Unmarried">Unmarried</option>
</select>
</div>
<div class="col-md-6">
<label for="department">Department</label>
<input type="text" class="form-control" name="position" id="position" aria-describedby="nameHelp" placeholder="Enter The Department">
</div>
<div class="col-md-6">
<label for="salary">Salary</label>
<input type="number" class="form-control" name="salary" id="salary" aria-describedby="nameHelp" placeholder="">
</div>
<div class="col-md-6">
<label for="certificate"> Highest Certificate Acquired</label>
<input type="text" class="form-control" id="certificate" name="certificate" aria-describedby="nameHelp" placeholder="Enter Highest Certificate Acquired">
</div>
</div>
</div>
<div class="form-group">
<label for="Email">Email Address</label>
<input type="emai" class="form-control" id="exampleInputEmail1" name="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<div class="form-group">
<label for="address">House Address</label>
<input type="text" class="form-control" id="exampleInputEmail1" name="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter House Address">
</div>
<div class="form-group">
<div class="form-row">
<div class="col-md-6">
<label for="phonenumber">Phone Number</label>
<input type="text" class="form-control" name="phonenumber" id="phonenumber">
</div>
</div>
</div>
<input type="submit" name="submit" id="passport">
</form>
</body>

Related

I want to update the recorded in data base. I want to send the "employee_id" on clicking save button. so that corresponding 'id' recorded is updated

I want to update the record of the corresponding id that is sent on clicking save button. I tried button tage, input tage and link tage but there is some mistake that I am making, but I don't know where?
This is my form
<form method="POST" action="handle_update.php">
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">First name</label>
<input type="text" name="fname" value="'.$first_name.'" class="form-control" >
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Last name</label>
<input type="text" name="last_name" value="'.$last_name.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Email</label>
<input type="email" name="email" value="'.$email.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Designation</label>
<input type="text" name="designation" value="'.$designation.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Address</label>
<input type="address" name="address" value="'.$address.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Date of Joining</label>
<input type="date" name="joining_date" value="'.$joining_date.'" class="form-control">
</div>
<a name="update" role = "button" type="submit" href="handle_update.php?ployee_id='.$id2.'">Save</a>
</form>
Add a hidden input field that holds the value you want to submit. Change your <a> to a <button> that can submit your form. Change your code to:
<form method="POST" action="handle_update.php">
<input type="hidden" name="ployee_id" value="' . $id2 . '">
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">First name</label>
<input type="text" name="fname" value="'.$first_name.'" class="form-control" >
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Last name</label>
<input type="text" name="last_name" value="'.$last_name.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Email</label>
<input type="email" name="email" value="'.$email.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Designation</label>
<input type="text" name="designation" value="'.$designation.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Address</label>
<input type="address" name="address" value="'.$address.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Date of Joining</label>
<input type="date" name="joining_date" value="'.$joining_date.'" class="form-control">
</div>
<button type="submit" name="update">Save</button>
</form>
More on forms: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form
More on hidden inputs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/hidden

can't connect a laravel api.php rout from an html form

I am trying to post a form from a HTML file to a live database using laravel api.php route. But it's yielding the following error :
my api.php looks like :
<?PHP
use Illuminate\Http\Request;
use App\Http\Controllers\User\PageController;
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::post('summitRegistration',[PageController::class,'summitRegistration']);
My HTML code :
<form action="https://www.aspireelearning.com/summitRegistration" method="POST">
<div class="col-12 col-md-6">
<div class="form-group">
<input type="text" class="form-control" name="full_name" id="full_name"
placeholder="Your Full Name">
<input type="text" class="form-control" name="phone" id="phone"
placeholder="Phone Number">
<input type="text" class="form-control" name="profession" id="profession"
placeholder="Profession">
</div>
</div>
<div class="col-12 col-md-6">
<div class="form-group">
<input type="email" class="form-control" name="email" id="email"
placeholder="Email Address" required>
<input type="text" class="form-control" name="organization" id="organization"
placeholder="Organization/Institute">
<select class="form-control country-search" name="country" id="country">
<option value="">Your Country</option>
<option value="">USA</option>
<option value="">UK</option>
</select>
</div>
</div>
<div class="col-12 text-center">
<button type="submit" class="btn btn-danger">
CONFIRM
</button>
</div>
</form>
i have update action and also added #csrf token now i hope you will get your out put .
<form action="https://www.aspireelearning.com/api/summitRegistration" method="POST">
//#csrf
<div class="col-12 col-md-6">
<div class="form-group">
<input type="text" class="form-control" name="full_name" id="full_name"
placeholder="Your Full Name">
<input type="text" class="form-control" name="phone" id="phone"
placeholder="Phone Number">
<input type="text" class="form-control" name="profession" id="profession"
placeholder="Profession">
</div>
</div>
<div class="col-12 col-md-6">
<div class="form-group">
<input type="email" class="form-control" name="email" id="email"
placeholder="Email Address" required>
<input type="text" class="form-control" name="organization" id="organization"
placeholder="Organization/Institute">
<select class="form-control country-search" name="country" id="country">
<option value="">Your Country</option>
<option value="">USA</option>
<option value="">UK</option>
</select>
</div>
</div>
<div class="col-12 text-center">
<button type="submit" class="btn btn-danger">
CONFIRM
</button>
</div>
</form>
You have to add api as prefix https://www.aspireelearning.com/api/summitRegistration

Boostrap Form wont submit data to database

I have a bootstrap form within a modal but i cant get the data to submit to my database
my modal form (html)
<div class="modal-body">
<form method="post" action="insertRecord.php">
<div class="form-group">
<label for="firstName">First Name</label>
<input type="text" name="txtFirstName" class="form-control" id="inputFirstName" placeholder="First Name">
</div>
<div class="form-group">
<label for="lastName">Last Name</label>
<input type="text" name="txtLastName" class="form-control" id="inputLastName" placeholder="First Name">
</div>
<div class="form-group">
<label for="emailAddress">Email address</label>
<input type="email" name="txtEmail" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="txtPassword" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-group">
<label for="Dob">Date of birth:</label>
<input type="date" name="DoB" class="form-control" id="inputDOB" placeholder="First Name">
</div>
<div class="form-group">
<label for="Address1">Address1</label>
<input type="text" name="txtAddress1" class="form-control" id="inputAddress1" placeholder="First Name">
</div>
<div class="form-group">
<label for="Address2">Address2</label>
<input type="text" name="txtAddress2" class="form-control" id="inputAddress2" placeholder="First Name">
</div>
<div class="form-group">
<label for="postcode">Postcode</label>
<input type="text" name="txtPostcode" class="form-control" id="inputPostcode" placeholder="First Name">
</div>
<input type="submit" value="Submit" name="taxSubmit" />
</form>
</div>
my code to insert the form info (php)
<?php
include 'connection.php';
$firstName=$_POST['txtFirstName'];
$lastName=$_POST['txtLastName'];
$email=$_POST['txtEmail'];
$password=$_POST['txtPassword'];
$dob=$_POST['DoB'];
$address1=$_POST['txtAddress1'];
$address2=$_POST['txtAddress2'];
$postcode=$_POST['txtPostcode'];
$query="INSERT INTO Userinfo (FirstName, LastName,
Email,Password,Dob,Address1,Address2,Postcode) VALUES ('$firstName',
'$lastName',
'$email','$password','$dob','$address1','$address2','$postcode')";
mysqli_query($connection, $query);
?>
I have another script that connects to the database, I would appreciate any help I can get as I have been stuck on this for many hours and cannot get my head around the problem.
Many thanks
Try this example, I ran and works fine for me:
<?php
require 'connection.php';
$firstName = $lastName = $email = $email = $password = $dob = $address1 = $address2 = $postcode = $query = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$firstName = $_POST['txtFirstName'];
$lastName = $_POST['txtLastName'];
$email = $_POST['txtEmail'];
$password = $_POST['txtPassword'];
$dob = $_POST['DoB'];
$address1 = $_POST['txtAddress1'];
$address2 = $_POST['txtAddress2'];
$postcode = $_POST['txtPostcode'];
$query = "INSERT INTO Userinfo (FirstName, LastName,
Email, Password, Dob, Address1, Address2, Postcode) VALUES ('$firstName',
'$lastName', '$email','$password','$dob','$address1','$address2','$postcode')";
}
echo $query;
if (mysqli_query($connection, $query)) {
echo "New record created successfully";
} else {
echo "Error: " . $query. "<br>" . mysqli_error($connection);
}
mysqli_close($connection);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Insert Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Modal</h2>
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<form method="post" action="">
<div class="form-group">
<label for="firstName">First Name</label>
<input type="text" name="txtFirstName" class="form-control" id="inputFirstName" placeholder="First Name">
</div>
<div class="form-group">
<label for="lastName">Last Name</label>
<input type="text" name="txtLastName" class="form-control" id="inputLastName" placeholder="First Name">
</div>
<div class="form-group">
<label for="emailAddress">Email address</label>
<input type="email" name="txtEmail" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="txtPassword" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-group">
<label for="Dob">Date of birth:</label>
<input type="date" name="DoB" class="form-control" id="inputDOB" placeholder="First Name">
</div>
<div class="form-group">
<label for="Address1">Address1</label>
<input type="text" name="txtAddress1" class="form-control" id="inputAddress1" placeholder="First Name">
</div>
<div class="form-group">
<label for="Address2">Address2</label>
<input type="text" name="txtAddress2" class="form-control" id="inputAddress2" placeholder="First Name">
</div>
<div class="form-group">
<label for="postcode">Postcode</label>
<input type="text" name="txtPostcode" class="form-control" id="inputPostcode" placeholder="First Name">
</div>
<input type="submit" value="Submit" name="taxSubmit" />
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

Submit button will not send form data to MySQL database [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have a problem that might be a syntax problem but I can't seem to figure out what I am doing wrong.
I have created a form and when I click on submit, the data in the form is not sent to my mysql database.
Here is my html code
<div class="content-wrapper">
<div class="container">
<div class="row">
<div class="col-md-10">
<h1 class="page-head-line">Forms </h1>
</div>
</div>
<div class="row">
<div class="col-md-10">
<div class="panel panel-default">
<div class="panel-heading">
BASIC FORM ELEMENTS
</div>
<div class="panel-body">
<form method="post" action="insert.php" >
<div class="form-group">
<label for="name">Name</label>
<input name="name' type="text" class="form-control" id="name" placeholder="Enter your name" required/>
</div>
<div class="form-group">
<label for="project_num">OIT-GIS Project Number</label>
<input name="project_num' type="text" class="form-control" id="project_num" placeholder="OIT-GIS Project Number" />
</div>
<div class="form-group">
<label for="project_name">Project Name</label>
<input name="name' type="text" class="form-control" id="project_name" placeholder="Project Name" required/>
</div>
<div class="form-group">
<label for="easyvista">EasyVista Ticket Number</label>
<input name="easyvista' type="text" class="form-control" id="easyvista" placeholder="EasyVista Ticket Number" />
</div>
<div class="form-group">
<label for="agency">Requestor/Agency</label>
<input name="agency' type="text" class="form-control" id="agency" placeholder="Requestor or Agency" />
</div>
<div class="form-group">
<label for="description">Description of Work:</label>
<input name="description' type="text" class="form-control" id="agency" placeholder="Description" />
</div>
<div class="form-group">
<label for="input-date">Enter Today Date</label>
<input name="input-date' type="date" value="">
<span class="result"></span>
</div>
<div class="form-group">
<div class="col-md-10">
<input id="submit" name="submit" type="submit" class="btn btn-primary">
</div>
</div>
</form>
</div>
</div>
and here is my php
<?php
echo $POST;
error_reporting(E_ALL);
ini_set('display_errors', 1);
include("../includes/config.php");
if (isset($_POST['submit'])) {
echo $_POST['submit'];
$name = $_POST['name'];
$projectnum = $_POST['project_num'];
$projectname = $_POST['project_name'];
$easyvista = $_POST['easyvista'];
$agency = $_POST['agency'];
$description = $_POST['description'];
$startDate = $_POST['input-date'];
$sql="INSERT INTO statusreport(name, project_num, project_name, easyvista, agency, description)
VALUES
('$name','$projectnum', '$projectname', '$easyvista', '$agency', '$description')";
if (!mysqli_query($conn, $sql))
{
die('Error: ' . mysqli_connect_error($conn));
}
echo "Entry is recored <br/>";
echo "Name:", $name, "<br/>";
echo "test..................<br/>", $name;
/*header("location: http://10.1.7.129//gisadmin/admin/forms.php");*/
//echo "<script>setTimeout(\"location.href = 'http://10.1.7.129//gisadmin/admin/forms.php';\",700);</script>";
mysqli_query($conn, $sql);
}
else {
echo "No data";
}
?>
Any help would be greatly appreciated.
Thanks
You have a mixing of single and double quotes here, the name attributes are opening the value with double quotes and closing with single quotes, should be as follows:
<form method="post" action="insert.php" >
<div class="form-group">
<label for="name">Name</label>
<input name="name" type="text" class="form-control" id="name" placeholder="Enter your name" required/>
</div>
<div class="form-group">
<label for="project_num">OIT-GIS Project Number</label>
<input name="project_num" type="text" class="form-control" id="project_num" placeholder="OIT-GIS Project Number" />
</div>
<div class="form-group">
<label for="project_name">Project Name</label>
<input name="project_name" type="text" class="form-control" id="project_name" placeholder="Project Name" required/>
</div>
<div class="form-group">
<label for="easyvista">EasyVista Ticket Number</label>
<input name="easyvista" type="text" class="form-control" id="easyvista" placeholder="EasyVista Ticket Number" />
</div>
<div class="form-group">
<label for="agency">Requestor/Agency</label>
<input name="agency" type="text" class="form-control" id="agency" placeholder="Requestor or Agency" />
</div>
<div class="form-group">
<label for="description">Description of Work:</label>
<input name="description" type="text" class="form-control" id="agency" placeholder="Description" />
</div>
<div class="form-group">
<label for="input-date">Enter Today Date</label>
<input name="input-date" type="date" value="">
<span class="result"></span>
</div>
<div class="form-group">
<div class="col-md-10">
<input id="submit" name="submit" type="submit" class="btn btn-primary">
</div>
</div>
</form>
And then, as #Fred -ii stated in his comment, the php script is wrong:
echo $POST;
That line is wrong, there is no variable with name $POST before that code.
Are you getting success message but database is not getting updated OR Getting Total Error...???
1) Check for double quotes and single quotes..
<div class="form-group">
<label for="name">Name</label>
<input name="name" type="text" class="form-control" id="name" placeholder="Enter your name" required/>
</div>
2) Also check for path... for
include("../includes/config.php");
Is it correct or not...?
3)
<label for="project_name">Project Name</label>
<input name="name' type="text"
SHOULD BE
<label for="project_name">Project Name</label>
<input name="project_name" type="text"

HTML - form acting weird. Not redirecting to URL and using GET instead of POST

I'm a CS student and I have a DB project due in less than 24hrs! This is really annoying because I just need to forms to access my DB. Anyway, I have this form that works perfectly, while the second form does not work. Instead of posting and directing to the correct URL the second form re-loads the current page with the variables in the URL. Anybody have any ideas?
<form role="form" method="post" action="../controller/AddPerson.php">
<div class="box-body">
<div class="form-group">
<label for="newReservationFirstName"> First name</label>
<input type="text" class="form-control" name="newReservationFirstName" placeholder="Enter first name">
<label for="newReservationLastName"> Last name</label>
<input type="text" class="form-control" name="newReservationLastName" placeholder="Enter last name">
<label for="newReservationPhoneNumber"> Phone Number</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-phone"></i>
</div>
<input type="text" class="form-control" name="newReservationPhoneNum" data-inputmask='"mask": "(999) 999-9999"' data-mask/>
</div><!-- /.input group -->
<label for="newReservationStreetAddress"> Street Address</label>
<input type="text" class="form-control" name="newReservationStreetAddress" placeholder="Enter street address">
<label for="newReservationCity"> City</label>
<input type="text" class="form-control" name="newReservationCity" placeholder="Enter city">
<label for="newReservationState"> State</label>
<select class="form-control" name="newReservationState">
<?php
$result = getTableOrderBy('States','stateName');
while($row = mysql_fetch_array($result)) {
echo "<option value=".$row[stateAbbr].">".$row[stateName]."</option>";
} ?>
</select>
<label for="newReservationZip"> Zip Code</label>
<input type="text" class="form-control" name="newReservationZip" placeholder="Enter zipcode">
</div>
<button type="submit" class="btn btn-success btn-lg">Add New Customer</button>
</div>
</form>
This is the form that doesn't work correctly, both pages exist on the server:
<form role="form" method="post" action="../controller/AddEmployee.php">
<div class="box-body">
<div class="form-group">
<label for="newEmployeeFirstName"> First name</label>
<input type="text" class="form-control" name="newEmployeeFirstName" placeholder="Enter first name">
<label for="newEmployeeLastName"> Last name</label>
<input type="text" class="form-control" name="newEmployeeLastName" placeholder="Enter last name">
<label for="newEmployeePhoneNumber"> Phone Number</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-phone"></i>
</div>
<input type="text" class="form-control" name="newEmployeePhoneNum" data-inputmask='"mask": "(999) 999-9999"' data-mask/>
</div><!-- /.input group -->
<label for="newEmployeeStreetAddress"> Street Address</label>
<input type="text" class="form-control" name="newEmployeeStreetAddress" placeholder="Enter street address">
<label for="newEmployeeCity"> City</label>
<input type="text" class="form-control" name="newEmployeeCity" placeholder="Enter city">
<label for="newEmployeeState"> State</label>
<select class="form-control" name="newEmployeeState">
<?php
$result = getTableOrderBy('States','stateName');
while($row = mysql_fetch_array($result)) {
echo "<option value=".$row[stateAbbr].">".$row[stateName]."</option>";
} ?>
</select>
<label for="newEmployeeZip"> Zip Code</label>
<input type="text" class="form-control" name="newEmployeeZip" placeholder="Enter zipcode">
<p></p>
<p></p>
<label for="newEmployeeFirstName"> Account Username</label>
<input type="text" class="form-control" name="newEmployeeUsername" placeholder="Enter username">
<label for="newEmployeeLastName"> Account Password</label>
<input type="text" class="form-control" name="newEmployeePassword" placeholder="Enter password">
<label for="newEmployeePhoneNumber"> Social Security Number</label>
<input type="text" class="form-control" name="newEmployeeSocial" placeholder="Enter SSN">
<div class="form-group" name="newEmployeePrivileges">
<br>
Privileges :
<select name="newEmployeePrivileges">
<option value="admin">Admin</option>
<option value="admin">Non-Admin</option>
</select>
</div>
<button type="submit" class="btn btn-success btn-lg">Add New Employee</button>
</div>
</div>
</form>
----------------------------------EDIT ----------------------------------------------
I tried making a another really simple form on some extra space and it still didn't work. I have no idea what could be cause it to do this.
<form method="post" action="post" action="../controller/AddEmployee.php">
<button type="submit" class="btn btn-success btn-lg">Add New Employee</button>
</form>
It could be that the button tag you are using to submit the form is causing it behave strangely. Try swapping out the button tag for an input. So:
<form method="post" enctype="multipart/form-data" action="../controller/AddEmployee.php">
<input type="submit" class="btn btn-success btn-lg" name="submit" >Add New Employee</input>
</form>
Also, I noticed you've included two 'action' attributes in your example form :-)

Categories