I have been working on this project for hours and need fresh eyes as to why the information from the forum is not being submitted into the database.
I have checked that the connection to the database was working. Whenever I try to submit an entry to the database, it shows that nothing goes wrong and goes to https://example.com/beta/index.php?post=success as it is supposed to but nothing except the auto_incremented id number shows up into the database.
My form page:
if(!session_id()){
session_start();
}
require('loginregister-master/includes/config.php');
if ($_SESSION['username'] !== admin ) {
header("Location: https://www.example.com/beta");
}
//if not logged in redirect to login page
if(!$user->is_logged_in()){ header('Location: loginregister-master/login.php'); }
include('sec/HTTPS.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>Post Blog</title>
<!-- Bootstrap Core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
<script src="vendor/jquery/jquery.min.js"></script>
</head>
<body>
<form action="likesdislike/post.php" method="POST">
<div class="form-group">
<label>Title</label>
<input type="title" class="form-control" name="title' placeholder="Title">
</div>
<div class="form-group">
<label>Content</label>
<input type="content" class="form-control" name="content' placeholder="Content">
</div>
<div class="form-group">
<label>Date</label>
<input type="text" class="form-control" name="etad' placeholder="Date">
</div>
<div class="form-group">
<label>Author</label>
<input type="text" class="form-control" name="author' placeholder="author">
</div>
<div class="form-group">
<label>URL</label>
<input type="text" class="form-control" name="URL' placeholder="URL">
</div>
<button type="submit" name="submit">Submit</button>
</form>
</body>
</html>
The bit that 'should' handle the submission the database:
<?php
include('connect.php');
$title = mysqli_real_escape_string($link, $_POST['title']);
$content = mysqli_real_escape_string($link, $_POST['content']);
$etad = mysqli_real_escape_string($link, $_POST['etad']);
$author = mysqli_real_escape_string($link, $_POST['author']);
$URL = mysqli_real_escape_string($link, $_POST['URL']);
$sql = "INSERT INTO posts (title, content, etad, author, URL) VALUES ('" . $title . "', '" . $content . "', '" . $etad . "', '" . $author . "', '" . $URL . "')";
mysqli_query($link, $sql);
header("Location: https://www.example.com/beta/index.php?post=success");
?>
And of course, the bit that handles the connection to the database:
<?php
$link = mysqli_connect("localhost", "username", "password", "database_name");
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
?>
You have misplaced " in name of html tags. Just do it with "".
<form action="likesdislike/post.php" method="POST">
<div class="form-group">
<label>Title</label>
<input type="title" class="form-control" name="title" placeholder="Title">
</div>
<div class="form-group">
<label>Content</label>
<input type="content" class="form-control" name="content" placeholder="Content">
</div>
<div class="form-group">
<label>Date</label>
<input type="text" class="form-control" name="etad" placeholder="Date">
</div>
<div class="form-group">
<label>Author</label>
<input type="text" class="form-control" name="author" placeholder="author">
</div>
<div class="form-group">
<label>URL</label>
<input type="text" class="form-control" name="URL" placeholder="URL">
</div>
<button type="submit" name="submit">Submit</button>
</form>
Related
I'm trying to create an edit page where data is read from MySQL with PHP and then displayed in HTML.
Normal fields like VARCHAR displays correctly, but I have difficulty in displaying TEXT fields.
<?php
$DATABASE_HOST = '';
$DATABASE_USER = '';
$DATABASE_PASS = '';
$DATABASE_NAME = '';
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if ( mysqli_connect_errno() ) {
exit('Failed to connect to MySQL: ' . mysqli_connect_error());
}
$idjob = $_POST['jobID'];
$jobquery = $mysqli->prepare('SELECT * FROM jobs WHERE id = ?');
$jobquery->bind_param('s', $idjob); // 's' specifies the variable type => 'string'
$jobquery->execute();
$jobresult = $jobquery->get_result();
while ($row = $jobresult->fetch_assoc()) {
$jobtitle = $row['jobtitle'];
$workhours = $row['workhours'];
$type = $row['type'];
$availfrom = $row['availfrom'];
$deadline = $row['deadline'];
$customer = $row['customer'];
$province = $row['province'];
$town = $row['town'];
$minreq = $row['minreq'];
$posdetails = $row['posdetails'];
$minsal = $row['minsal'];
$maxsal = $row['maxsal'];
}
mysqli_free_result($jobresult);
mysqli_close($mysqli);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Edit Job Listing</title>
<link rel="shortcut icon" type="image/jpg" href="images/Logo.jpg">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0 shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="../assets/css/style.css" type="text/css"/>
</head>
<body id="editjoblisting">
<!-- Container (About Add New Job Listing Section) -->
<div id="abouteditnewjob" class="container-fluid bg-grey">
<div class="row">
<div class="col-sm-2"></div>
<div class="col-sm-8">
<div class="text-center">
<h2> Edit Job Listing </h2>
</div>
</div>
<div class="col-sm-2"></div>
</div>
</div>
<div class="container-fluid bg-grey">
<form method="post" id="updedit_form" action="../php/updeditjob.php">
<div class="form-row">
<div class="col-sm-2"></div>
<div class="col-sm-4">
<div class="form-group">
<label for="jobtitle"> Job Title</label>
<input type="text" class="form-control" name="jobtitle" value='<?php echo $jobtitle; ?>'>
<label for="workhours"> Working Hours</label>
<input type="text" class="form-control" name="workhours" value='<?php echo $workhours; ?>'>
<label for="worktype">Type</label>
<select class="form-control" name="worktype" >
<option value='<?php echo $type; ?>' selected><?php echo $type; ?></option>
<option>--None--</option>
<option>Temporary</option>
<option>Permanent</option>
</select>
<label for="availfrom"> Available From</label>
<input type="date" class="form-control" id="availfrom" name="availfrom" required maxlength="50" value='<?php echo $availfrom; ?>'>
<label for="deadline"> Application Deadline</label>
<input type="date" class="form-control" id="deadline" name="deadline" required maxlength="50" value='<?php echo $deadline; ?>'>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="minreq">Minimum Requirements</label>
<textarea class="form-control" type="textarea" name="minreq" id="minreq" maxlength="6000" rows="5" value='<?php echo $minreq; ?>'></textarea>
<label for="posdetails">Position Details</label>
<textarea class="form-control" type="textarea" name="posdetails" id="posdetails" maxlength="6000" rows="5" value='<?php echo $posdetails; ?>'></textarea>
<label for="minsal"> Minimum Salary</label>
<input type="text" class="form-control" id="minsal" name="minsal" value='<?php echo $minsal; ?>'>
<label for="maxsal"> Maximum Salary</label>
<input type="text" class="form-control" id="maxsal" name="maxsal" value='<?php echo $maxsal; ?>'>
</div>
</div>
<div class="col-sm-2"></div>
</div>
</form>
</div>
</body>
</html>
This is the data I'm trying to show/edit.
id "251"
jobid "ID#20101664"
jobtitle "SENIOR CONVEYANCING SECRETARY"
workhours "Monday - Friday 7:00 - 17:00"
type "Permanent"
availfrom "2021-06-07"
deadline "2021-10-29"
minreq
"- Matric Certificate
- Minimum 3 years experience
- Knowledge in Law programs (Lexis Nexis, Windeed) – Compulsory
- Knowledge of Bonds: Absa, Standard Bank, FNB and Nedbank
- Bilingual (English & Afrikaans)
- Computer literate
- Be accurate and methodical etc.." \N
minsal "0"
maxsal "0"
Everything works nicely except minreq which is a TEXT field in MySQL. It is not displayed, yet echo shows that it was retrieved in the $row array.
Try to echo the value between the textarea tags, not in the value attribute:
<textarea class="form-control" type="textarea" name="minreq" id="minreq" maxlength="6000" rows="5"><?php echo $minreq; ?></textarea>
Please remove the value from inside the text area and write your code like this:
//here is the valid code...this will 100% work.
<textarea class="form-control" type="textarea" name="posdetails" id="posdetails" maxlength="6000" rows="5">
<?php echo $posdetails; ?>
</textarea>
I keep submitting form input or attempting to do so I get a 404 with this PHP at the end of the url its in the top of the php snippit I am unsure if that is a clue to the issue. I have the action linked to insert.php I am unsure what is going on. Everything to me looks correct. But obviously its not. I've made sure the header('location: index.html') is correct. As another post suggested. Here is my code
HTML
<!Doctype html>
<html>
<head>
<title>Sign Up</title>
<link rel="stylesheet" href="css/live/app-d159020cbe.min.css">
<link rel="stylesheet" href="css/live/core-89ce772293.min.css">
</head>
<body>
<div class="containsignuptext">
<p>We believe the developer community is stronger togeather, We believe it takes the right community for us to reach the next stage in the future we believe in adding real tools to developers tool belts.</p>
</div>
<form action="insert.php" method="POST" accept-charset="UTF-8" role="form" id="loginForm">
<div class="form-group">
<div class="form-group">
<label for="login_email" class="sr-only">Full Name</label>
<input class="form-control input-lg" id="fullname" placeholder="Full Name" required="required" name="fullname" type="text">
</div>
<div class="form-group">
<label for="login_email" class="sr-only">Username</label>
<input class="form-control input-lg" id="username" placeholder="Username" required="required" name="username" type="text">
</div>
</div>
<div>
<label for="login_email" class="sr-only">Email</label>
<input class="form-control input-lg" id="email" placeholder="Email" required="required" name="email" type="text">
</div>
<div class="form-group">
<label for="login_password" class="sr-only">Password</label>
<input class="form-control input-lg" id="password" placeholder="Password" required="required" name="password" type="password">
<div>
<label for="login_email" class="sr-only">Codelangs</label>
<input class="form-control input-lg" id="codelang" placeholder="Code Language You Like the Most" required="required" name="codelangs" type="text">
</div>
<button method="POST" type="submit" class="btn btn-lg btn-primary btn-block ladda-button" data-style="zoom-in" type="submit" name="insert">
<span class="ladda-label">Get Hacking</span>
</button>
</form>
</body>
</html>
PHP
<?php echo $_SERVER['PHP_SELF']; ?>
I get that in the url idk if it helps the rest is the inser.php code.
<?php
$servername = "localhost";
$username = "Placeholder";
$pass = "FakeForShow";
$dbname = "sign up new";
$fullname=$_POST['fullname'];
$username=$_POST['username'];
$email=$_POST['email'];
$password=$_POST['password'];
$codelangs=$_POST['codelangs'];
// Create connection
$conn = new mysqli($servername, $username, $pass, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO newusers (fullname, username, password, email, codelang)
VALUES ( '$fullname', '$username', '$email', '$password', '$codelangs');";
if ($conn->query($sql) === TRUE) {
header("location: index.html");
}
else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
?>
Your database connection should be similar to this.
$s = 'localhost';
$u = 'root';
$p = 'yourUsername';
$d = 'yourPassword';
$mysqli = new mysqli($s, $u, $p, $d);
Check to see if the butt is clicked first.
if(isset($_POST['insert'])){
Do some Error Checks like this you need to add to this this is very basic.
$fullname=$_POST['fullname'];
$username=$_POST['username'];
$email=$_POST['email'];
$password=$_POST['password'];
$codelangs=$_POST['codelangs'];
$alert = '';
$errorFullname = '';
if($_POST['fullname'] == '' || $_POST['username'] || $_POST['email'] || $_POST['password']){
if($_POST['fullname'] == ''){$errorFullname "Cannot be empty.";}//and so on...
$alert = "All fields are required.";} else {
If no Errors insert. Encrypt your passwords before inserting them.
$hashedWord = password_hash($password, PASSWORD_BCRYPT, array("cost" => 17));
$insertdata = $mysqli->prepare("INSERT INTO newusers (fullname, username, password, email, codelang) VALUES('"$fullname"', '"$username"', '"$hashedWord"', '"$email"', '"$codelangs"') ");
$insertdata->execute();
$insertdata->close();
header("location: index.html");
}
}
include 'YourHtmlPage';
You can call the error messages like this.
<div class="form-group">
<label for="login_email" class="sr-only">Full Name</label>
<input class="form-control input-lg" id="fullname" placeholder="Full Name" required="required" name="fullname" type="text">
</div>
<div><?php echo $errorFullname; ?></div>
You can use something like this to check the hashed password. Run a select and match it with what they typed.
password_verify($passwordTheyTyped, $YourHashedPassFromTheDatabase);
Hope it helps a little.
This might help you.
The HTML Code : index.php
<!Doctype html>
<html>
<head>
<title>Sign Up</title>
<link rel="stylesheet" href="css/live/app-d159020cbe.min.css">
<link rel="stylesheet" href="css/live/core-89ce772293.min.css">
</head>
<body>
<div class="containsignuptext">
<p>We believe the developer community is stronger togeather, We believe it takes the right community for us to reach the next stage in the future we believe in adding real tools to developers tool belts.</p>
</div>
<form action="insert.php" method="POST" accept-charset="UTF-8" role="form" id="loginForm">
<div class="form-group">
<label for="login_email" class="sr-only">Username</label>
<input class="form-control input-lg" id="username" placeholder="Username" required="required" name="username" type="text">
</div>
<!-- Other form elements-->
<button method="POST" type="submit" class="btn btn-lg btn-primary btn-block ladda-button" data-style="zoom-in" type="submit" name="insert">
<span class="ladda-label">Get Hacking</span>
</button>
</form>
</body>
</html>
The PHP Code : insert.php
<?php
$servername = "localhost";
$db_username = "DB_USER_NAME";
$db_pass = "DB_USER_PASSWORD";
$dbname = "DB_NAME";
$username = $_POST['username'];
// Other POST elements
$conn = new mysqli($servername, $db_username, $db_pass, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO newusers (username) VALUES ('$username');";
if ($conn->query($sql) === TRUE) {
header("location: index.php");
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
?>
You can add more form elements, Javascript Validations etc as per your requirement.
When trying to submit my form I get the following error message:
Notice: Undefined index: application_results in C:\xampp\htdocs\cas\insert.php
This is my form php code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>CAS Application</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.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body style="background-color:#FF9933">
<div class="container" >
<form action="insert.php" method="post" class="form-horizontal" role="form" enctype="multipart/form-data">
<h2 style="text-align:center">Application Form</h2>
</div>
<div class="form-group">
<label for="surname" class="col-sm-3 control-label">Surname</label>
<div class="col-sm-9">
<input type="text" name="surname" id="surname" placeholder="Surname" class="form-control" autofocus>
</div>
</div>
<div class="form-group">
<label for="firstName" class="col-sm-3 control-label">First Name</label>
<div class="col-sm-9">
<input type="text" name="first_name" id="first_name" placeholder="First Name" class="form-control" autofocus>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-3 control-label">Email</label>
<div class="col-sm-9">
<input type="text" id="email" placeholder="Email" class="form-control" name="email">
</div>
</div>
<div class="col-sm-offset-3">
<h2>Application Results</h2>
<label for="application_results">Please upload your application results here:</label>
<input type="file" name="application_results" ><br>
</div>
<div class="form-group">
<div class="col-sm-6 col-sm-offset-3">
<button type="submit" class="btn btn-primary btn-block" name="submit">Submit</button>
</div>
</div>
</form>
</div>
</body>
</html>
<?php
$con = mysql_connect("localhost","root","");
mysql_select_db("cas",$con);
if(isset($_POST['submit'])) {
$file = rand(1000,100000). "-".$_FILES['application_results']['name'];
$file_loc = $_FILES['application_results']['tmp_name'];
$folder="application_results";
if(move_uploaded_file($file)) {
$sql="INSERT INTO applications (application_results) VALUES ($application_results)";
mysql_query($sql);
}
}
?>
This is my code for insertion:
<?php
$link = mysqli_connect("localhost", "root", "", "cas");
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$surname = mysqli_real_escape_string($link, $_REQUEST['surname']);
$first_name = mysqli_real_escape_string($link, $_REQUEST['first_name']);
$email = mysqli_real_escape_string($link, $_REQUEST['email']);
$application_results = mysqli_real_escape_string($link, $_REQUEST['application_results']);
// attempt insert query execution
$sql = "INSERT INTO applications ( surname, first_name,
email, application_results )
VALUES ('$surname', '$first_name', '$email', $application_results )";
if(mysqli_query($link, $sql)){
echo "Your application has been submitted.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// close connection
mysqli_close($link);
?>
What I am actually trying to accomplish is after insertion when calling an applications.php page details of the applicant must be displayed together with the uploaded file for reading. I suspect most of the uploaded files will be in pdf.
My PHP page is unable to pick values from HTML form. It's sending blank strings to database. Here is my HTML and PHP code. Please find error. I am new to PHP, unable to solve the problem.
my html page:
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>LOGIN</title>
<link rel="stylesheet" href="css/reset.css">
<link rel='stylesheet prefetch' href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900|RobotoDraft:400,100,300,500,700,900'>
<link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<!-- Mixins-->
<!-- Pen Title-->
<div class="pen-title">
<h1>SYNCHPHONY</h1>
</div>
<div class="rerun">Rerun Pen</div>
<div class="container">
<div class="card"></div>
<div class="card">
<h1 class="title">Login</h1>
<form name="login" action="login.php" method="POST">
<div class="input-container">
<input type="text" id="loginid" required="required"/>
<label for="loginid">Login ID</label>
<div class="bar"></div>
</div>
<div class="input-container">
<input type="password" id="password" required="required"/>
<label for="password">Password</label>
<div class="bar"></div>
</div>
<div class="button-container">
<button><span>Go</span></button>
</div>
</form>
</div>
<div class="card alt">
<div class="toggle"></div>
<h1 class="title">Register
<div class="close"></div>
</h1>
<form name="register" action="register.php" method="POST">
<div class="input-container">
<input type="text" id="loginid" required="loginid"/>
<label for="loginid">Login ID</label>
<div class="bar"></div>
</div>
<div class="input-container">
<input type="password" id="password" required="required"/>
<label for="password">Password</label>
<div class="bar"></div>
</div>
<div class="button-container">
<button value'submitb'><span>Next</span></button>
</div>
</form>
</div>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>
my php page:
**strong text** <?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "syncphony";
$loginid="";
$password="";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(isset($_POST['loginid'])){ $loginid = $_POST['loginid']; }
if(isset($_POST['password'])){ $password = $_POST['password']; }
// Escape user inputs for security
$loginid = mysqli_real_escape_string($conn,$loginid);
$password = mysqli_real_escape_string($conn,$password);
// attempt insert query execution
$sql = "INSERT INTO users (loginid, password ) VALUES ('$loginid', '$password')";
if(mysqli_query($conn, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
}
// close connection
mysqli_close($conn);
?>
The inputs inside your form tag do not have names. Try this for login:
<input type="text" id="loginid" required="required" name="loginid"/>
and this for password:
<input type="password" id="password" required="required" name="password"/>
It would be nice if you would protect your users against XSS attacks and to use encryption when you store a password. Also, you should structure your code and make sure your HTML is valid.
I am trying to insert data submitted in a form, into a MySQL Database, and I can't see the problem in my code(except for MySQL injection, that I will work to resolve after actually being able to insert any data). I have searched in Stack Overflow, and found someone who probably worked by the same manual, but I work in localhost, he's on GoDaddy. The solution given there doesn't work for me.
Here is my code for the HTML and the PHP code:
<?php
require'connection/connect.php';
?>
<?php
if(isset($_POST['Register'])){
session_start();
$Fname = $_POST['FirstName'];
$Lname = $_POST['LastName'];
$Email = $_POST['Email'];
$pw = $_POST['Password'];
$sql= $con->query("INSERT INTO user (Fname,Lname,Email,Password) values('{$Fname}', '{$Lname}', '{$Email}', '{$pw}')");
}
?>
<!DOCTYPE html >
<html>
<head>
<link href="css/Master.css" rel="stylesheet" type="text/css" />
<link href="css/Menu.css" rel="stylesheet" type="text/css" />
<title>Register</title>
</head>
<body>
<div class="container">
<div class="header">
</div>
<div class="menu">
<div id="NavBar">
<nav>
<ul>
<li>
Login
</li>
<li>
Register
</li>
</ul>
</nav>
</div>
</div>
<div class="leftBody"></div>
<div class="rightBody">
<form action="" method="post" name="RegisterForm" id="RegisterForm">
<div class="FormElement">
<input name="FirstName" id="FirstName" type="text" placeholder="First Name" class="TField">
</div><br>
<div class="FormElement">
<input name="LastName" id="LastName" type="text" placeholder="Last Name" class="TField">
</div><br>
<div class="FormElement">
<input name="Email" id="Email" type="email" placeholder="E-Mail" class="TField">
</div><br>
<div class="FormElement">
<input name="Password" id="Password" type="password" placeholder="Password" class="TField">
</div><br>
<input name="Register" id="Register" type="button" value="Register" class="regButton">
</form>
</div>
<div class="footer"></div>
</div>
</body>
</html>
And this is my connection.php file:
That it does show that it connects.
<?php
$host="localhost";
$username="root";
$password="";
$dataBase="users";
$con=mysqli_connect($host,$username,$password,$dataBase);
if (!$con) {
die("Could not connect: " . mysqli_error());
}
echo "Connected successfully";
?>
And a picture of my database in phpMyAdmin:
Database
I have tried also using this line like this for some reason, but to no avail.:
$sql= $con->query("INSERT INTO user
(Fname,Lname,Email,Password)
values ('Fname', 'Lname', 'Email', 'pw')");
i didn't see submit button that actually submit the form. So if i am not wrong please try to use
<input name="Register" id="Register" type="submit" value="Register" class="regButton">
your code should be run
$sql= $con->query("INSERT INTO user
(Fname,Lname,Email,Password)
VALUES('$Fname', '$Lname', '$Email', '$pw')");