Blank entries with SQL and PHP [duplicate] - php

This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 5 years ago.
I tried the other solutions on this and other sites, but can´t make it work.
When I press refresh empty data is sent to phpmyadmin, and a blank entry is made.
When I press submit it doesn´t send anything, not even blank.
My database connection is working.
conn
<?php
$host = 'localhost'; // min host.
$user = 'root'; // mit brugernavn.
$password = 'mysql'; // mit password. Er tomt for Windows-brugere, men root for Mac-brugere.
$database = 'boliger'; // navnet på min database.
$conn = new mysqli($host, $user, $password, $database);
mysqli_set_charset($conn, 'utf8');
if ($conn->connect_error)
die($conn->connect_error);
?>
index
<?php
include_once 'conn.php';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<link rel="apple-touch-icon" sizes="76x76" href="assets/img/apple-icon.png" />
<link rel="icon" type="image/png" href="assets/img/favicon.png" />
<title>Bolig</title>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<meta name="viewport" content="width=device-width" />
<!-- CSS Files -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
<link href="assets/css/paper-bootstrap-wizard.css" rel="stylesheet" />
<!-- CSS Just for demo purpose, don't include it in your project -->
<link href="assets/css/demo.css" rel="stylesheet" />
<!-- Fonts and Icons -->
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Muli:400,300' rel='stylesheet' type='text/css'>
<link href="assets/css/themify-icons.css" rel="stylesheet">
</head>
<body>
<div class="image-container set-full-height" style="background-image:">
<!-- Creative Tim Branding -->
<!-- Big container -->
<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<!-- Wizard container -->
<div class="wizard-container">
<div class="card wizard-card" data-color="green" id="wizard">
<form method="POST" action="process.php">
<!-- You can switch " data-color="green" " with one of the next bright colors: "blue", "azure", "orange", "red" -->
<div class="wizard-header">
<h3 class="wizard-title">Søg bolig</h3>
<p class="category">Denne information vil hjælpe os med, at denne et billed af dine bolig ønsker.</p>
</div>
<div class="wizard-navigation">
<div class="progress-with-circle">
<div class="progress-bar" role="progressbar" aria-valuenow="1" aria-valuemin="1" aria-valuemax="4" style="width: 15%;"></div>
</div>
<ul>
<li>
<a href="#location" data-toggle="tab">
<div class="icon-circle">
<i class="ti-map"></i>
</div>
Placering
</a>
</li>
<!--
<li>
<a href="#type" data-toggle="tab">
<div class="icon-circle">
<i class="ti-direction-alt"></i>
</div>
Type
</a>
</li>
-->
<li>
<a href="#facilities" data-toggle="tab">
<div class="icon-circle">
<i class="ti-panel"></i>
</div>
Kontakt Oplysninger
</a>
</li>
</ul>
</div>
<div class="tab-content">
<div class="tab-pane" id="location">
<div class="row">
<div class="col-sm-12">
<h5 class="info-text"> Lade os starte med, at få de grundlæggende oplysninger.</h5>
</div>
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label>Kommune 1</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Kommune du gerne vil have bolig i?">
</div>
<div class="form-group">
<label>Kommune 2</label>
<input type="text" class="form-control" id="exampleInputEmail1" placeholder="Kommune du gerne vil have bolig i?">
</div>
<div class="form-group">
<label>Kommune 3</label>
<input type="text" class="form-control" id="exampleInputEmail1" placeholder="Kommune du gerne vil have bolig i?">
</div>
<div class="form-group">
<label>Kommune 4</label>
<input type="text" class="form-control" id="exampleInputEmail1" placeholder="Kommune du gerne vil have bolig i?">
</div>
<div class="form-group">
<label>Kommune 5</label>
<input type="text" class="form-control" id="exampleInputEmail1" placeholder="Kommune du gerne vil have bolig i?">
</div>
</div>
<div class="col-sm-5 col-sm-offset">
<div class="form-group">
<label>Antal Voksne</label>
<select class="form-control">
<option disabled="" selected="">- Voksne -</option>
<option>1 Person</option>
<option>2 Personer </option>
<option>3 Personer</option>
<option>4 Personer</option>
<option>5 Personer</option>
<option>6+ Personer</option>
</select>
</div>
</div>
<div class="col-sm-5 col-sm-offset">
<div class="form-group">
<label>Antal Børn</label>
<select class="form-control">
<option disabled="" selected="">- Børn -</option>
<option>1 Barn</option>
<option>2 Børn </option>
<option>3 Børn</option>
<option>4 Børn</option>
<option>5 Børn</option>
<option>6+ Børn</option>
</select>
</div>
</div>
<div class="col-sm-5 col-sm-offset">
<div class="form-group">
<label>Antal Rum</label>
<select class="form-control">
<option disabled="" selected="">- Værelser -</option>
<option>1 Værelse</option>
<option>2 Værelser </option>
<option>3 Værelser</option>
<option>4 Værelser</option>
<option>5 Værelser</option>
<option>6+ Værelser</option>
</select>
</div>
</div>
<div class="col-sm-5 col-sm-offset">
<div class="form-group">
<label>Maksimum husleje inkl. forbrug</label>
<div class="input-group">
<input type="text" class="form-control" placeholder="Husleje">
<span class="input-group-addon">DKK</span>
</div>
</div>
</div>
<div class="col-sm-5 col-sm-offset">
<div class="form-group">
<label>Kæledyr</label>
<div class="checkbox">
<label><input type="checkbox" value="">Hvis du har kæledyr og ønsker, at det er tilladt i den nye bolig, så sæt venligst et flueben.</label>
</div>
</div>
</div>
</div>
</div>
<!--
<div class="tab-pane" id="type">
<h5 class="info-text">Hvilken form for bolig har du?</h5>
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<div class="col-sm-4 col-sm-offset-2">
<div class="choice" data-toggle="wizard-checkbox">
<input type="checkbox" name="jobb" value="Design">
<div class="card card-checkboxes card-hover-effect">
<i class="ti-home"></i>
<p>Lejlighed</p>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-checkbox">
<input type="checkbox" name="jobb" value="Design">
<div class="card card-checkboxes card-hover-effect">
<i class="ti-package"></i>
<p>Der komme flere på, i takt med, at vi udvider.</p>
</div>
</div>
</div>
</div>
</div>
</div>
-->
<div class="tab-pane" id="facilities">
<div class="row">
<div class="col-sm-12">
<h5 class="info-text">Dine kontaktoplysninger</h5>
</div>
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label>Navn</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Indtast navn">
</div>
</div>
<div class="col-sm-5 col-sm-offset">
<div class="form-group">
<label>Email</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Indtast email">
</div>
</div>
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label>Mobil nummer</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Indtast mobil nummer">
</div>
</div>
</div>
</div>
<div class="wizard-footer">
<div class="pull-right">
<input type='button' class='btn btn-next btn-fill btn-success btn-wd' name='next' value='Næste' />
<input type='submit' class='btn btn-finish btn-fill btn-success btn-wd' name="submit" value="Submit" />
</div>
<div class="pull-left">
<input type='button' class='btn btn-previous btn-default btn-wd' name='previous' value='Tilbage' />
</div>
<div class="clearfix"></div>
</div>
</form>
</div>
</div> <!-- wizard container -->
</div>
</div> <!-- row -->
</div> <!-- big container -->
<div class="footer">
<div class="container text-center">
</div>
</div>
</div>
<?php
if( isset( $_POST['submit'] ) )
{
$hvemErDu = $_POST['hvemErDu'];
} else {
echo error;
}
//connecting to sql database
$conn or die( $conn->error );
//inserting details into table
$insert = $conn->query( "INSERT INTO lejere ( `hvemErDu` ) VALUE ( '$hvemErDu' )" );
//closing mysqli connection
$mysqli->close;
//if ($_POST) {
// if (isset($_POST["Submit"])) {
// // $hvemErDu = $_POST["hvemErDu"];
// // Se side 250
// mysqli_query($conn, "INSERT INTO lejere (hvemErDu)
//VALUES ('$_POST[hvemErDu]')";
//
?>
</body>
<!-- Core JS Files -->
<script src="assets/js/jquery-2.2.4.min.js" type="text/javascript"></script>
<script src="assets/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/js/jquery.bootstrap.wizard.js" type="text/javascript"></script>
<!-- Plugin for the Wizard -->
<script src="assets/js/paper-bootstrap-wizard.js" type="text/javascript"></script>
<!-- More information about jquery.validate here: http://jqueryvalidation.org/ -->
<script src="assets/js/jquery.validate.min.js" type="text/javascript"></script>
</html>
process
<?php
//process.php
if ($_SERVER["REQUEST_METHOD"] == "POST") {//Check it is coming from a form
$u_name = $_POST["hvemErDu"]; //set PHP variables like this so we can use them anywhere in code below
//$u_email = $_POST["user_email"];
//$u_text = $_POST["user_text"];
//print output text
print "Hello " . $u_name . "!, we have received your message and email "; //.$u_email;
print "We will contact you very soon!";
}
?>

How does your form look like? Do you have a "submit" input at all?
From what I see in your code, SQL statement runs every time you send the form, without any condition, you better place the query inside the condition brackets, like:
<?php
if (isset( $_POST['submit'] ))
{
$hvemErDu = $_POST['hvemErDu'];
//connecting to sql database
$conn or die( $conn->error );
//inserting details into table
$insert = $conn->query("INSERT INTO lejere ( `hvemErDu` ) VALUE ( '$hvemErDu' )");
//closing mysqli connection
$mysqli->close;
} else
{
echo 'error';
}
?>
Pay attention that you also echo error - I'm not sure if you meant to echo the string 'error' or the variable $error.
But again, this time it looks like you won't have any record - not even a blank one, can you show the whole form code?
Update:
As for your code, pay attention that when you post your form, you submit it to process.php, is that file exists at all? as your code wouldn't work unless you submit the form to the same page, as the following code:
// Send the form to the same page - index.php
<form method="POST">
Update:
You've another problem, you've many inputs which share the same name: hvemErDu.
You've to give each input a unique name, otherwise the latest input's value is gonna be submitted to server.
This is from your index.php code:
<label>Kommune 1</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Kommune du gerne vil have bolig i?">
<label>Navn</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Indtast navn">
<label>Email</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Indtast email">
<label>Mobil nummer</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Indtast mobil nummer">

Related

Bootstrap 4 carousel next and prev slides don't work

I'm trying to solve an weird issue for a school group project on my own, but I'm at wit's end. Essentially, I have a Bootstrap 4 Carousel with three images. Though one of the images is displayed, you can't advance to the next or previous slides. The initial webpage is launched using php as follows:
<?php
//require_once('connection.php');
if (isset($_GET['controller']) && isset($_GET['action'])) {
$controller = $_GET['controller'];
$action = $_GET['action'];
} else {
$controller = 'static';
$action = 'landing';
}
require_once('views/layout.php');
?>
The landing page launches layout.php (which has the Bootstrap, jQuery, popper and other JavaScript files and landing.php (which has the carousel code:
landing.php:
<div id="main_container" class="container-fluid">
<div id="body" class="container">
<p>Stuff about how great the application is.</p>
<div id="carousel" class="carousel slide" content="width=device-width data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel" data-slide-to="0" class="active"></li>
<li data-target="#carousel" data-slide-to="1"></li>
<li data-target="#carousel" data-slide-to="2"></li>
</ol>
<!-- The slideshow -->
<div class="carousel-inner">
<div class="carousel-item active">
<img src="./views/images/kids_kites.png" alt="Los Angeles">
<div class="carousel-caption">
<h3>Los Angeles</h3>
<p>We had such a great time in LA!</p>
</div>
</div>
<div class="carousel-item">
<img src="./views/images/kids_playing.png" alt="Chicago">
<div class="carousel-caption">
<h3>Chicago</h3>
<p>We had such great pizza in CHI!</p>
</div>
</div>
<div class="carousel-item">
<img src="./views/images/kids_swing.png" alt="New York">
<div class="carousel-caption">
<h3>New York</h3>
<p>It is too crowded!</p>
</div>
</div>
</div>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#carousel" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#carousel" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
</div>
Search Events
</div>
layout.php
<!doctype HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<script defer src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script defer src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"
integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<title>Kamps For Kids</title>
<link rel="stylesheet" href="views/styles/styles.css">
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script defer src="views/scripts/main.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
</head>
<body>
<?php
require_once "templates/header.php";
require_once "templates/footer.php";
require_once "routes.php";
?>
<div id="id01" class="modal">
<!--action_page.php is the php file which will perform user validation when the 'submit' button is clicked -->
<form class="modal-content animate" action="/action_page.php">
<div class="img-container">
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">×</span>
<div><img src="./views/images/KamparoosLogo.png" alt="Logo" class="logo"></div>
<img src="./views/images/img_avatar2.png" alt="Avatar" class="avatar">
<div>
<!-- Add icon library from font-awesome -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Add font awesome icons -->
</div>
</div>
<div class="container">
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="user-name" required>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
<label>
<input type="checkbox" checked="checked" name="remember"> Remember me
</label>
</div>
<div class="container" style="background-color:#FAFC2F">
<button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancel-btn">
Cancel
</button>
<span class="psw">Forgot password?</span>
</div>
</form>
</div>
<div id="id02" class="modal">
<!--action_page.php is the php file which will perform user validation when the 'submit' button is clicked -->
<form class="modal-content animate" name="registrationForm" onsubmit="return validateForm()" method="post"
action="/action_page.php">
<div class="img-container">
<h3>Registration Form</h3>
<span onclick="document.getElementById('id02').style.display='none'" class="close" title="Close Modal">×</span>
<div><img src="./views/images/KamparoosLogo.png" alt="Logo" class="logo"></div>
<img src="./views/images/img_avatar2.png" alt="Avatar" class="avatar">
<div>
<!-- Add icon library from font-awesome -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</div>
</div>
<div class="container">
<div class="form-row">
<div class="form-group col-md-6">
<label for="firstName">First Name</label>
<input type="text" class="form-control" id="firstName" placeholder="Enter first name" name="firstName"
required>
</div>
<div class="form-group col-md-6">
<label for="lastName">Last Name</label>
<input type="text" class="form-control" id="lastName" placeholder="Enter last name" name="lastName"
required>
</div>
<div class="form-group col-md-6">
<label for="emailAddress">Email Address</label>
<input type="email" class="form-control" id="emailAddress" placeholder="Enter email address"
name="emailAddress" required>
</div>
<div class="form-group col-md-6">
<label for="phoneNumber">Phone Number</label>
<input type="tel" class="form-control" id="phoneNumber" placeholder="Enter 10 digit phone number"
name="phoneNumber" required
pattern="[0-9]{3}[0-9]{3}[0-9]{4}"
size="10">
</div>
<div class="form-group col-md-12">
<label for="numOfKids">Number of Kids </label>
<select name="numOfKids" id="numOfKids">
<option value="">Select...</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 class="form-group col-md-4">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" placeholder="Enter password" name="password"
required>
</div>
<div class="form-group col-md-4">
<label for="confirmPassword">Confirm Password</label>
<input type="password" class="form-control" id="confirmPassword" placeholder="Re-enter password"
name="confirmPassword" required>
</div>
<div class="form-group col-md-12">
<label for="userRole">Register as </label>
<select name="userRole" id="userRole" required>
<option value="">Select...</option>
<option value="user">Individual User</option>
<option value="admin">Admin</option>
<option value="organization">Organization</option>
</select>
</div>
</div>
</div>
<button type="submit" class="btn btn-danger btn-success"
">Register</button>
</form>
</div>
<script>
// Get the modal
var modal = document.getElementById('id01');
// When the user clicks anywhere outside of the modal, the modal with close
window.onclick = function (event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
// Get the modal
var modalTwo = document.getElementById('id02');
// When the user clicks anywhere outside of the modal, the modal with close
window.onclick = function (event) {
if (event.target == modalTwo) {
modal.style.display = "none";
}
}
</script>
</body>
</html>
If you're interested, the project is being saved in a GitHub repository at : https://github.com/ad410project/ad410project I'm sure it's possible some crazy php issue, but any help or suggestions would be appreciated.

php error and even after defining variable

this is my block of code for insert product of my project
<?php
include('includes/db.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html lang="EN">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="images/logo.jpg" type="image/x-icon" />
<title>Insert Products</title>
<script src="https://cloud.tinymce.com/stable/tinymce.min.js"></script>
<script>tinymce.init({ selector:'textarea' });</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="fontawesome/css/font-awesome.min.css" />
</head>
<body>
<div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<li class="active"><i class="fa fa-dashboard"></i>Dashboard/Insert Products</li>
</ol> <!--breadcrumb ends here-->
</div> <!---col-lg-12 ends-->
</div> <!--row ends-->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-money fa-fw"></i> Insert Products
</h3>
</div> <!--panel heading ends--->
<div class="panel-body">
<form class="form-horizontal" method="post" enctype="multipart/form-data">
<div class="form-group">
<label class="col-md-3 control-label" >Product title</label>
<div class="col-md-6">
<input type="text" name="product_title" class="form-control" required>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Category</label>
<div class="col-md-6">
<select name="product_cat" class="form-control" required>
<option>Select Category</option>
<?php
$get_p_cats="select * from product_categories";
$run_p_cats=mysqli_query($conn,$get_p_cats);
while($row_p_cats=mysqli_fetch_array($run_p_cats)){
$p_cat_id=$row_p_cats['p_cat_id'];
$p_cat_title=$row_p_cats['p_cat_title'];
echo "<option value='$p_cat_id'>$p_cat_title</option>";
}
?>
</select>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Category</label>
<div class="col-md-6">
<select name="cat" class="form-control" required>
<option>Select Category</option>
<?php
$get_cat="select * from categories";
$run_cat=mysqli_query($conn,$get_cat);
while($row_cat=mysqli_fetch_array($run_cat)){
$cat_id=$row_cat['cat_id'];
$cat_title=$row_cat['cat_title'];
echo "<option value='$cat_id'>$cat_title</option>";
}
?>
</select>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Image 1</label>
<div class="col-md-6">
<input type="file" name="product_img1" class="form-control" required>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Image 2</label>
<div class="col-md-6">
<input type="file" name="product_img2" class="form-control" required>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Image 3</label>
<div class="col-md-6">
<input type="file" name="product_img3" class="form-control" required>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Price</label>
<div class="col-md-6">
<input type="text" name="product_price" class="form-control" required>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Keywords</label>
<div class="col-md-6">
<input type="text" name="product_keywords" class="form-control" required>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Description</label>
<div class="col-md-6">
<textarea name="product_desc" class="form-control" rows="6" cols="19" style="max-width:100%; max-height:100%;"></textarea>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" ></label>
<div class="col-md-6">
<input type="submit" name="submit" value="Insert Product" class="btn btn-primary form-control">
</div>
</div> <!---form-group-->
</form> <!--form-horizontal ends--->
</div> <!--panel-body ends-->
</div> <!---panel panel-default ends-->
</div> <!--col-lg-12 ends--->
</div> <!--row 2 ends-->
</body>
</html>
<?php
if(isset($_POST['submit'])){
$product_title=$_POST['product_title'];
$product_cat=$_POST['product_cat'];
$cat=$_POST['cat'];
$product_price=$_POST['product_price'];
$product_desc=$_POST['product_desc'];
$product_keyword=$_POST['product_keywords'];
$product_img1=$_FILES['product_img1']['name'];
$product_img2=$_FILES['product_img2']['name'];
$product_img3=$_FILES['product_img3']['name'];
$temp_name1=$_FILES['product_img1']['tmp_name'];
$temp_name2=$_FILES['product_img2']['tmp_name'];
$temp_name3=$_FILES['product_img3']['tmp_name'];
move_uploaded_file($temp_name1,"product_images/$product_img1");
move_uploaded_file($temp_name2,"product_images/$product_img2");
move_uploaded_file($temp_name3,"product_images/$product_img3");
$insert_product="insert into products(p_cat_id,cat_id,date,product_title,product_img1,product_img2,product_img3,product_price,product_desc,product_keywords) values( '$product_cat','$cat',NOW(),'$product_title','$product_img1','$product_img2','$product_img3','$product_price','$product_desc','$product_keyword')";
$run_product=mysqli_query($conn,$insert_product);
if($run_product){
echo "<script>alert('Product has been inserted successfully')</script>";
echo "<script>window.open('insert.php','self')</script>";
}
}
?>
Even after defining variable i get error Undefined index: product_price in C:\xampp\htdocs\RangProject\admin_area\insert_products.php on line 183
this is my line 183
$product_price=$_POST['product_price'];
can someone tell me what my mistake is?? Php is quite confusing and case sensitive.
check if your post is not empty before assigning.
$product_price = isset($_POST['product_price']) ? $_POST['product_price'] : '';
fixed my error. Just added this after taking some advice from all my replies i got. Thanks everyone.
$product_title=mysqli_real_escape_string($conn,$_POST['product_title']);
$product_cat=mysqli_real_escape_string($conn,$_POST['product_cat']);
$cat=mysqli_real_escape_string($conn,$_POST['cat']);
$product_price =mysqli_real_escape_string($conn,$_POST['product_price']);
$product_desc=mysqli_real_escape_string($conn,$_POST['product_desc']);
$product_keyword=mysqli_real_escape_string($conn,$_POST['product_keywords']);
This happens because "product_price" does not exist on $_POST.
To avoid this error, check if it exists first using isset():
$product_price = isset($_POST['product_price']) ? $_POST['product_price'] : '';

Login Butto returning to the same page. Instead of Home

Iam creating a page. The sign up works fine and takes me to home page but after logging out and trying to login again. The login button redirects me back to the registration page.
Please Help! I have checked through over and over and cant find any error.
login.php
<?php
if(isset($_POST['Login']))
{error_reporting(1);
$connection = mysqli_connect('localhost','root','','uni-saga');
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$user=$_POST['username'];
$pass=$_POST['password'];
$que1=mysqli_query($connection,"select * from users where Email='$user' and Password='$pass'");
$count1=mysqli_num_rows($que1);
if($count1>0)
{
session_start();
$_SESSION['tempsagauser']=$user;
$que6=mysqli_query("select * from users where Email='$user'");
$rec6=mysqli_fetch_array($que6);
$userid=$rec6[0];
$que2=mysqli_query($connection,"select * from user_profile_pic where user_id=$userid");
$count2=mysqli_num_rows($que2);
if($count2>0)
{
$que3=mysqli_query($connection,"select * from user_secret_quotes where user_id=$userid");
$count3=mysqli_num_rows($que3);
if($count3>0)
{
$que4=mysqli_query($connection,"select * from user_secret_quotes where user_id=$userid");
while($rec=mysqli_fetch_array($que4))
{
$que2=$rec[3];
$ans2=$rec[4];
}
if($que2=="" && $ans2=="")
{
header("location:saga_files/saga_step/saga_step3/Secret_Question2.php");
}
else
{
session_start();
$_SESSION['sagauser']=$user;
$query1=mysqli_query($connection,"select * from users where Email=$user");
$rec1=mysqli_fetch_array($query1);
$userid=$rec1[0];
mysqli_query($connection,"update user_status set status='Online' where user_id='$userid'");
header("location:saga_files/saga_home/Home.php");
}
}
else
{
header("location:saga_files/saga_step/saga_step2/Secret_Question1.php");
}
}
else
{
while($rec=mysqli_fetch_array($que1))
{
$Gender=$rec[4];
}
if($Gender=="Male")
{
header("location:saga_files/saga_step/saga_step1/Step1_Male.php");
}
else
{
header("location:saga_files/saga_step/saga_step1/Step1_Female.php");
}
}
}
else
{
$que5=mysqli_query($connection,"select * from users where Email='$user'");
$count5=mysqli_num_rows($que5);
if($count5>0)
{
header("location:Invalid_Password.php");
}
else
{
header("location:Invalid_Username.php");
}
}
}
?>
index.php
<?php
include("Login.php");
include("saga_files/saga_index_file/saga_SignUp_file/SignUp.php");
?>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>UniSaga</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/ionicons.min.css" />
<link rel="stylesheet" href="css/font-awesome.min.css" />
<!--Google Font-->
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,400i,700,700i" rel="stylesheet">
<!--Favicon-->
<link rel="shortcut icon" type="image/png" href="images/fav.png"/>
</head>
<script>
function time_get()
{
d = new Date();
mon = d.getMonth()+1;
time = d.getDate()+"-"+mon+"-"+d.getFullYear()+" "+d.getHours()+":"+d.getMinutes();
}
</script>
<header id="header-inverse">
<nav class="navbar navbar-default navbar-fixed-top menu">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index-register.html"><img src="images/logo.png" alt="logo" /></a>
</div>
</div>
</nav>
</header>
<div id="lp-register">
<div class="container wrapper">
<div class="row">
<div class="col-sm-5">
<div class="intro-texts">
<h1 class="text-white">UniSaga</h1>
<p>Connect With Students from other Your University and Other Universities and get the latest news on what is Happening Around these learning Institutions. <br /> <br />What Are You Waiting For. Join Now And Experience It Like Never Before.</p>
</div>
</div>
<div class="col-sm-6 col-sm-offset-1">
<div class="reg-form-container">
<div class="reg-options">
<ul class="nav nav-tabs">
<li class="active">Register</li>
<li>Login</li>
</ul><!--Tabs End-->
</div>
<!--Registration Form Contents-->
<div class="tab-content">
<div class="tab-pane active" id="register">
<h3>Register Now !!!</h3>
<p class="text-muted">Its Free and Always Will Be.</p>
<!--Register Form-->
<form method="post" name="registration_form" id='registration_form' class="form-inline">
<div class="row">
<div class="form-group col-xs-6">
<label for="first_name" class="sr-only">First Name</label>
<input id="first_name" class="form-control input-group-lg" type="text" name="first_name" title="Enter first name" placeholder="First name"/>
</div>
<div class="form-group col-xs-6">
<label for="last_name" class="sr-only">Last Name</label>
<input id="last_name" class="form-control input-group-lg" type="text" name="last_name" title="Enter last name" placeholder="Last name"/>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label for="email" class="sr-only">Email</label>
<input id="email" class="form-control input-group-lg" type="text" name="email" title="Enter Email" placeholder="Your Email"/>
</div>
<div class="form-group col-xs-12">
<label for="remail" class="sr-only">Re-Enter Email</label>
<input id="remail" class="form-control input-group-lg" type="text" name="remail" title="Enter Email" placeholder="Re-Enter Your Email"/>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label for="password" class="sr-only">Password</label>
<input id="password" class="form-control input-group-lg" type="password" name="password" title="Enter password" placeholder="Password"/>
</div>
</div>
<div class="row">
<p class="birth"><strong>Date of Birth</strong></p>
<div class="form-group col-sm-3 col-xs-6">
<label for="month" class="sr-only"></label>
<select name="day" class="form-control" id="Day">
<option value="Day" disabled selected>Day</option>
<script type="text/javascript">
for(i=1;i<=31;i++)
{
document.write("<option value='"+i+"'>" + i + "</option>");
}
</script>
</select>
</div>
<div class="form-group col-sm-3 col-xs-6">
<label for="month" class="sr-only"></label>
<select name="month" class="form-control" id="Month">
<option value="Month" disabled selected>Month</option>
<script type="text/javascript">
var m=new Array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
for(i=1;i<=m.length-1;i++)
{
document.write("<option value='"+i+"'>" + m[i] + "</option>");
}
</script>
</select>
</div>
<div class="form-group col-sm-6 col-xs-12">
<label for="year" class="sr-only"></label>
<select name="year" class="form-control" id="Year">
<option value="Year" disabled selected>Year</option>
<script type="text/javascript">
for(i=2000;i>=1960;i--)
{
document.write("<option value='"+i+"'>" + i + "</option>");
}
</script>
</select>
</div>
</div>
<div class="form-group gender">
<select name="sex" style="width:120;height:35;font-size:18px;padding:3;">
<option value="Select Sex:"> Select Sex: </option>
<option value="Female"> Female </option>
<option value="Male"> Male </option>
</select>
</div>
<div class="row">
<div class="form-group col-xs-6">
<label for="campus" class="sr-only">Campus</label>
<input id="campus" class="form-control input-group-lg reg_name" type="text" name="campus" title="Enter campus" placeholder="Your campus"/>
</div>
<div class="form-group col-xs-6">
<label for="county" class="sr-only"></label>
<select name="county" class="form-control" id="county">
<option value="county" disabled selected>County</option>
<option value="Baringo">Baringo</option>
<option value="Bomet">Bomet</option>
<option value="Bungoma">Bungoma</option>
<option value="Busia">Busia</option>
<option value="Elgeyo">Elgeyo Marakwet</option>
<option value="Embu">Embu</option>
<option value="Garissa">Garissa</option>
<option value="Homa">Homa Bay</option>
<option value="Isiolo">Isiolo</option>
<option value="Kajiado">Kajiado</option>
<option value="Kakamega">Kakamega</option>
<option value="Kericho">Kericho</option>
<option value="Kiambu">Kiambu</option>
<option value="Kilifi">Kilifi</option>
<option value="Kirinyaga">Kirinyaga</option>
<option value="Kisii">Kisii</option>
<option value="Kisumu">Kisumu</option>
<option value="Kitui">Kitui</option>
<option value="Kwale">Kwale</option>
<option value="Laikipia">Laikipia</option>
<option value="Lamu">Lamu</option>
<option value="Machakos">Machakos</option>
<option value="Makueni">Makueni</option>
<option value="Mandera">Mandera</option>
<option value="Meru">Meru</option>
<option value="Migori">Migori</option>
<option value="Marsabit">Marsabit</option>
<option value="Mombasa">Mombasa</option>
<option value="Muranga">Muranga</option>
<option value="Nairobi">Nairobi</option>
<option value="Nakuru">Nakuru</option>
<option value="Nandi">Nandi</option>
<option value="Narok">Narok</option>
<option value="Nyamira">Nyamira</option>
<option value="Nyandarua">Nyandarua</option>
<option value="Nyeri">Nyeri</option>
<option value="Samburu">Samburu</option>
<option value="Siaya">Siaya</option>
<option value="Taita">Taita Taveta</option>
<option value="Tana">Tana River</option>
<option value="Tharaka">Tharaka Nithi</option>
<option value="Trans">Trans Zoia</option>
<option value="Turkana">Turkana</option>
<option value="Uasin">Uasin Gishu</option>
<option value="Vihiga">Vihiga</option>
<option value="Wajir">Wajir</option>
<option value="West">West Pokot</option>
</select>
</div>
</div>
<button type="submit" name="signup" id="sign_button" class="btn btn-primary" / onClick="time_get()" >Register Now</button>
</form>
</div>
<div class="tab-pane" id="login">
<h3>Login</h3>
<p class="text-muted">Log into your account</p>
<!--Login Form-->
<form method="post" name="Login_form" id='Login_form'>
<div class="row">
<div class="form-group col-xs-12">
<label for="my-email" class="sr-only">Email</label>
<input id="my-email" class="form-control input-group-lg" type="text" name="username" title="Enter Email" placeholder="Your Email"/>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label for="my-password" class="sr-only">Password</label>
<input id="my-password" class="form-control input-group-lg" type="password" name="password" title="Enter password" placeholder="Password"/>
</div>
</div>
<p>Forgot Password</p>
<button name="Login" id="login_button" class="btn btn-primary">Login Now</button>
</form><!--Login Form Ends-->
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-6">
<!--Social Icons-->
<ul class="list-inline social-icons">
<li><i class="icon ion-social-facebook"></i></li>
<li><i class="icon ion-social-twitter"></i></li>
<li><i class="icon ion-social-googleplus"></i></li>
<li><i class="icon ion-social-pinterest"></i></li>
<li><i class="icon ion-social-linkedin"></i></li>
</ul>
</div>
</div>
</div>
</div>
<!--preloader-->
<div id="spinner-wrapper">
<div class="spinner"></div>
</div>
<!-- Scripts
================================================= -->
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.appear.min.js"></script>
<script src="js/jquery.incremental-counter.js"></script>
<script src="js/script.js"></script>
</body>
</html>
<?php
include("saga_files/saga_index_file/saga_erorr_file/saga_erorr.php");
?>
</body>
</html>
1) Your session doesn't preserve its state, e.g. it's closed immediately after your login.php page finished processing. That happens because you're calling session_start() inside your code in login.php. So, you must move your session_start() to the first line in login.php. No code should reside before it.
And use it ONLY ONCE! (You use session_start twice)
See: PHP session for tracking unique page views
2) Also: Login_form needs an action attribute (login.php). Otherwise the form is posted to the page were it resides, e.g to index.php. So:
<form method="post" action="login.php" name="Login_form" id="Login_form">
3) And there is a typo here (/):
<button type="submit" name="signup" id="sign_button" class="btn btn-primary" / onClick="time_get()" >Register Now</button>
Good luck.

PHP Radio Buttons forms example

So lets say i have the following example how can i get values from radio buttons and acctualy work with those values? You can see that i tried something but i can't find it how to make it work ..
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<link href="css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="css/bootstrap.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-ex-collapse"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand">My learning skills: A self-assessment questionnaire</a></div>
<div class="collapse navbar-collapse" id="navbar-ex-collapse">
<ul class="nav navbar-nav navbar-right"></ul>
</div>
</div>
</div>
<div class="section">
<div class="container">
<div class="row">
<div class="col-md-12">
<form role="form" method="post">
<div class="form-group"><label class="control-label" for="exampleInputEmail1">Nume:</label><input class="form-control input-lg" id="exampleInputEmail1" placeholder="Enter name" type="text"></div>
<div class="form-group"><label class="control-label" for="exampleInputEmail1">Email address:</label><input class="form-control input-lg" id="exampleInputEmail1" placeholder="Enter email" type="email"></div>
<div class="container">
<div class= "row">
<h4>Your gender: *</h4>
</div>
<div class="row">
<div class="radio">
<label><input type="radio" name="gender" value="female">F</label>
</div>
<div class="radio">
<label><input type="radio" name="gender" value="male">M</label>
</div>
<div class="radio">
<label><input type="radio" name="gender" value="other">Other</label>
</div>
</div>
</br>
<div class="row">
<div class="form-group"><label class="control-label" for="exampleInputEmail1">Your age: *</label><input class="form-control input-lg" id="exampleInputEmail1" placeholder="Enter age" type="text"></div>
</div>
<div class= "row">
<h2>That was it! Please, keep your scores saved and check that after refilling in this questionnaire, in 6-8 months from now on. Happy learning!</h2>
</div>
<div class= "row">
<button type="submit" name="submit" value="submit" class="btn btn-primary btn-lg">Send</button>
</div>
</div>
</form>
<?php $gender = $_POST['contact']; echo $gender; ?>
</div>
</div>
</div>
</div>
</body>
</html>
As example:
echo $gender;
and the results should be $female
<?php $gender = $_POST['contact']; echo $gender; ?>
Change this to
<?php $gender = $_POST['gender']; echo $gender; ?>.
Name of your radio control is gender not contact.

Registration form bringing back login credentials

I have made a user registration form in PHP and when I access the page the username part of the form is already filled in as my own log in credentials and the same with the password. The other parts of the form are filled in as an undefined index also.
Below shows the form and PHP code for my registration form. The form itself actually works and populates to my database.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>Ballymena Sports</title>
<!-- Bootstrap core CSS -->
<link href="bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="home2.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Ballymena Sports</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li>Log out</li>
</ul>
</div>
</nav>
<?php
include"config.php";
if(isset($_POST["submit"])){
$username=$_POST['username'];
$password=$_POST['password'];
$forename=$_POST['forename'];
$surname=$_POST['surname'];
$email=$_POST['email'];
$telephone=$_POST['telephone'];
$address1=$_POST['address1'];
$town=$_POST['town'];
$postcode=$_POST['postcode'];
$q = $db->prepare("SELECT * FROM user WHERE username = ?");
$query = $q-> execute(array($username));
$count = $q->rowCount();
if($count == 0) {
$query = $db->prepare("INSERT INTO user SET username = ?, password = ?, forename = ?, surname = ?, email = ?, telephone = ?, address1 = ?, town=?, postcode=? ");
$query = $query->execute(array($username,$password,$forename,$surname,$email,$telephone,$address1,$town,$postcode));
if($query){
echo "User successfully registered";
header("Location:home2_template.html");
return;
} else {
echo "Fail";
}
} else {
echo "User already exists";
}
}
?>
<!-- Main part of homepage -->
<div class="jumbotron">
<div class="container">
<div id="registerBody">
<h2>Register your account</h2>
<p>All fields within the registration form must be filled in</p>
</div>
<div class = "register">
<form method="POST" class="form-horizontal" action="">
<div class="form-group">
<label for="username" class="col-sm-2 control-label">Username:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="username" name="username" value="<?php echo $username ?>"required="required">
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Password:</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="password" name="password" value="<?php echo $password ?>"required="required">
</div>
</div>
<div class="form-group">
<label for="forename" class="col-sm-2 control-label">Forename:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="forename" name="forename" value="<?php echo $forename ?>"required="required">
</div>
</div>
<div class="form-group">
<label for="surname" class="col-sm-2 control-label">Surname:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="surname" name="surname" value="<?php echo $surname ?>"required="required">
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">Email:</label>
<div class="col-sm-10">
<input type="email" pattern="[a-z0-9._%+-]+#[a-z0-9.-]+\.[a-z]{2,3}$" class="form-control" id="email" name="email" placeholder="Match email format of 'email#provider.com'" value="<?php echo $email ?>"required="required">
</div>
</div>
<div class="form-group">
<label for="telephone" class="col-sm-2 control-label">Telephone:</label>
<div class="col-sm-10">
<input type="text" pattern="[0-9]{11}" class="form-control" id="telephone" name="telephone" placeholder="Match telephone format of 11 digits" value="<?php echo $telephone ?>"required="required">
</div>
</div>
<div class="form-group">
<label for="address1" class="col-sm-2 control-label">Address:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="address1" name="address1" value="<?php echo $address1 ?>"required="required">
</div>
</div>
<div class="form-group">
<label for="town" class="col-sm-2 control-label">Town:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="town" name="town" value="<?php echo $town ?>"required="required">
</div>
</div>
<div class="form-group">
<label for="postcode" class="col-sm-2 control-label">Postcode:</label>
<div class="col-sm-10">
<input type="text" pattern ="[A-Za-z]{1,2}[0-9Rr][0-9A-Za-z]? [0-9][ABD-HJLNP-UW-Zabd-hjlnp-uw-z]{2}" class="form-control" id="postcode" name="postcode" placeholder="Match postcode format of 'XX00 0XX' "value="<?php echo $postcode ?>"required="required">
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<input id="button" name="submit" type="submit" value="Register" class="btn btn-primary">
</div>
</div> <!-- registration button -->
</form>
</div> <!-- registration end -->
</div> <!-- container end -->
</div> <!-- jumbo end -->
<br>
<!--<div class="form-group">
<div class="col-sm-10">
<input id="submit" name="reg" type="submit" value="Register" class="btn btn-primary">
</div>
</div> -->
<!-- end of reg -->
<div class="container">
<br>
<footer>
<p>© Ballymena Sports 2014</p>
</footer>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="../../dist/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
Cheers
Stuart
Initialize all the variables with an empty string. You problem will be
resolved.
<?php
$username="";
$password="";
$forename="";
$surname="";
$email="";
$telephone="";
$address1="";
$town="";
$postcode="";
if(isset($_POST["submit"])){
$username=$_POST['username'];
$password=$_POST['password'];
$forename=$_POST['forename'];
$surname=$_POST['surname'];
$email=$_POST['email'];
$telephone=$_POST['telephone'];
............
..........
......
..}

Categories