I'm new here so I apologize beforehand if i don't make the questions right, or give too much information (or less).
I have this problem making my login page in php: in many lines, it gives me syntax errors.
These lines are: 31, 39, 42, 43, 55, 56, 57, 62, 63, 65, 68, 71, 73, 77, 79, 80, 85, 93, 94, 95, 96, 97, 101, 103, 111, 112, 113, 114, 115, 119.
Sorry if I put so many errors, i'm learning and searched all over the web for tutorials but they didn't help me.
and here's my entire code:
<?php
$servername = "localhost";
$email="root";
$password="";
$dbname="testnew";
//create connection
$conn = new MySQLi($servername, $email, $password, $dbname);
//check the connection
if($con->connect_error){
die("connection failed".$conn->connect_error);
}
if(isset($_POST['email'])){
$email = $_POST['email'];
$pass = $_POST['pass'];
$sql = "SELECT * FROM loginnnew WHERE email='".$email."' AND password='".$pass."' LIMIT 1;
$result = $conn->query(sql);
if($result->num_rows>0){
echo 'Has iniciado sesión correctamente'
exit();
}else{
echo 'Contraseña o e-mail incorrectos.';
exit();
}
}
}
?>
<!DOCTYPE html>
<html >
<head>
<title>Responsive Login/Signup Modal Window</title>
<script src='https://s.codepen.io/assets/libs/modernizr.js' type="text/javascript"></script>
<link href='https://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/148866/reset.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel="stylesheet" href="file:///C|/Users/PC 1/Desktop/ADOBE SOFTWARES/responsive-login-signup-modal-window/css/style.css">
<style type="text/css">
body,td,th {
color: #FFFFFF;
}
body {
background-color: #9E1B1D;
}
</style>
</head>
<body>
<body>
<header role="banner">
<div id="cd-logo"><img src="Images/HEADERIC.png" alt="Logo"></div>
<nav class="main-nav">
<ul>
<!-- inser more links here -->
<li><a class="cd-signin" href="#0">Inicia Sesión</a></li>
<li><a class="cd-signup" href="file:///C|/Users/PC 1/Desktop/ADOBE SOFTWARES/responsive-login-signup-modal-window/registro.html">Registrarse</a></li>
</ul>
</nav>
</header>
<div class="cd-user-modal"> <!-- this is the entire modal form, including the background -->
<div class="cd-user-modal-container"> <!-- this is the container wrapper -->
<ul class="cd-switcher">
<li>Sign in</li>
</ul>
<div id="cd-login"> <!-- log in form -->
<form method="post" action="/paginainicio.php" class="cd-form">
<p class="fieldset">
<label class="image-replace cd-email" for="signin-email">E-mail</label>
<input name="email" class="full-width has-padding has-border" id="signin-email" type="email" placeholder="E-mail">
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<label class="image-replace cd-password" for="signin-password">Contraseña</label>
<input name="pass" class="full-width has-padding has-border" id="signin-password" type="text" placeholder="Contraseña">
Hide
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<input type="checkbox" id="remember-me" checked>
<label for="remember-me">Recordarme</label>
</p>
<p class="fieldset">
<input class="full-width" type="submit" value="Inicia Sesión">
</p>
</form>
<p class="cd-form-bottom-message">¿Has olvidado tu contraseña?</p>
<!-- Close -->
</div> <!-- cd-login -->
<div id="cd-reset-password"> <!-- reset password form -->
<p class="cd-form-message">¿Has olvidado tu contraseña? Ingresa tu e-mail y te enviaremos un link para recuperarla.</p>
<form class="cd-form">
<p class="fieldset">
<label class="image-replace cd-email" for="reset-email">E-mail</label>
<input class="full-width has-padding has-border" id="reset-email" type="email" placeholder="E-mail">
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<input class="full-width has-padding" type="submit" value="Reset password">
</p>
</form>
<p class="cd-form-bottom-message">Volver al Login</p>
</div> <!-- cd-reset-password -->
Cerrar
</div> <!-- cd-user-modal-container -->
</div> <!-- cd-user-modal -->
</body>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="file:///C|/Users/PC 1/Desktop/ADOBE SOFTWARES/responsive-login-signup-modal-window/js/index.js"></script>
<img src="Images/separator50px.png" alt=""/>
<img src="Images/separator50px.png" alt=""/>
<center><img src="Images/LOGO.png" alt=""/></center>
<img src="Images/separator50px.png" alt=""/>
<center><img src="Images/fraseinicial.png" alt=""/></center>
<img src="Images/separator50px.png" alt=""/>
<img src="Images/separator50px.png" alt=""/>
</body>
</html>
Hope somebody can help. Thanks in advance!
I can't see what your SQL connection looks like, but I did see that you forgot to end the String for your $sql variable. Try this.
Also, next time, clean up your code. There were spelling errors, missing semicolons, and all kinds of stuff.
<?php
$servername = "localhost";
$email="root";
$password="";
$dbname="testnew";
//create connection
$conn = new mysqli($servername, $email, $password, $dbname);
//check the connection
if($conn->connect_error){
die("connection failed(".$conn->connect_error.")");
}
if(isset($_POST['email'])){
$email = $_POST['email'];
$pass = $_POST['pass'];
$sql = "SELECT * FROM loginnnew WHERE email='".$email."' AND password='".$pass."' LIMIT 1";
$result = $conn->query(sql);
if($result->num_rows>0){
echo 'Has iniciado sesión correctamente';
exit();
}else{
echo 'Contraseña o e-mail incorrectos.';
exit();
}
}
}
?>
<!DOCTYPE html>
<html >
<head>
<title>Responsive Login/Signup Modal Window</title>
<script src='https://s.codepen.io/assets/libs/modernizr.js' type="text/javascript"></script>
<link href='https://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/148866/reset.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel="stylesheet" href="file:///C|/Users/PC 1/Desktop/ADOBE SOFTWARES/responsive-login-signup-modal-window/css/style.css">
<style type="text/css">
body,td,th {
color: #FFFFFF;
}
body {
background-color: #9E1B1D;
}
</style>
</head>
<body>
<body>
<header role="banner">
<div id="cd-logo"><img src="Images/HEADERIC.png" alt="Logo"></div>
<nav class="main-nav">
<ul>
<!-- inser more links here -->
<li><a class="cd-signin" href="#0">Inicia Sesión</a></li>
<li><a class="cd-signup" href="file:///C|/Users/PC 1/Desktop/ADOBE SOFTWARES/responsive-login-signup-modal-window/registro.html">Registrarse</a></li>
</ul>
</nav>
</header>
<div class="cd-user-modal"> <!-- this is the entire modal form, including the background -->
<div class="cd-user-modal-container"> <!-- this is the container wrapper -->
<ul class="cd-switcher">
<li>Sign in</li>
</ul>
<div id="cd-login"> <!-- log in form -->
<form method="post" action="/paginainicio.php" class="cd-form">
<p class="fieldset">
<label class="image-replace cd-email" for="signin-email">E-mail</label>
<input name="email" class="full-width has-padding has-border" id="signin-email" type="email" placeholder="E-mail">
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<label class="image-replace cd-password" for="signin-password">Contraseña</label>
<input name="pass" class="full-width has-padding has-border" id="signin-password" type="text" placeholder="Contraseña">
Hide
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<input type="checkbox" id="remember-me" checked>
<label for="remember-me">Recordarme</label>
</p>
<p class="fieldset">
<input class="full-width" type="submit" value="Inicia Sesión">
</p>
</form>
<p class="cd-form-bottom-message">¿Has olvidado tu contraseña?</p>
<!-- Close -->
</div> <!-- cd-login -->
<div id="cd-reset-password"> <!-- reset password form -->
<p class="cd-form-message">¿Has olvidado tu contraseña? Ingresa tu e-mail y te enviaremos un link para recuperarla.</p>
<form class="cd-form">
<p class="fieldset">
<label class="image-replace cd-email" for="reset-email">E-mail</label>
<input class="full-width has-padding has-border" id="reset-email" type="email" placeholder="E-mail">
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<input class="full-width has-padding" type="submit" value="Reset password">
</p>
</form>
<p class="cd-form-bottom-message">Volver al Login</p>
</div> <!-- cd-reset-password -->
Cerrar
</div> <!-- cd-user-modal-container -->
</div> <!-- cd-user-modal -->
</body>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="file:///C|/Users/PC 1/Desktop/ADOBE SOFTWARES/responsive-login-signup-modal-window/js/index.js"></script>
<img src="Images/separator50px.png" alt=""/>
<img src="Images/separator50px.png" alt=""/>
<center><img src="Images/LOGO.png" alt=""/></center>
<img src="Images/separator50px.png" alt=""/>
<center><img src="Images/fraseinicial.png" alt=""/></center>
<img src="Images/separator50px.png" alt=""/>
<img src="Images/separator50px.png" alt=""/>
</body>
</html>
Related
I do this long years ago, but now, I don't remember and I can't put this working...
So, I have a form with action to another file.php, to send an email, and I want to put a sweet alert to tell people, okay your message has been sent...
Check the code in CONTACT.PHP
<link href="sweet/style.css" type="text/css" rel="stylesheet">
<link href="sweet/sweetalert.css" type="text/css" rel="stylesheet">
<script src="sweet/jquery-3.4.1.min.js" type="text/javascript"></script>
<script src="sweet/sweetalert.min.js" type="text/javascript"></script>
<script type='text/javascript'>
$( document ).ready(function() {
// Show image
$("#but3").click(function(){
var message = $("#message").val();
var title = $("#title").val();
if(message == "Welcome"){
message = "Welcome";
}
if(title == "Welcome"){
title = "Welcome";
}
swal({
title: title,
text: message,
imageUrl: "logo.png"
});
});
// Timer
$("#but4").click(function(){
var message = $("#message").val();
var title = $("#title").val();
if(message == ""){
message = "Your message";
}
if(title == ""){
title = "Your message";
}
message += "(close after 2 seconds)";
swal({
title: title,
text: message,
timer: 2000,
showConfirmButton: false
});
});
});
</script>
<!-- main-container -->
<div class="container main-container">
<div class="col-md-6">
<form action="envia.php" name="envia" id="envia" method="post">
<div class="row">
<div class="col-md-6">
<div class="input-contact">
<input type="text" name="nome" id="nome" required>
<span>Nome</span>
</div>
</div>
<div class="col-md-6">
<div class="input-contact">
<input type="text" id="email" name="email" required>
<span>Email</span>
</div>
</div>
<div class="col-md-12">
<div class="input-contact">
<input type="text" name="assunto" id="assunto" required>
<span>Assunto</span>
</div>
</div>
<div class="col-md-12">
<div class="textarea-contact">
<textarea name="menssagem" id="mensagem" required></textarea>
<span>Mensagem</span>
</div>
</div>
<div class="col-md-12">
<input type="submit" name="enviar" value="enviar" class="btn btn-box">
</div>
</div>
</form>
<table>
<tr><td> THIS SMALL FORM ITS JUST FOR SHOW SWEET ALERT </TD></TR>
<tr>
<td>Title</td>
<td><input type='text' value='Title text' id='title'></td>
</tr>
<tr>
<td>Message</td>
<td><input type='text' value='Your message' id='message'></td>
</tr>
<tr>
<td colspan='2'>
<input type='button' value='Alert with image' id='but4'>
</td>
</tr>
</table>
</div>
--
<!-- main-container -->
<div class="container main-container">
<div class="col-md-6">
<form action="envia.php" name="envia" id="envia" method="post">
<div class="row">
<div class="col-md-6">
<div class="input-contact">
<input type="text" name="nome" id="nome" required>
<span>Nome</span>
</div>
</div>
<div class="col-md-6">
<div class="input-contact">
<input type="text" id="email" name="email" required>
<span>Email</span>
</div>
</div>
<div class="col-md-12">
<div class="input-contact">
<input type="text" name="assunto" id="assunto" required>
<span>Assunto</span>
</div>
</div>
<div class="col-md-12">
<div class="textarea-contact">
<textarea name="menssagem" id="mensagem" required></textarea>
<span>Mensagem</span>
</div>
</div>
<div class="col-md-12">
<input type="submit" name="enviar" value="enviar" class="btn btn-box">
</div>
</div>
</form>
<table>
<tr><td> THIS SMALL FORM ITS JUST FOR SHOW SWEET ALERT </TD></TR>
<tr>
<td>Title</td>
<td><input type='text' value='Title text' id='title'></td>
</tr>
<tr>
<td>Message</td>
<td><input type='text' value='Your message' id='message'></td>
</tr>
<tr>
<td colspan='2'>
<input type='button' value='Alert with image' id='but4'>
</td>
</tr>
</table>
</div>
THE FILE ENVIA.PHP
$nomeremetente = $_POST['nome'];
$emailremetente = trim($_POST['email']);
$emaildestinatario = 'info#mydomain.pt';// Digite seu e-mail aqui, lembrando que o e-mail deve estar em seu servidor web
$assunto = $_POST['assunto'];
$mensagem = $_POST['mensagem'];
/* Montando a mensagem a ser enviada no corpo do e-mail. */
$mensagemHTML = '
<strong>Formulário de Contato</strong>
<p><b>Nome:</b> '.$nomeremetente.' <p>
<b>E-Mail:</b> '.$emailremetente.' <p>
<b>Assunto:</b> '.$assunto.' <p>
<b>Mensagem:</b> '.$mensagem.'</p>
<hr>';
// O remetente deve ser um e-mail do seu domínio conforme determina a RFC 822.
// O return-path deve ser ser o mesmo e-mail do remetente.
$headers = "MIME-Version: 1.1\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$headers .= "From: $emailremetente\r\n";
// remetente
$headers .= "Return-Path: $emaildestinatario \r\n";
// return-path
$envio = mail($emaildestinatario, $assunto, $mensagemHTML, $headers);
if($envio)
echo "<script>location.href='contact.php'</script>";// Página que será redirecionada
I have tried so many ways, and I just reset everything and now I don't know what to do.........
Edited to the full code fix
contact.php
<!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" />
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Box personal portfolio Template</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="ionicons/css/ionicons.min.css" rel="stylesheet" />
<link rel="icon" href="img/fav.png" type="image/x-icon" />
<!-- main css -->
<link href="css/style.css" rel="stylesheet" />
<!-- Sweetalert -->
<!-- <link href="sweet/style.css" type="text/css" rel="stylesheet" /> -->
<link href="sweet/sweetalert.css" type="text/css" rel="stylesheet" />
<script src="sweet/sweetalert.min.js" type="text/javascript"></script>
<!-- modernizr -->
<script src="js/modernizr.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[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>
<!-- Preloader -->
<div id="preloader">
<div class="pre-container">
<div class="spinner">
<div class="double-bounce1"></div>
<div class="double-bounce2"></div>
</div>
</div>
</div>
<!-- end Preloader -->
<div class="container-fluid">
<!-- box-header -->
<header class="box-header">
<div class="box-logo">
<a href="index.html"
><img src="img/logo.png" width="80" alt="Logo"
/></a>
</div>
<!-- box-nav -->
<a class="box-primary-nav-trigger" href="#0">
<span class="box-menu-text">Menu</span
><span class="box-menu-icon"></span>
</a>
<!-- box-primary-nav-trigger -->
</header>
<!-- end box-header -->
<!-- nav -->
<nav>
<ul class="box-primary-nav">
<li class="box-label">About me</li>
<li>Intro</li>
<li>About me</li>
<li>services</li>
<li>portfolio</li>
<li>
contact me
<i class="ion-ios-circle-filled color"></i>
</li>
<li class="box-label">Follow me</li>
<li class="box-social">
<i class="ion-social-facebook"></i>
</li>
<li class="box-social">
<i class="ion-social-instagram-outline"></i>
</li>
<li class="box-social">
<i class="ion-social-twitter"></i>
</li>
<li class="box-social">
<i class="ion-social-dribbble"></i>
</li>
</ul>
</nav>
<!-- end nav -->
</div>
<!-- top bar -->
<div class="top-bar">
<h1>contact Me</h1>
<p>Home / Contact Me</p>
</div>
<!-- end top bar -->
<!-- main-container -->
<div class="container main-container">
<div class="col-md-6">
<form name="envia" action="#" id="envia">
<div class="row">
<div class="col-md-6">
<div class="input-contact">
<input type="text" name="nome" id="nome" required />
<span>Nome</span>
</div>
</div>
<div class="col-md-6">
<div class="input-contact">
<input type="text" id="email" name="email" required />
<span>Email</span>
</div>
</div>
<div class="col-md-12">
<div class="input-contact">
<input type="text" name="assunto" id="assunto" required />
<span>Assunto</span>
</div>
</div>
<div class="col-md-12">
<div class="textarea-contact">
<textarea name="menssagem" id="mensagem" required></textarea>
<span>Mensagem</span>
</div>
</div>
<div class="col-md-12">
<input
id="submit"
type="submit"
name="enviar"
value="enviar"
class="btn btn-box"
/>
</div>
</div>
</form>
</div>
<div class="col-md-6">
<h3 class="text-uppercase">Entre em contacto</h3>
<h5>Pedidos orçamento e esclarecimento de dúvidas.</h5>
<div class="h-30"></div>
<p>
<br />Poderá usar este formulário para esclarecimento de dúvidas ou
pedido de orçamento, para pedidos de orçamento deverá indicar o mais
claro possivel o que pretende.
</p>
<div class="contact-info">
<p><i class="ion-android-call"></i>911729199</p>
<p><i class="ion-ios-email"></i>info#obruno.pt</p>
</div>
</div>
</div>
<!-- end main-container -->
<!-- footer -->
<footer>
<div class="container-fluid">
<p class="copyright">© Box Portfolio 2016</p>
</div>
</footer>
<!-- end footer -->
<!-- back to top -->
<i class="ion-android-arrow-up"></i>
<!-- end back to top -->
<!-- jQuery -->
<script src="js/jquery-2.1.1.js"></script>
<!-- plugins -->
<script src="js/bootstrap.min.js"></script>
<script src="js/menu.js"></script>
<script src="js/animated-headline.js"></script>
<script src="js/isotope.pkgd.min.js"></script>
<!-- custom script -->
<script src="js/custom.js"></script>
<script>
// This will prevent the default button action and the page won't refresh
document.querySelector("#submit").addEventListener(
"click",
function (event) {
process();
},
false
);
// This will make a post request to your php file
function process() {
// Getting the inputs
var message = document.getElementById("mensagem").value;
var email = document.getElementById("email").value;
var subject = document.getElementById("assunto").value;
var name = document.getElementById("nome").value;
// Some data validation to see if the user have filled the required fields
if (message && email && subject && name) {
event.preventDefault();
// Setting the AJAX request handler
var xmlhttp = new XMLHttpRequest();
// Waiting for a response
xmlhttp.onreadystatechange = function () {
// If the response is 200 aka "OK"
if (this.readyState == 4 && this.status == 200) {
// Show your success alert here
swal({
title: "Message Sent!",
text: "Thank you for contacting us.",
timer: 2000,
showConfirmButton: false,
});
document.getElementById("envia").reset();
return;
}
};
// Setting the request type and data to be sent
xmlhttp.open("POST", "envia.php", true);
xmlhttp.setRequestHeader(
"Content-type",
"application/x-www-form-urlencoded"
);
xmlhttp.send(
"nome=" +
name +
"&email=" +
email +
"&assunto=" +
subject +
"&mensagem=" +
message
);
} else {
// Alert the user to fill the required fields
console.log("please fill all required fields");
return;
}
}
</script>
</body>
</html>
envia.php
<?php
$nomeremetente = $_POST['nome'];
$emailremetente = $_POST['email'];
$emaildestinatario = 'info#mydomain.pt';
$assunto = $_POST['assunto'];
$mensagem = $_POST['mensagem'];
$content = '<strong>Formulário de Contato</strong><p><b>Nome:</b> ' . $nomeremetente . ' <p><b>E-Mail:</b> ' . $emailremetente . ' <p><b>Assunto:</b> ' . $assunto . ' <p><b>Mensagem:</b> ' . $mensagem . '</p><hr>';
$headers = array(
'From' => $emailremetente,
'Reply-To' => $emaildestinatario,
'MIME-Version' => '1.1',
'Content-type' => 'text/html;charset=UTF-8',
'X-Mailer' => 'PHP/' . phpversion()
);
if (isset($nomeremetente) && isset($emailremetente) && isset($emaildestinatario) && isset($assunto) && isset($mensagem) && isset($content)) {
mail($emaildestinatario, $assunto, $content, $headers);
echo "SUCCESS";
http_response_code(200);
} else {
echo "FAILED";
http_response_code(404);
}
Take note that I have added already the sweet alert you can go ahead and customize the message to display after email success
NB: Don't forget to change the email that you're going to receive email on to one on your domain or the emails would end up not getting sent or in your spam
I am try to fill the form and I got this error. Please someone tell me why?
I have attached all the code and the images: what I want is when I fill this form, it gets automatically saved in database. And please, if you can provide me how to upload images from the same form to the same database at phpmyadmin.
Error Message:
This is the model :
class Clinic_Model extends CI_Model
{
function insert_into_db()
{
$pfn = $_POST['pfn'];
$pe = $_POST['pe'];
$pmn = $_POST['pmn'];
$pa = $_POST['pa'];
$pw = $_POST['pw'];
$ph = $_POST['ph'];
$pgt = $_POST['pgt'];
$pbp = $_POST['pbp'];
$pec = $_POST['pec'];
$this->db->query("INSERT INTO add_clinic
VALUES($pfn','$pe','$pmn','$pa','$pw','$ph','$pgt','$pbp','$pec')");
}
}
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
This is the controller
class Easyclinic extends CI_Controller {
//----------Constructor----------
public function __construct()
{
parent::__construct();
$this->load->helper('url');
//load Model
$this->load->model('clinic_model');
}
//----------BaseFunctions----------
public function index()
{
$this->load->view('add_patient');
}
public function mydata()
{
$this->load->view('mydata');
}
public function addpatient()
{
$this->load->view('add_patient');
}
//---------Advinced Functions---------
public function insert_into_db()
{
$this->load->model('clinic_model');
$this->clinic_model->insert_into_db();
$this->load->view('success');//loading success view
}
}
this is the view
<!DOCTYPE html>
<html lang="en">
<head>
<title>Add Patient</title>
<!-- for-mobile-apps -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="easyclinic" />
<script type="application/x-javascript"> addEventListener("load",
function() { setTimeout(hideURLbar, 0); }, false);
function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- //for-mobile-apps -->
<!-- //custom-theme -->
<link href="assests/css/style.css" rel="stylesheet" type="text/css"
media="all" />
<!-- js -->
<script type="text/javascript" src="assests/js/jquery-2.1.4.min.js">
</script>
<!-- //js -->
<link href='//fonts.googleapis.com/css?
family=Roboto:400,100,300,500,700,900' rel='stylesheet' type='text/css'>
</head>
<body>
<!-- banner -->
<div class="center-container">
<div class="main">
<h1 class="w3layouts_head">Add Patient Info</h1>
<h1 class="w3layouts_head">Welcome Dr.Atef</h1>
<div class="w3layouts_main_grid">
<form action="<?php echo base_url();?
>easyclinic/insert_into_db" method="post" class="w3_form_post">
<!-- day/time -->
<div class="agileits_w3layouts_main_grid w3ls_main_grid">
<span class="agileinfo_grid">
<label>Examination Date</label>
<div class="agileits_w3layouts_main_gridl">
<input class="date hasDatepicker" id="datepicker" name="Text"
type="text" value="dd/mm/yyyy" onfocus="this.value = '';" onblur="if
(this.value == '') {this.value = '';}" required="">
</div>
<div class="agileits_w3layouts_main_gridr">
<input type="time" name="Time" placeholder=" " required="">
</div>
<div class="clear"> </div>
</span>
</div>
<!-- name -->
<div class="w3_agileits_main_grid w3l_main_grid">
<span class="agileits_grid">
<label>Patient Full Name </label>
<input type="text" name="pfn" placeholder=" 4 part name"
required="">
</span>
</div>
<!-- email -->
<div class="w3_agileits_main_grid w3l_main_grid">
<span class="agileits_grid">
<label>Patient Email </label>
<input type="text" name="pe" placeholder=" Email" required="">
</span>
</div>
<!-- Phone number -->
<div class="w3_agileits_main_grid w3l_main_grid">
<span class="agileits_grid">
<label>Patient Number </label>
<input type="text" name="pmn" placeholder="Phone Number"
required="">
</span>
</div>
<!-- choose your Gender-->
<div class="content-w3ls">
<div class="form-w3ls">
<div class="content-wthree2">
<div class="grid-w3layouts1">
<div class="w3-agile1">
<label>Gender</label>
<ul>
<li>
<input type="radio" id="a-option" name="pg">
<label for="a-option">Male </label>
<div class="check"></div>
</li>
<li>
<input type="radio" id="b-option" name="pg2">
<label for="b-option">female</label>
<div class="check"><div class="inside"></div></div>
</li>
</ul>
</div>
</div>
<!-- age -->
<div class="w3_agileits_main_grid w3l_main_grid">
<span class="agileits_grid">
<label>Patient Age </label>
<input type="text" name="pa" placeholder="Patient Age"
required="">
</span>
</div>
<div class="clear"></div>
</div>
</div>
<!-- weight -->
<div class="w3_agileits_main_grid w3l_main_grid">
<span class="agileits_grid">
<label>Weight</label>
<input type="text" name="pw" placeholder="Weight in
KiloGrams" required="">
</span>
</div>
<!-- Height -->
<div class="w3_agileits_main_grid w3l_main_grid">
<span class="agileits_grid">
<label>Height</label>
<input type="text" name="ph" placeholder="Height in
CentiMeters" required="">
</span>
</div>
<!-- Glucose -->
<div class="w3_agileits_main_grid w3l_main_grid">
<span class="agileits_grid">
<label>Glucose Test</label>
<input type="text" name="pgt" placeholder="~100~140"
required="">
</span>
</div>
<!-- Heart pressure -->
<div class="w3_agileits_main_grid w3l_main_grid">
<span class="agileits_grid">
<label>Blood Pressure</label>
<input type="text" name="pbp" placeholder="~120~180"
required="">
</span>
</div>
<!-- Uoload File -->
<div>
<span class="agileits_grid">
<label>Upload sonar image</label>
<form method="post" enctype="multipart/form-data" action="upload">
</br>
Choose a file:
<input type="image" name="usi" />
<input type="submit" />
</form>
</div>
<!-- Uoload File -->
<div>
<span class="agileits_grid">
<label>Upload cbc image</label>
<form method="post" enctype="multipart/form-data" action="upload">
Choose a file:
<input type="image" name="uci" />
<input type="submit" />
</form>
</div>
<!-- day/time -->
<div class="agileits_w3layouts_main_grid w3ls_main_grid">
<span class="agileinfo_grid">
<label>Expectation of Childbirth</label>
<div class="agileits_w3layouts_main_gridl">
<input class="date hasDatepicker" id="datepicker" name="Text"
type="text" value="mm/dd/yyyy" onfocus="this.value = '';"
onblur="if (this.value == '') {this.value = '';}" required="">
</div>
<div class="agileits_w3layouts_main_gridr">
<input type="time" name="pec" placeholder=" " required="">
</div>
<div class="clear"> </div>
</span>
</div>
<!-- submit button -->
<div class="w3_main_grid">
<div class="w3_main_grid_right">
<input type="submit" name="save" value="Submit">
</div>
</div>
</form>
</div>
<!-- Calendar -->
<link rel="stylesheet" href="assests/css/jquery-ui.css" />
<script src="js/jquery-ui.js"></script>
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
<!-- //Calendar -->
<div class="w3layouts_copy_right">
<div class="container">
<p>© 2018 Patient Registration Form. All rights reserved |
HassanAli</p>
</div>
</div>
</div>
</div>
<!-- //footer -->
</body>
</html>
and this is the image of phpmyadmion:
see phpmyadmin iamge
There is a minor error of a missing ' in your columns of the INSERT statement (VALUES($pfn'), but also there is also a problem of matching the columns up. I would normally list the columns that I am inserting into as well, something like...
$this->db->query("INSERT INTO add_clinic (`Patient Full Name`, *** )
VALUES('$pfn','$pe','$pmn','$pa','$pw','$ph','$pgt','$pbp','$pec')");
(Where *** is just a list of the columns to be inserted into).
There are two recommendations I would like to make - firstly is to change the names of your columns. Having spaces in column names can cause all sorts of problems and is not normally recommended.
Secondly is to look into using prepared statements and bind variables, this will provide all sorts of benefits later, including security and not having problems with certain characters in the text.
i have a user login page and php script to check the login credentials with data stored in a database. Everything works fine, i just tried adding a msg box styled with CSS containing the text "wrong email" if login details didn't match the data in the database and it will automatically return to login page.
Unfortunately, the msg is not being echoed and it is returning to login page..
my php code goes like this..
<style>
.alert {
padding: 20px;
background-color: #f44336;
color: white;
}
.closebtn {
margin-left: 15px;
color: white;
font-weight: bold;
float: right;
font-size: 22px;
line-height: 20px;
cursor: pointer;
transition: 0.3s;
}
.closebtn:hover {
color: black;
}
</style
<?php
//15 2 2015
session_start();
$Cser = mysqli_connect("localhost","root","*****","database") or die("Server connection failed : ".mysqli_error($Cser));
$email = $_REQUEST["email"];
$password = $_REQUEST["password"];
$s = "select * from fuser where email='".$email."' and password = '".$password."'";
$result = mysqli_query($Cser,$s);
$count = mysqli_num_rows($result);
if($count>0)
{
$_SESSION["username"] = $username;
$_SESSION["login"]="1";
header("location:../home.php");
}
else
{
echo '<div class="alert">';
echo '<span class="closebtn" onclick="this.parentElement.style.display="none";">×</span>';
echo '<strong>Danger!</strong> wrong email id';
echo '</div>';
header("location:sign.php");
}
?>
My sign.php code as follows::
<!DOCTYPE html>
<html >
<?php
$servername = "localhost";
$username = "root";
$password = "*******";
$dbname = "database";
$conn = new mysqli($servername, $username, $password, $dbname);
?>
<head>
<meta charset="UTF-8">
<title>title</title>
<script src="http://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script>
<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/148866/reset.css">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header role="banner">
<nav class="main-nav">
<ul>
<!-- inser more links here -->
<li><a class="cd-signin" href="#0">Sign In</a></li>
<li><a class="cd-signup" href="#0">Sign Up</a></li>
</ul>
</nav>
</header>
<label class="thought">
<p> find your passion, <br><br> make it as your profession </p>
</label>
<div class="cd-user-modal"> <!-- this is the entire modal form, including the background -->
<div class="cd-user-modal-container"> <!-- this is the container wrapper -->
<ul class="cd-switcher">
<li>Sign In</li>
<li>Sign Up</li>
</ul>
<div id="cd-login"> <!-- log in form -->
<form class="cd-form" action="logincheck.php" method="post">
<p class="fieldset">
<label class="image-replace cd-email" for="signin-email">E-mail</label>
<input class="full-width has-padding has-border" name="email" id="signin-email" type="text" placeholder="E-mail" required autocomplete="off">
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<label class="image-replace cd-password" for="signin-password">Password</label>
<input class="full-width has-padding has-border" name="password" id="signin-password" type="text" placeholder="Password" required autocomplete="off">
Hide
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<input type="checkbox" id="remember-me">
<label for="remember-me">Remember me</label>
</p>
<button class="button button-block" type="submit" > Sign In </button>
</form>
<p class="cd-form-bottom-message">Forgot your password?</p>
<!-- Close -->
</div> <!-- cd-login -->
<div id="cd-signup"> <!-- sign up form -->
<form class="cd-form" action="register.php" method="post" >
<p class="fieldset">
<label class="image-replace cd-username" for="signup-username">Profile Name</label>
<input class="full-width has-padding has-border" name="name" id="signup-username" type="text" placeholder="Type your Name" required autocomplete="off">
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<label class="image-replace cd-email" for="signup-email">E-mail</label>
<input class="full-width has-padding has-border" name="email" id="email" type="text" placeholder="example#mail.com"required autocomplete="off" onkeyup="checkemail();">
<span class="cd-error-message" id="result"></span>
</p>
<label id="title" class="dropdown"><font face="verdana"> Select any three streams that your skills suits the best: </font><br><br>
<select id="job" name="category1" required>
<option value="Engineering"><font face="verdana">Engineering</font></option>
<option value="Medical"><font face="verdana">Medical</font></option>
<option value="Programming"><font face="verdana">Programming</font></option>
<option value="Business"><font face="verdana">Business</font></option>
<option value="Admin"><font face="verdana">Admin</font></option>
<option value="Other"><font face="verdana">Other</font></option>
</select>
<select id="job" name="category2" required>
<option value="Engineering"><font face="verdana">Engineering</font></option>
<option value="Medical"><font face="verdana">Medical</font></option>
<option value="Programming"><font face="verdana">Programming</font></option>
<option value="Business"><font face="verdana">Business</font></option>
<option value="Admin"><font face="verdana">Admin</font></option>
<option value="Other"><font face="verdana">Other</font></option>
</select>
<select id="job" name="category3" required>
<option value="Engineering"><font face="verdana">Engineering</font></option>
<option value="Medical"><font face="verdana">Medical</font></option>
<option value="Programming"><font face="verdana">Programming</font></option>
<option value="Business"><font face="verdana">Business</font></option>
<option value="Admin"><font face="verdana">Admin</font></option>
<option value="Other"><font face="verdana">Other</font></option>
</select>
</label>
<p class="fieldset">
<label class="image-replace cd-password" for="signup-password">Password</label>
<input class="full-width has-padding has-border" name="password" id="signup-password" type="text" placeholder="Password" required autocomplete="off">
Hide
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<input type="checkbox" id="accept-terms" required>
<label for="accept-terms">I agree to the Terms</label>
</p>
<button class="button button-block" type="submit" > Create an Account </button>
</form>
<!-- Close -->
</div> <!-- cd-signup -->
<div id="cd-reset-password"> <!-- reset password form -->
<p class="cd-form-message">Lost your password? Please enter your email address. You will receive a link to create a new password.</p>
<form class="cd-form">
<p class="fieldset">
<label class="image-replace cd-email" for="reset-email">E-mail</label>
<input class="full-width has-padding has-border" id="reset-email" type="email" placeholder="E-mail" autocomplete="off" required>
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<input class="full-width has-padding" type="submit" value="Reset password">
</p>
</form>
<p class="cd-form-bottom-message">Back to log-in</p>
</div> <!-- cd-reset-password -->
Close
</div> <!-- cd-user-modal-container -->
</div> <!-- cd-user-modal -->
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>
Any help is greatly appreciated..
Remove the redirection code from the else condition, PHP will redirect without echoing/displaying anything on-screen.
... else
{
echo '<div class="alert">';
echo '<span class="closebtn" onclick="this.parentElement.style.display="none";">×</span>';
echo '<strong>Danger!</strong> wrong email id';
echo '</div>';
}
To keep your code you need to remove the header() redirect and either put a link on the bottom of the error message or use a META tag for redirect.
The code below will redirect after 10 seconds, so the user can read your error message:
... else
{
echo '<div class="alert">';
echo '<span class="closebtn" onclick="this.parentElement.style.display="none";">×</span>';
echo '<strong>Danger!</strong> wrong email id';
echo '</div>';
echo '<meta http-equiv="refresh" content="10;url=sign.php">';
}
or, with a link
... else
{
echo '<div class="alert">';
echo '<span class="closebtn" onclick="this.parentElement.style.display="none";">×</span>';
echo '<strong>Danger!</strong> wrong email id';
echo '</div>';
echo 'go back to login page';
}
I'm having another problem with this code. I have tried different ways but no success.
if (isset($_POST['submitted'])) {
if($fgmembersite->ChangePassword()){
echo '<div id="ajaxDivOk">Password alterada com sucesso</div>';
sleep(2);
$fgmembersite->RedirectToURL("index.php");
}
echo '<div id="ajaxDivErro">A mudança de password não foi efetuadada....tente mais tarde</div>';
sleep(2);
}
In the debugger, I get the echo...but not in the main page.
This is my main page:
<?PHP
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', '1');
require_once("./include/membersite_config.php");
if (!$fgmembersite->CheckLogin()) {
$fgmembersite->RedirectToURL("index.php");
exit;
}
if (isset($_POST['submitted'])) {
if($fgmembersite->ChangePassword()){
echo '<div id="ajaxDivOk">Password alterada com sucesso</div>';
sleep(2);
$fgmembersite->RedirectToURL("index.php");
}
echo '<div id="ajaxDivErro">A mudança de password não foi efetuadada....tente mais tarde</div>';
sleep(2);
}
$email = $fgmembersite->UserEmail();
?>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>EBSPMA Atividades</title>
<link href="css/styles.css" rel="stylesheet">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/modernizr.js?cb=2.2.3.2085"></script>
<script type="text/javascript">
</script>
</head>
<body>
<header role="banner" class="main-header">
<!-- MAIN HEADER -->
<div class="main-header-body">
<div class="container-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-xs-3">
<h2>EBSPMA PAAD</h2>
</div>
<div class="col-xs-4 col-xs-offset-1 main-header-title">
<p class="sizeToggle" >Mudar Password</p>
</div>
</div>
</div>
</div>
</div>
</header><section class="content">
<div class="grid">
<div class="box">
<form name="changepwd" id="loginForm" action='<?php echo $fgmembersite->GetSelfScript(); ?>' method="POST">
<input type="hidden" name='submitted' id='submitted'/>
<input type="hidden" name="path" value="painelAdquirente.action"/>
<div>
<p><b><font color="red">A sua password deve ser alterada!</font></b></p></div>
<div class="icon-input">
<label for="password"></label>
<div class="input password">
<i class="fa fa-lock"></i>
<input type="password" name="oldpwd" id="oldpwd" placeholder="Senha antiga">
</div>
</div>
<br>
<div class="icon-input">
<label for="password"></label>
<div class="input password">
<i class="fa fa-lock"></i>
<input type="password" name="newpwd" id="newpwd" placeholder="Senha nova">
</div>
<input type="hidden" name="email" id="email" value="<?php echo $email; ?>">
</div>
<br>
<input type="submit" id="sbmtLogin" class="sa-btn1" value="Mudar">
</form>
</div>
<div class="form-group">
<div id="ajaxDivOk" style="display:none" class="alert alert-success">Aqui</div>
</div>
<div class="form-group">
<div id="ajaxDivErro" style="display:none" class="alert alert-danger"></div>
</div>
</div>
</section>
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/jquery.validate.min.js"></script>
<script src="js/plugins.js?cb=2.2.3.2085"></script>
</body>
</html>
The function is working since I receive in my debugger the sentence
<div class="alert alert-success">Verifique o seu mail....Obrigado</div>
So what's wrong?
UPDATE:
I'm still having a problem: now I have this error:
Uncaught ReferenceError: checkMudaPass is not defined
The function is:
<script type="text/javascript">
function checkMudaPass(){
var res = "<?php echo $result; ?>";
console.log(res);
if(res === "1"){
document.getElementById('ajaxDivOk').style.display = "block";
document.getElementById('ajaxDivOk').innerHTML = "A mudança de password foi efetuada....Verifique o seu email";
}else{
document.getElementById('ajaxDivErro').style.display = "block";
document.getElementById('ajaxDivErro').innerHTML = "A mudança de password não foi efetuada";
}
setTimeout(function(){
window.location='index.php';
}, 5000);
};
</script>
<input type="submit" id="submitted" name="submitted" class="sa-btn1" value="Mudar" onclick="checkMudaPass()">
I'm doing a registration page. It requires the name, password, email, gender, nationality, date of birth and other things.
I did the registration and it was good. But I need to add the validation and this is what I could do so far:
<?php include("config.php"); ?>
<!DOCTYPE html>
<html lang="en">
<!-- CSS -->
<link rel="stylesheet" href="css/styles.css" type="text/css"/>
<link type="text/css" href="css/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
<!-- JavaScript -->
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
<script src="js/validation.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$('#datepicker').datepicker({
dateFormat:'dd/mm/yy',
changeMonth: true,
changeYear: true,
yearRange: '-90:+0',
maxDate: '+0'
});
});
</script>
</head>
<head>
<title></title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/reset.css" type="text/css" media="all">
<link rel="stylesheet" href="css/layout.css" type="text/css" media="all">
<link rel="stylesheet" href="css/style.css" type="text/css" media="all">
<script type="text/javascript" src="js/jquery-1.4.2.js" ></script>
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/cufon-replace.js"></script>
<script type="text/javascript" src="js/Myriad_Pro_italic_600.font.js"></script>
<script type="text/javascript" src="js/Myriad_Pro_italic_400.font.js"></script>
<script type="text/javascript" src="js/Myriad_Pro_400.font.js"></script>
<!--[if lt IE 9]>
<script type="text/javascript" src="http://info.template-help.com/files/ie6_warning/ie6_script_other.js"></script>
<script type="text/javascript" src="js/html5.js"></script>
<![endif]-->
<?php $error_messages = array(
'T1' => 'Please enter a Name to proceed.',
'T2' => 'Please enter a valid Email Address to continue.',
'T3' => 'Please enter your Message to continue.'
);
?>
</head>
<body id="page2">
<div class="body1">
<div class="main">
<!-- header -->
<header>
<div class="wrapper">
<h1>Air Lines<span id="slogan">International Travel</span></h1>
<div class="right">
<nav>
<ul id="top_nav">
<li><img src="images/img1.gif" alt=""></li>
<li><img src="images/img2.gif" alt=""></li>
<li class="bg_none"><img src="images/img3.gif" alt=""></li>
</ul>
</nav>
<nav>
<ul id="menu">
<li>Home</li>
<li id="menu_active" >Login/sign up</li>
<li>Vision and mission</li>
<li>Contacts</li>
</ul>
</nav>
</div>
</div>
</header>
</div>
</div>
<div class="main">
<div id="banner"></div>
</div>
<!-- header -->
<div class="main">
<!-- content -->
<section id="content">
<article class="col1">
<div class="pad_1">
<h2>Login</h2>
<form id="form_1" action="login.php" method="post">
<div class="wrapper">
User Name:
<div class="bg"><input type="text" name="LogIn_Name" class="input input1" value="Enter your name" onblur="if(this.value=='') this.value='Enter your name'" onfocus="if(this.value =='Enter your name' ) this.value=''"></div>
</div>
<div class="wrapper">
Password:
<div class="bg"><input type="password" name="LogIn_Pass" class="input input1" value="Enter your password" onblur="if(this.value=='') this.value='Enter your password'" onfocus="if(this.value =='Enter your password' ) this.value=''"></div>
</div>
<div class="wrapper">
<h2 id="coq"> Forget Password</h2>
<input type="submit" class="button2" value="GO">
</div>
</form>
<h2> </h2>
</div>
</article>
<article class="col2 pad_left1">
<h2>Registration</h2>
<div class="wrapper">
<figure class="left marg_right1"></figure>
<p>
<form id="form_1" action="" method="post">
<div class="wrapperr" >
<?php
$username = $_POST["T1"];
$password = $_POST["T2"];
$repassword = $_POST["T3"];
$email = $_POST["T4"];
$gender = $_POST["T5"];
$Cou = $_POST["T6"];
$DO= $_POST["T7"];
$passport= $_POST["T8"];
$phone= $_POST["T9"];
{
if((strlen($username)<3)){
echo "The username is too short"."</br>";
if((strlen($gender)<3)){
echo "Gender"."</br>";
}
if((strlen($Cou)<2)){
echo "The CO too short"."</br>";
}
if((strlen($phone)<5)){
echo "The phone is too short"."</br>";
}
if((strlen($password)<5)){
echo "The password is too short"."</br>";
}
}
else{
if($password == $repassword){
$chec = mysql_query("SELECT * FROM register WHERE name='$username'");
if(strlen($chec['name'])>0){
echo "The username '$username' already exists";
}
else{
$check_variable=stripos($email,"#");
if($check_variable){
$password=md5($password);
mysql_query("INSERT INTO register (name,password,email,gender,country,DOB,phone,passport) VALUES ('$username','$password','$email','$gender','$Cou','$DO','$phone','$passport')");
echo "Registration Successful .. Click <a href='index.php'> here </a> to home";
}
else{
echo "email is invalid";
}
}
}
else{
echo "The password in both field doesn't match.";
}
}
}
?>
</div> <div class="wrapper">
Name:
<div class="bg"><input type="text" name="T1" class="input input1" value="Enter your name" onblur="if(this.value=='') this.value='Enter your name'" onfocus="if(this.value =='Enter your name' ) this.value=''"></div>
</div>
<div class="wrapper">
Password:
<div class="bg"><input type="password" name="T2" class="input input1" value="Enter the password" onblur="if(this.value=='') this.value='Enter the password'" onfocus="if(this.value =='Enter the password' ) this.value=''"></div>
</div>
<div class="wrapper">
Confirm password:
<div class="bg"><input type="password" name="T3" class="input input1" value="Confirm the password" onblur="if(this.value=='') this.value='Confirm the password'" onfocus="if(this.value =='Confirm the password' ) this.value=''"></div>
</div>
<div class="wrapper">
e-mail:
<div class="bg"><input type="text" name = "T4" class="input input1" value="Enter your e-mail" onblur="if(this.value=='') this.value='Enter your e-mail'" onfocus="if(this.value =='Enter your e-mail' ) this.value=''"></div>
</div>
<div class="wrapper">
Gender:
<div class="bg">
<td>
<input type="radio" name="T5" value="Male">
Male
</td><td>
<input type="radio" name="T5" value="Female">
Female</td>
</div>
</div>
<div class="wrapper">
NATIONALITY:
<div class="bg"><input type="text" name="T6" class="input input1" value="Enter your country" onblur="if(this.value=='') this.value='Enter your country'" onfocus="if(this.value =='Enter your country' ) this.value=''"></div>
</div>
<div class="wrapper">
<div class="wrapper">
Passport number:
<div class="bg"><input type="text" name="T8" class="input input1" value="Enter your passport number" onblur="if(this.value=='') this.value='Enter your passport number'" onfocus="if(this.value =='Enter your passport number' ) this.value=''"></div>
</div>
<div class="wrapper">
Date of birth:
<div class="wrapper">
<div class="bg left"><input type="text" name="T7" class="input input2" value="mm/dd/yyyy " onblur="if(this.value=='') this.value='mm/dd/yyyy '" onfocus="if(this.value =='mm/dd/yyyy ' ) this.value=''" id="datepicker" >
<br/><span id="bdayInfo"></span>
</div>
<div class="bg right"></div>
</div>
</div>
Phone number:
<div class="wrapper">
<div class="bg left"><input type="text" name="T9" class="input input2" value="" onblur="if(this.value=='') this.value=''" onfocus="if(this.value =='' ) this.value=''"></div>
<div class="bg right"></div>
</div>
</div>
<div class="wrapper">
<p> </p>
<input type="submit" class="button2" name="Go" value="GO">
</div>
</form>
</p>
</div>
<p> </p>
<h2> </h2>
</article>
</section>
<!-- / content -->
</div>
<div class="body2">
<div class="main">
<!--footer -->
<footer>
Website template designed by www.templatemonster.com<br>
3D Models provided by www.templates.com
</footer>
<!-- / footer -->
</div>
</div>
<script type="text/javascript"> Cufon.now(); </script>
</body>
</html>
Always validate server side first i.e. in PHP (this is the point where it is required).
Then add JavaScript validation afterwards. It is not required, but added to improve user expecrience. Any javascript can be circumnavigated (avoided) so if you don't have the PHP backup then you're leaving your self open for trouble.
Note, I'm not saying don't add JS validation, merely that you add PHP first, JS second. Sometimes you find libraries / frameworks that can add both at the same time.
So back to your code: the error appears to be that you're checking for errors after you display the error. So it's going to fail.
Restructure your code as follows:
Create default values for your form
Create blank errors array.
If POSTED, then read in values (over defaults), validate them
If all is good, then process the form and redirect [header('location: '); exit();] to a results / thank-you page.
(Note that at this point you have not outputted any HTML at all, merely updated your default values and error array)
If all is not good (or you never got a post) then now show the HTML. You have default values for the inputs (will alos contain the POSTED values, if applicable) and error messages to display at the right points.
Basically, handle the data first, output last.
Once that is working, then ass jQuery validation (as suggested in comments). It's pretty good.
HTML 5 has a bunch of built in validation tools and you could use jQuery or Javascript to further enhance that. I am not a big fan of validating variables on a new page, especially when we could prevent the page load completely. Definitely look into some sort of Client Side validation instead of posting to the the PHP page.
W3Schools has a decent article on Javascript validation: http://www.w3schools.com/js/js_form_validation.asp
The jQuery link was already given in a comment above.
If Javascript is not your specialty then try something like this. It is prebuilt and has some nice features. Best of all it is free.
http://www.javascript-coder.com/html-form/javascript-form-validation.phtml