TomCreed TomCreed - 4 months ago 41
MySQL Question

PHP POST method not working?

I am a complete beginner and am trying to make a form for a project at university. I am just learning php and I am trying to test whether or not I can take the values from my php form and output it before I move on to linking it to my database. This is my full code for my login page, which btw I used bootstrap for some of the frame work. So I have tried to use the POST method and echo out first name and last name to see if it works, and it just wont echo out when I press the submit button. This is really frustrating me. Don't worry about the style, I just want to get the functionality out of the way first, and yes the page is called index.php .

<!doctype html>
<html lang='en'>
<title>Create Employee Account</title>

<!-- Required meta tags -->
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>

<!-- Bootstrap CSS -->
<link rel='stylesheet' href='' >

<link rel='stylesheet' href='no_dashboard_css_template.css'>
<link rel='stylesheet' href= ''>


include 'dbconnect.php';

echo $firstName;
echo $lastName;



<nav class='navbar navbar-expand-lg navbar-light bg-light'>
<img id='logo' src='logo.png'>
<button class='navbar-toggler' type='button' data-toggle='collapse' data-target='#navbarSupportedContent' aria-controls='navbarSupportedContent' aria-expanded='false' aria-label='Toggle navigation'>
<span class='navbar-toggler-icon'></span>

<div class='collapse navbar-collapse' id='navbarSupportedContent'>
<ul class='navbar-nav mr-auto'>
<li class='nav-item active'>
<a class='nav-link' href='#'>Home/Login<span class='sr-only'>(current)</span></a>
<!-- Main CONTAINER part of the page WHERE MOST PAGE CONTENT WILL GO -->
<div class='container-fluid'>

<div class='row'>


<div class='col-lg-4'>
<h3>Potential Employee Sign Up</h3>

<form action='index.php' method='POST' >

<!-- Title (Mr Mrs etc. -->
<label class='mr-sm-2' for='inlineFormCustomSelectPref'>Title</label>
<select name='title' class='custom-select mb-2 mr-sm-2 mb-sm-0' id='inlineFormCustomSelectPref'>
<option selected>Choose...</option>
<option value='1'>Mr</option>
<option value='2'>Ms</option>
<option value='3'>Mrs</option>

<!-- NAMES -->
<div class='row'>

<!-- First Name -->
<div class='col'>
<input type='text' class='form-control' name='firstname' placeholder='First name'>

<!-- Last Name -->
<div class='col'>
<input type='text' class='form-control' name='lastname' placeholder='Last name'>

<!-- Email and Password-->
<div class='form-group'>
<label for='exampleInputEmail1'>Email address</label>
<input type='text' class='form-control' id='exampleInputEmail1' name='email' placeholder='Enter email'>
<div class='form-group'>
<label for='exampleInputPassword1'>Password:</label>
<input type='password' class='form-control' name='password1' id='exampleInputPassword1' placeholder='Password'>
<label for='exampleInputPassword1'>Enter your Password again:</label>
<input type='password' class='form-control' name='password2' id='exampleInputPassword1' placeholder='Password'>
<!-- Terms and Conditions-->
<div class='form-check'>
<label class='form-check-label'>
<input type='checkbox' class='form-check-input'>
I have agreed and read the Terms and conditions

<!-- Education -->
<!-- University -->
<div class='form-group'>
<label for='exampleFormControlInput1'>University</label>
<input type='text' class='form-control' name='uni' id='exampleFormControlInput1' placeholder='Please Type your University'>
<!-- Degree Type -->
<label class='mr-sm-2' for='inlineFormCustomSelectPref'>Degree Type</label>
<select class='custom-select mb-2 mr-sm-2 mb-sm-0' name='degtype' id='inlineFormCustomSelectPref'>
<option selected>Choose...</option>
<option value='1'>BEng</option>
<option value='2'>MEng</option>
<option value='3'>MSc</option>
<!-- End Button to submit -->
<button type='submit' class='btn btn-primary' name='submit' >Sign Up!</button>




<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src='' ></script>
<script src='' ></script>
<script src='' ></script>

Answer Source

Your mistake is on this line


Use it

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download