insert into mysql using php/html - not work - php

I'm trying to enter data into a mysql database using php / html form but it isn't working and I don't know why. The record is not inserted and the page just refresh
I apologize for some of it being written in Danish
I have 2 files 1 with html and php and 1 with only php
My database: Database image
This is the html form and php:
<div class="row">
<div class="col-sm-12">
<?php
if (isset($_POST['Submit'])) {
// echo "<pre>", print_r($_POST), "</pre>";
$apply_name = mysqli_real_escape_string($db, $_POST ['apply_name']);
$apply_age = mysqli_real_escape_string($db, $_POST ['apply_age']);
$apply_ingame_name = mysqli_real_escape_string($db, $_POST ['apply_ingame_name']);
$apply_email = mysqli_real_escape_string($db, $_POST ['apply_email']);
$apply_steamID = mysqli_real_escape_string($db, $_POST ['apply_steamID']);
$apply_text = mysqli_real_escape_string($db, $_POST ['apply_text']);
$errors = []; // Array
if ($apply_name == "") {
$errors['apply_name'] = "<div class='alert alert-danger'>
<strong>Du har ikke angivet noget navn!</strong>
</div>";
} elseif (strlen($apply_name) < 2) {
$errors['apply_name'] = "<div class='alert alert-info'>
<strong>Dit navn skal minimum være 2 karatere</strong>
</div>";
}
if ($apply_age == "") {
$errors['create_apply_age'] = "<div class='alert alert-danger'>
<strong>Du har ikke angivet din alder!</strong>
</div>";
}
if ($apply_ingame_name == "") {
$errors['create_apply_ingame_name'] = "<div class='alert alert-danger'>
<strong>Du har ikke angivet noget In-Game navn!</strong>
</div>";
} elseif (strlen($apply_ingame_name) < 2) {
$errors['create_apply_ingame_name'] = "<div class='alert alert-info'>
<strong>Dit In-Game navn skal minimum være 2 karatere</strong>
</div>";
}
if ($apply_email == "") {
$errors['create_apply_email'] = "<div class='alert alert-danger'>
<strong>Email skal udfyldes!</strong>
</div>";
} elseif (!filter_var($apply_email, FILTER_VALIDATE_EMAIL)) {
$errors['create_apply_email'] = "<div class='alert alert-info'>
<strong>Email er ugyldig</strong>
</div>";
}
if ($apply_steamID == "") {
$errors['create_apply_steamID'] = "<div class='alert alert-danger'>
<strong>Du har ikke angivet noget SteamID!</strong>
</div>";
} elseif (strlen($apply_steamID) < 18) {
$errors['create_apply_steamID'] = "<div class='alert alert-info'>
<strong>Dit SteamID ser sådan her ud STEAM_0:0:XXXXXXXX</strong>
</div>";
}
if ($apply_text == "") {
$errors['create_apply_text'] = "<div class='alert alert-danger'>
<strong>Du har ikke skrevet noget om dig selv!</strong>
</div>";
}
if (empty($errors)) {
// Send ansøning
$created = create_apply($apply_name, $apply_age, $apply_ingame_name, $apply_email, $apply_steamID, $apply_text);
if ($created) {
echo "
<div class='alert alert-info'>
<strong>Din ansøning er sendt.</strong>
</div>
";
} else {
// Ansøning kunne ikke sendes
$create_error = "Ansøningen kunne ikke sendes, SteamID eksistere i forvejen";
}
} else {
$create_error = "Der opstod en fejl, Prøv igen";
}
}
?>
<section>
<hr>
<form class="form-horizontal" enctype="multipart/form-data" id="signup" method="post" name="signup" action="?p=askforsignup">
<?php
if (isset($errors['apply_name'])) {
echo $errors['apply_name'];
}
?>
<div class="form-group">
<label class="control-label col-sm-3">Navn <span class="text-danger">*</span></label>
<div class="col-md-8 col-sm-9">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user"></i></span><input class="form-control" id="mem_name" name="apply_name" placeholder="Navn" type="text" value="" >
</div>
</div>
</div>
<?php
if (isset($errors['create_apply_age'])) {
echo $errors['create_apply_age'];
}
?>
<div class="form-group">
<label class="control-label col-sm-3">Alder <span class="text-danger">*</span></label>
<div class="col-md-8 col-sm-9">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span><input class="form-control" id="age" name="apply_age" placeholder="Alder" type="date" value="" >
</div>
</div>
</div>
<?php
if (isset($errors['create_apply_ingame_name'])) {
echo $errors['create_apply_ingame_name'];
}
?>
<div class="form-group">
<label class="control-label col-sm-3">In-Game Name <span class="text-danger">*</span></label>
<div class="col-md-8 col-sm-9">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user"></i></span><input class="form-control" id="ingame_game" name="apply_ingame_name" placeholder="In-Game Name" type="text" value="" >
</div>
</div>
</div>
<?php
if (isset($errors['create_apply_email'])) {
echo $errors['create_apply_email'];
}
?>
<div class="form-group">
<label class="control-label col-sm-3">Email <span class="text-danger">*</span></label>
<div class="col-md-8 col-sm-9">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope"></i></span><input class="form-control" id="emailid" name="apply_email" placeholder="Email" type="email" value="" >
</div><small>Your Email is being used for ensuring the security of your account, authorization and access recovery.</small>
</div>
</div>
<?php
if (isset($errors['create_apply_steamID'])) {
echo $errors['create_apply_steamID'];
}
?>
<div class="form-group">
<label class="control-label col-sm-3">Steam ID <span class="text-danger">*</span></label>
<div class="col-md-5 col-sm-8">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-steam"></i></span><input class="form-control" id="contactnum" name="apply_steamID" placeholder="Steam ID" type="text" value="" >
</div>
</div>
</div>
<?php
if (isset($errors['create_apply_text'])) {
echo $errors['create_apply_text'];
}
?>
<div class="form-group">
<label class="control-label col-sm-3">Beskriv dig selv <span class="text-danger">*</span></label>
<div class="col-md-8 col-sm-9">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-id-card"></i></span>
<textarea class="form-control" rows="5" id="message" name="apply_text" placeholder="Beskriv dig selv." ></textarea>
</div><br>
<div class="col-xs-offset-8 col-xs-10 pull-right">
<input class="btn btn-primary" name="Submit" type="submit" value="Sign Up">
</div>
</div>
</div>
</form>
</section>
</div><!--/.col-sm-8-->
</div>
And this is the php code:
function create_apply($apply_name, $apply_age, $apply_ingame_name, $apply_email, $apply_steamID, $apply_text) {
global $db;
$steamID_exists = steamID_exists($apply_steamID);
if ($steamID_exists == false) {
$apply_name = mysqli_real_escape_string($db, $apply_name);
$apply_age = mysqli_real_escape_string($db, $apply_age);
$apply_ingame_name = mysqli_real_escape_string($db, $apply_ingame_name);
$apply_email = mysqli_real_escape_string($db, $apply_email);
$apply_steamID = mysqli_real_escape_string($db, $apply_steamID);
$apply_text = mysqli_real_escape_string($db, $apply_text);
$query = "INSERT INTO member_applys
(apply_name, apply_age, apply_ingame_name, apply_email, apply_steamID, apply_text, apply_date)
VALUES
('$apply_name', '$apply_age', '$apply_ingame_name', '$apply_email', '$apply_steamID', '$apply_text', NOW())";
$result = $db->query($query);
return true;
} else {
// Brugeren eksistere opret = falsk
return false;
}
}
Solved
the problem was google autocomplete was on not off

Di you be sure that your script call well the form?
I see:
....action="?p=askforsignup">
try:
....action="your_script.php">

Related

How to make PHP register errors go underneath their dedicated input boxes

I'm just wondering if anyone knows how to make the errors shown on this screenshot: https://imgur.com/a/eaTVR9g go underneath their dedicated input boxes like shown on this image: https://imgur.com/a/Sb1AfUj If anyone is kind enough to do it for me I would greatly appreciate it. Thank you!
Here is my code:
<?php
$title = "Register";
include ($_SERVER['DOCUMENT_ROOT'] . '/private/header.php');
if ($AUTH) {
header ('Location: /');
die();
}
if (isset($_POST['go'])) {
$username = $_POST['username'];
$email = strtolower($_POST['email']);
$password = $_POST['password'];
$passwordConfirm = $_POST['confirmPassword'];
$protectedPassword = password_hash($password, PASSWORD_ARGON2I);
// Validation Checks
$errors = array();
$Emailstmt = $db->prepare("SELECT * FROM `Users` WHERE `Email` = :email;");
$Emailstmt->bindParam(':email', $email, PDO::PARAM_STR);
$Emailstmt->execute();
if ($Emailstmt->rowCount() > 0) {
$error[] = 'The email you tried to use is already being used on an different account, please use another one.';
}
$Userstmt = $db->prepare("SELECT * FROM `Users` WHERE `Username` = :username;");
$Userstmt->bindParam(':username', $username, PDO::PARAM_STR);
$Userstmt->execute();
$checkIP = $db->prepare("SELECT count(*) FROM `Users` WHERE `LastIP` = :regIP");
$checkIP->bindParam(":regIP", $UserIP, PDO::PARAM_STR);
$checkIP->execute();
$checkIpAdress = $checkIP->fetchColumn();
if (empty($checkIpAdress)) {
$checkIpAdress = 0;
}
if ($checkIpAdress) {
if ($checkIpAdress > 3) {
array_push($errors, 'It looks like you have registered too many accounts under this IP address.');
}
}
if (strlen($username) < 3) {
array_push($errors, 'Your username must be at least 3 characters in total.');
}
if (strlen($password) < 5) {
array_push($errors, 'Your password must be at least 5 characters in total.');
}
if ($Userstmt->rowCount() > 0) {
array_push($errors, 'The username you tried to use is already being used, Maybe try to pick another one.');
}
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
//echo("$email is a valid email address");
} else {
array_push($errors, 'The email you specified(' . htmlspecialchars($email, ENT_QUOTES, "UTF-8") . ') is invaild.');
}
if (!preg_match("/^[a-zA-Z0-9][\w\.]+[a-zA-Z0-9]$/", $username)) {
array_push($errors, 'The username you specified(' . htmlspecialchars($username, ENT_QUOTES, "UTF-8") . ') contains special symbols or is invaild.');
}
if (strtolower($username) == strtolower($password)) {
array_push($errors, 'Your password can not be the same as your username.');
}
if ($password !== $passwordConfirm) {
array_push($errors, 'It looks like your passwords do not match.');
}
// Begin form submission
if (empty($errors)) {
$insert = $db->prepare("INSERT INTO `Users` (`Username`,`Email`,`Password`,`LastIP`,`TimeRegister`,`AvatarURL`) VALUES (:Username,:Email,:Password,:LastIP,:TimeRegister,:AvatarURL)");
$insert->bindParam(":Username", $username, PDO::PARAM_STR);
$insert->bindParam(":Email", $email, PDO::PARAM_STR);
$insert->bindParam(":Password", $protectedPassword, PDO::PARAM_STR);
$insert->bindParam(":LastIP", $UserIP, PDO::PARAM_STR);
$insert->bindParam(":TimeRegister", $now, PDO::PARAM_INT);
$insert->bindValue(":AvatarURL", '8ca17bec-0320-4293-90e5-dfc5b8690156', PDO::PARAM_STR);
$insert->execute();
?>
<div class="space">
<section class="hero is-success">
<div class="hero-body modal-button" data-target="modal" aria-haspopup="true"
style="padding: 1rem 1rem !important;">
<center>You have successfully registered! Please wait while we redirect you.</center>
</div>
</section><br>
</div>
<meta http-equiv='refresh' content='5;url=/auth/login' />
<?php
} else {
}
}
if ($SiteSettings->Registration == 0) {
echo '<section class="section">
<div class="container">
<div class="columns is-centered">
<div class="column is-7">
<div class="box">
<p>We\'re sorry, but account creation is currently disabled right now. Please try again later.</p>
</div>
</div>
</div>
</section>
';
include($_SERVER['DOCUMENT_ROOT'] . "/private/footer.php");
die;
}
?>
<section class="section">
<div class="container">
<div class="columns is-centered">
<div class="column is-7">
<div class="box">
<div class="title is-size-4">Register</div>
<form action="#" method="POST">
<input type="hidden" name="token" value="<?php echo $_SESSION["csrf_token"]; ?>" />
<div class="field">
<label class="label">Username</label>
<div class="control has-icons-left">
<input class="input" name="username" type="text" id="username" maxlength="15"
autocomplete="off" placeholder="Enter a username">
<span class="icon is-small is-left"><i class="fas fa-user"></i></span>
<p id="username_message"></p>
</div>
</div>
<div class="field">
<label class="label">E-Mail address</label>
<div class="control has-icons-left">
<input class="input" name="email" type="email" id="email" maxlength="128"
autocomplete="off" placeholder="Enter your e-mail address.">
<span class="icon is-small is-left"><i class="fas fa-envelope"></i></span>
<p id="email_message"></p>
</div>
</div>
<div class="field">
<label class="label">Password</label>
<div class="control has-icons-left">
<input class="input" name="password" type="password" id="password" maxlength="45"
autocomplete="off" placeholder="Enter your password.">
<span class="icon is-small is-left"><i class="fas fa-lock"></i></span>
<p id="password_message"></p>
</div>
</div>
<div class="field">
<label class="label">Confirm Password</label>
<div class="control has-icons-left">
<input class="input" name="confirmPassword" type="password" id="confirmPassword"
maxlength="45" autocomplete="off" placeholder="Confirm your password">
<span class="icon is-small is-left"><i class="fas fa-lock"></i></span>
<p id="confirmPassword_message"></p>
</div>
</div>
<div class="push-5"></div>
<button class="button is-success is-fullwidth" type="submit" name="go"><b>Register</b></button>
</form>
<?php
if (!empty($errors)) {
?>
<?php
foreach ($errors as $error) {
echo '<p class="help has-text-danger">' . $error . '</p>';
}
} ?>
</div>
<p class="has-text-centered">Already a member? Login</p>
</div>
</div>
</div>
</section>
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/private/footer.php'); ?>
You can organize the array keys to reflect the fields they relate to, IE:
if (strlen($username) < 3) {
$errors['username'][] = 'Your username must be at least 3 characters in total.';
}
and then on the display side you can use said keys to identify what errors belong to what field, IE:
<div class="field">
<label class="label">Username</label>
<div class="control has-icons-left">
<input class="input" name="username" type="text" id="username" maxlength="15" autocomplete="off" placeholder="Enter a username">
<span class="icon is-small is-left"><i class="fas fa-user"></i></span>
<p id="username_message">
<?php if (isset($errors['username'])): ?>
<?php foreach($errors['username'] as $error): ?>
<?= $error ?> <br/>
<?php endforeach; ?>
<?php endif; ?>
</p>
</div>

Keep form value after user fail on registration

PHP CODE REQUEST
Hey guys i want to asking about "How to keep the form value after we fail registration?"
this is my register.php :
<?php
ob_start();
session_start();
if( isset($_SESSION['user2'])!="" ){
header("Location: home.php");
}
include_once 'serverconfig.php';
if(isset($_POST['btn-signup'])) {
$alpha = "abcdefghijklmnopqrstuvwxyz";
$alpha_upper = strtoupper($alpha);
$numeric = "0123456789";
$special = ".-+=_,!#$#*%<>[]{}";
$chars = "";
if (isset($_POST['gencode'])){
// if you want a form like above
if (isset($_POST['alpha']) && $_POST['alpha'] == 'on')
$chars .= $alpha;
if (isset($_POST['alpha_upper']) && $_POST['alpha_upper'] == 'on')
$chars .= $alpha_upper;
if (isset($_POST['numeric']) && $_POST['numeric'] == 'on')
$chars .= $numeric;
if (isset($_POST['special']) && $_POST['special'] == 'on')
$chars .= $special;
$length = $_POST['length'];
}else{
// default [a-zA-Z0-9]{9}
$chars = $alpha . $alpha_upper . $numeric;
$length = 9;
}
$len = strlen($chars);
$gc = '';
for ($i=0;$i<$length;$i++)
$gc .= substr($chars, rand(0, $len-1), 1);
// the finished password
$gc = str_shuffle($gc);
$namalengkap_ = trim($_POST['namalengkap']);
$email_ = trim($_POST['email']);
$nomorhape_ = trim($_POST['nomorhape']);
$jeniskelamin_ = trim($_POST['jeniskelamin']);
$tanggallahir_ = trim($_POST['tanggallahir']);
$username_ = trim($_POST['uname']);
$password_ = trim($_POST['upass']);
$namalengkap = strip_tags($namalengkap_);
$email = strip_tags($email_);
$nomorhape = strip_tags($nomorhape_);
$jeniskelamin = strip_tags($jeniskelamin_);
$tanggallahir = strip_tags($tanggallahir_);
$username = strip_tags($username_);
$password = strip_tags($password_);
// check email exist or not
$query = "SELECT email FROM user2 WHERE email='$email'";
$result = mysql_query($query);
$query2 = "SELECT username FROM user2 WHERE username='$username'";
$result2 = mysql_query($query2);
$count = mysql_num_rows($result); // if email not found then proceed
$count2 = mysql_num_rows($result2);
if ($count==0 && $count2==0) {
$query = "INSERT INTO user2(namalengkap,email,jeniskelamin,tanggallahir,username,password,activecode,status) VALUES('$namalengkap','$email','$jeniskelamin','$tanggallahir','$username','$password','$gc','0')";
$res = mysql_query($query);
if ($res) {
$errTyp = "success";
$errMSG = "Registrasi Berhasil !";
} else {
$errTyp = "danger";
$errMSG = "Ada Kesalahan Saat Mengisi Form Di Bawah, Silahkan Cek Kembali";
}
} else {
$errTyp = "warning";
$errMSG = "E-Mail/Username Sudah Digunakan Oleh User Lain. Silahkan Daftar E-Mail, ";
$errMSG .= "Klik Disini";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ariigoh Register</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
</head>
<body>
<div class="container">
<div id="login-form">
<form method="post" autocomplete="off">
<div class="col-md-12">
<div class="form-group">
<h2 class="">Sign Up to <kbd>Ariigoh Afnan Localhost</kbd></h2>
</div>
<div class="form-group">
<hr />
</div>
<?php
if ( isset($errMSG) ) {
?>
<div class="form-group">
<div class="alert alert-<?php echo ($errTyp==" success ") ? "success " : $errTyp; ?>">
<span class="glyphicon glyphicon-info-sign"></span>
<?php echo $errMSG; ?>
</div>
<div id="errmsgbox">
<div id="divError"></div>
</div>
</div>
<?php
}
?>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
<input type="text" name="namalengkap" class="form-control" placeholder="Masukan Nama Lengkap Anda" pattern="^[a-zA-Z ]*$" title="Masukan Nama Anda Yang Benar" max="32" min="4" required/>
</div>
<div class="input-group">
<p><kbd>Input tidak di perbolehkan nomor/spesial karakter</kbd></p>
</div>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-earphone"></span></span>
<input type="text" name="nomorhape" class="form-control" placeholder="Masukan Nomor Handphone Anda" pattern="^[0-9]*$" title="Masukan Nomor Handphone Yang Benar" max="14" min="4" required />
</div>
<div class="input-group">
<p><kbd>Input hanya nomor dan tanpa (+62) -> ex : 08xxxxxxxxxx</kbd> </p>
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
<input type="email" name="email" class="form-control" placeholder="Masukan Alamat Email Anda" pattern="^[A-Za-z#.0-9]*$" title="Masukan E-Mail yang Valid(Aktif)" required />
</div>
<div class="input-group">
<p><kbd>Input hanya diperbolehkan a-z(A-Z),#,0-9,dan.(titik) -> ex : contoh.12#localhost.com</kbd></p>
</div>
</div>
<div class="form-group">
<label for="sel1">Jenis Kelamin:</label>
<select class="form-control" id="sel1" name="jeniskelamin" required>
<option value="Laki-Laki">Laki-Laki</option>
<option value="Perempuan">Perempuan</option>
</select>
</div>
<div class="form-group">
<label for="sel2">Tanggal Lahir :</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
<input type="date" name="tanggallahir" class="form-control" required />
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
<input type="text" name="uname" class="form-control" placeholder="Masukan Username" pattern="^[a-zA-Z0-9]*$" title="Masukan Username Dengan Benar" required />
</div>
<div class="input-group">
<p><kbd>Input hanya diperbolehkan a-z(A-Z) dan 0-9</kbd></p>
</div>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
<input type="password" name="upass" class="form-control" placeholder="Masukan Password" pattern="^[a-zA-Z0-9]*$" title="Masukan Password Dengan Benar" required />
</div>
<div class="input-group">
<p><kbd>Input hanya diperbolehkan a-z(A-Z) dan 0-9</kbd></p>
</div>
</div>
<div class="form-group">
<div class="alert-danger">
<h4><strong>Perhatian !</strong> Gunakan E-Mail Yang Sudah Terdaftar di Localhost. Kalau Tidak Yakin Silahkan Daftar, Klik Disini</h4>
</div>
</div>
<div id="form-group">
<button type="submit" class="btn btn-block btn-primary" name="btn-signup">Sign Up</button>
</div>
<hr>
<div class="form-group">
Sign in Here...
</div>
</div>
</form>
</div>
</div>
</body>
</html>
what must i do with that script ?
thank you for you help :) and sorry for my bad english ;)
Use some thing like this:
<input type="email" name="email" class="form-control" placeholder="Masukan Alamat Email Anda" pattern="^[A-Za-z#.0-9]*$" title="Masukan E-Mail yang Valid(Aktif)" value="<?php isset($_REQUEST['email']) ? $_REQUEST['email'] : '' ?>" required />
this
value="<?php if(isset($_REQUEST['email'])) { echo $_REQUEST['email']; } ?>"
will retain value in the textbox on unsuccessful processing.
Take a look to this example may help you PHP Form validation

Logical Error with PHP! A password length check

I am getting a logical error I believe I am using PHP as my server side language and I am performing password checks. Users will not be allowed to enter a password less than 8 characters and no more than 32 characters.
register.php
<?php $pageTitle = "Register"; ?>
<?php $sectoin = "signing"; ?>
<?php include 'INC/header.php'; ?>
<?php
$submit = $_POST['submit'];
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);
$repeatPassword = strip_tags($_POST['repeatPassword']);
$email = strip_tags($_POST['email']);
$date = date("m-d-Y");
if ($submit) {
// Checking for exsistence
if ($username && $password && repeatPassword && $email) {
// Encrypts the Pasword
$password = md5($password);
$repeatPassword = md5($repeatPassword);
// Do Passwords Match
if ($password == $repeatPassword) {
// Check Character Length of Username
if (strlen($username) > 16 || strlen($username) <= 2) {
echo "<h3 class='text-center'> <span class='alert alert-warning'> Your <b>Username</b> must be between 3 and 16 characters! </h3> </span>";
} else {
// Check Password Length
if (strlen($password && $repeatPassword) < 8) {
echo "<h3 class='text-center'> <span class='alert alert-warning'> Your <b>Password</b> is less than 8 characters! </h3> </span>";
} else {
echo 'Registration Completed!';
}
}
} else echo "<h3 class='text-center'> <span class='alert alert-danger'> Your <b>Passwords</b> must match! </h3> </span>";
} else echo "<h3 class='text-center'> <span class='alert alert-warning'> Please fill out <b>All</b> fields!</h3> </span>";
}
?>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-body">
<div class="page-header">
<h3 class="text-center"> Registration </h3>
</div>
<form class="form-horizontal" role="form" action="register.php" method="POST">
<!--Start of Username-->
<div class="form-group">
<label for="username" class="col-sm-2 control-label"> Username </label>
<div class="col-sm-10">
<div class="input-group">
<span class="input-group-addon"> <span class="glyphicon glyphicon-user"> </span> </span>
<input type="text" name="username" class="form-control" id="username" placeholder="Username" />
</div>
</div>
</div>
<!--End of Username-->
<!--Start of E-Mail-->
<div class="form-group">
<label for="email" class="col-sm-2 control-label"> E-Mail </label>
<div class="col-sm-10">
<div class="input-group">
<span class="input-group-addon"> <span class="glyphicon glyphicon-envelope"> </span> </span>
<input type="email" name="email" class="form-control" id="email" placeholder="E-Mail" />
</div>
</div>
</div>
<!--End of E-Mail-->
<!--Start of Password-->
<div class="form-group">
<label for="password" class="col-sm-2 control-label"> Password </label>
<div class="col-sm-10">
<div class="input-group">
<span class="input-group-addon"> <span class="glyphicon glyphicon-star"> </span> </span>
<input type="password" name="password" class="form-control" id="password" placeholder="Password" />
</div>
</div>
</div>
<!--End of Password-->
<!--Start of Repeat Password-->
<div class="form-group">
<label for="repeatPassword" class="col-sm-2 control-label"> <span id="repeatPassword"> Repeat Password </span> </label>
<div class="col-sm-10">
<div class="input-group">
<span class="input-group-addon"> <span class="glyphicon glyphicon-check"> </span> </span>
<input type="password" name="repeatPassword" class="form-control" id="password" placeholder="Password" />
</div>
</div>
<!--End of Repeat Password-->
<!--Start of Checkbox and Submit Button-->
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<label class="checkbox">
<input type="checkbox" name="rememberMe" value="rememberMe" id="rememberMe"> <span id="rememberUs"> Remember Me </span>
</label>
<button type="submit" name="submit" value="Register" class="btn btn-primary slideToTheLeft"> Register </button>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="col-sm-2"></div>
</div>
<?php include 'INC/footer.php'; ?>
If I take the '&& $repeatPassword' out of the equation it skips the condition and echos.
if (strlen($password && $repeatPassword) < 8 {
However, it is called that $repeatPassword = $password, so I shouldn't even need the '&& repeatPassword' but it won't do anything if it is included into the code.
However, the main problem besides that is that no matter what the if statement is stating that no matter what the password is less than 8 characters.
As a means of testing if supplied values are within permitted bounds you could try:
$valid_username=in_array( strlen( $username ), range(2,16) );
$valid_password=$password===$repeatPassword && in_array( strlen( $password ), range(8,32) );
if( $valid_username && $valid_password ){/* all good */}
example:
if( $submit ) {
if( $username && $password && $repeatPassword && $email ) {
// hash the Passwords
$password = md5( trim( $password ) );
$repeatPassword = md5( trim( $repeatPassword ) );
$unrange=range(3,16);
$pwdrange=range(8,32);
$valid = true;
$valid_username = in_array( strlen( $username ), $unrange );
$valid_password = in_array( strlen( $password ), $pwdrange );
$password_match = $password===$repeatPassword;
if( !$valid_password ){
$valid=false;
echo "<h3 class='text-center'> <span class='alert alert-warning'> Your <b>Password</b> should be between ".min( $pwdrange )." and ".max( $pwdrange )." characters! </h3> </span>";
}
if( !$valid_username ){
$valid=false;
echo "<h3 class='text-center'> <span class='alert alert-warning'> Your <b>Username</b> must be between ".min( $unrange )." and ".max( $unrange )." characters! </h3> </span>";
}
if( !$password_match ){
$valid=false;
echo "<h3 class='text-center'> <span class='alert alert-danger'> Your <b>Passwords</b> must match! </h3> </span>";
}
if( $valid ) {
echo 'Registration Completed!';
/* add to db? */
}
} else echo "<h3 class='text-center'> <span class='alert alert-warning'> Please fill out <b>All</b> fields!</h3> </span>";
}
You probably don't need to check the length of both $password and $repeatPassword since you will also be checking to see if they match each other.
if (strlen($password < 8) {
// error
} elseif ($password != $repeatPassword) {
// error
} else {
// ALL IS GOOD !
}
I had actually solved my problem, I decided to take out the or to the password and it had solved the problem and everything is up and running.
Try this:
if (strlen($password) >= 8 && strlen($password) <= 32) {
if (strlen($repeatpassword) >= 8 && strlen($repeatpassword) <= 32) {
// code here
}
}
I think it's a bit odd to check both passwords, however.
So, my solution would be:
if (strlen($password) >= 8 && strlen($password) <= 32) {
// code here
}

Save Bootstrap Form Helpers Country picker to my database

I have used Bootstrap-Form-Helpers to display the countries and the flags through a drop down box. I have used the following Html,
<div class="bfh-selectbox bfh-countries" data-country="US" data-flags="true">
<input type="hidden" value="">
<a class="bfh-selectbox-toggle" role="button" data-toggle="bfh-selectbox" href="#">
<span class="bfh-selectbox-option input-medium" data-option=""></span>
<b class="caret"></b>
</a>
<div class="bfh-selectbox-options">
<input type="text" class="bfh-selectbox-filter" name="country">
<div role="listbox">
<ul role="option">
</ul>
</div>
</div>
</div>
The PHP code to save to the database is
if (isset($_POST['btn_signup'])) {
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$username = $_POST['username'];
$pass = $_POST['password'];
$cpass = $_POST['conf_pass'];
$country = $_POST['country'];
$dropdown = $_POST['dropdown'];
$query3 = "SELECT * from tbl_users WHERE email = '" . $email . "'";
$result3 = mysql_query($query3, $con) or die(mysql_error());
$query = "SELECT * from tbl_users WHERE username = '" . $username . "'";
$result = mysql_query($query, $con) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
echo '<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">';
echo '<div class="alert alert-danger alert-dismissable">';
echo '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
echo 'Username is not available! Please Try another username!!.' . mysql_error();
echo '</div>';
echo '</div>';
}
elseif ($pass != $cpass) {
echo '<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">';
echo '<div class="alert alert-danger alert-dismissable">';
echo '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
echo 'Password typed doesnt match please retype the password correctly!!.' . mysql_error();
echo '</div>';
echo '</div>';
}
elseif (mysql_num_rows($result3) > 0) {
echo '<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">';
echo '<div class="alert alert-danger alert-dismissable">';
echo '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
echo 'Email Already exist please try another email!!.' . mysql_error();
echo '</div>';
echo '</div>';
}
else {
$query2 = "INSERT INTO tbl_users (first_name,last_name,username,password,confPass,email,country,user_type)VALUES('{$fname}','{$lname}','{$username}','{$pass}','{$cpass}','{$email}','{$country}','{$dropdown}')";
$result2 = mysql_query($query2);
echo '<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">';
echo '<div class="alert alert-success alert-dismissable">';
echo '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
echo 'Success! Well done its submitted.';
echo '</div>';
echo '</div>';
}
}
All my other data is entered to my database. But not the country.
Please help!!
You can use data-name="country" in below div tag. Then you can get in selected country in the $_POST.
<div class="bfh-selectbox bfh-countries" data-country="US" data-name="country" data-flags="true"> ..............remaining code here.............. </div>
$country = $_POST['country'];
Let me know if this help.
Thanks
The input field your getting is overwriting by the form helper function
Try the below code
<?php
session_start();
require_once ("includes/db.php");
print_r($_POST);
if (isset($_POST['btn_signup'])) {
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$username = $_POST['username'];
$pass = $_POST['password'];
$cpass = $_POST['conf_pass'];
$country = $_POST['country'];
$dropdown = $_POST['dropdown'];
$query3 = "SELECT * from tbl_users WHERE email = '" . $email . "'";
$result3 = mysql_query($query3, $con) or die(mysql_error());
$query = "SELECT * from tbl_users WHERE username = '" . $username . "'";
$result = mysql_query($query, $con) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
echo '<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">';
echo '<div class="alert alert-danger alert-dismissable">';
echo '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
echo 'Username is not available! Please Try another username!!.' . mysql_error();
echo '</div>';
echo '</div>';
}
elseif ($pass != $cpass) {
echo '<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">';
echo '<div class="alert alert-danger alert-dismissable">';
echo '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
echo 'Password typed doesnt match please retype the password correctly!!.' . mysql_error();
echo '</div>';
echo '</div>';
}
elseif (mysql_num_rows($result3) > 0) {
echo '<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">';
echo '<div class="alert alert-danger alert-dismissable">';
echo '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
echo 'Email Already exist please try another email!!.' . mysql_error();
echo '</div>';
echo '</div>';
}
else {
$query2 = "INSERT INTO tbl_users (first_name,last_name,username,password,confPass,email,country,user_type)VALUES('{$fname}','{$lname}','{$username}','{$pass}','{$cpass}','{$email}','{$country}','{$dropdown}')";
$result2 = mysql_query($query2);
echo '<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">';
echo '<div class="alert alert-success alert-dismissable">';
echo '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
echo 'Success! Well done its submitted.';
echo '</div>';
echo '</div>';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Mycricprofle</title>
<link rel="shortcut icon" href="http://faviconist.com/icons/be7b568b1a766b3888e5326879e1a9b8/favicon.ico" />
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<link rel="stylesheet" href="css/bootstrap-theme.min.css"/>
<link rel="stylesheet" href="css/bootstrap-formhelpers-countries.flags.css"/>
<link rel="stylesheet" href="css/bootstrap-formhelpers.min.css"/>
<script src="js/vendor/jquery-1.11.2.min.js"></script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/bootstrap-formhelpers.min.js"></script>
<script src="js/bootstrap-formhelpers-countries.js"></script>
<style>
.style {
color: #761c19;
text-decoration: none;
}
.style a {
text-decoration: none;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<div class="col-md-6 col-sm-6 col-xs-12">
<h2>Signup to Create a New Account</h2>
<br/>
<form action="signup.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="text">First Name:</label>
<input type="text" class="form-control" placeholder="Firstname" name="fname" required/>
</div>
<br/>
<div class="form-group">
<label for="text">Last Name:</label>
<input type="text" class="form-control" placeholder="Last name" name="lname" required/>
</div>
<br/>
<div class="bfh-selectbox bfh-countries" data-country="US" data-flags="true">
<input type="hidden" id="country" name="country" value="">
<a class="bfh-selectbox-toggle" role="button" data-toggle="bfh-selectbox" href="#"> <span class="bfh-selectbox-option input-medium" data-option=""></span> <b class="caret"></b> </a>
<div class="bfh-selectbox-options">
<input type="text" class="bfh-selectbox-filter">
<div role="listbox">
<ul role="option">
</ul>
</div>
</div>
</div>
<br/>
<div class="form-group">
<label for="text">Email:</label>
<input type="email" class="form-control" placeholder="Email" name="email" required/>
</div>
<br/>
<div class="form-group">
<label for="text">Username:</label>
<input type="text" class="form-control" placeholder="Username" name="username" required/>
</div>
<br/>
<div class="form-group">
<label for="text">Password:</label>
<input type="password" class="form-control" placeholder="Password" name="password" required/>
</div>
<br/>
<div class="form-group">
<label for="text">Confirm Password:</label>
<input type="password" class="form-control" placeholder="Confirm Password" name="conf_pass" required/>
</div>
<br/>
<select class="form-control selectpicker" name="dropdown" id="type_user" required/>
<option value="player">Player</option>
<option value="recruiter">Recruiter</option>
</select>
<br/>
<br/>
<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--accent" id="btn_signup" name="btn_signup">Submit</button>
</form>
<br/>
<p class="style">Back to <a href='index.php'>Home</a></p>
<p class="style">Signin to Get in <a href='signin.php'>Sigin in</a></p>
</div>
</div>
<script>
$(document).ready(function(e) {
$(document).find(".bfh-countries input[type=hidden]").attr("name","country");
});
</script>
<?php
// include('includes/footer.php');
?>
</body>
</html>
About DOM reffer this
About DOM manupilation reffer this
Assuming you're using at least version 2.3 of the formhelpers library, You should be able to replace this:
<div class="bfh-selectbox bfh-countries" data-country="US" data-flags="true">
<input type="hidden" id="country" name="country" value="">
<a class="bfh-selectbox-toggle" role="button" data-toggle="bfh-selectbox" href="#"> <span class="bfh-selectbox-option input-medium" data-option=""></span> <b class="caret"></b> </a>
<div class="bfh-selectbox-options">
<input type="text" class="bfh-selectbox-filter">
<div role="listbox">
<ul role="option">
</ul>
</div>
</div>
</div>
With this:
<div class="country bfh-selectbox bfh-countries" data-flags="true" data-filter="true" data-name="country"></div>
The data-name attribute specifies the name of the hidden field that's used to store the two character country code. You can also specify the value of data-country which will either supply a default value or maintain the value after the postback but that depends on how you're handling it.

Disable button after submit PHP

I have this code that when submitted, it generates random number from the array.
<?php
if(isset($_POST['roll'])) {
$randarray = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$randselect = array_rand($randarray);
$nr = $randarray[$randselect];
echo '<p class="btn btn-info"> Branch: '. $nr. '</p>';
}
?>
<form action="#" method="post">
<button type="submit" class="btn btn-default" name="roll">Roll Branch </button>
</form>
What I wanted to do is after the form was submitted, the button will be disabled. Any thoughts?
Just add disabled if the button is pressed, e.g.
<button type="submit" class="btn btn-default" name="roll" <?php echo isset($_POST["roll"]) ? "disabled" : "";?>>Roll Branch </button>
You can do this:
<button type="submit" class="btn btn-default" name="roll" <?php echo isset($_POST['roll']) ? 'disabled="true"' : ''; ?> >Roll Branch </button>
Add onclick="this.disabled='true';" for button tag
It is not getting enabled after page post and I got some error.
In my situation my signup page have a submit button. Below is the code :
<form action="" method="post" id="signup-form" name="signup-form">
<div class="row">
<div class="form-group col-md-12 mb-4">
<input type="text" class="form-control input-lg" id="txtFormNo" name="txtFormNo" aria-describedby="nameHelp" placeholder="Form No" required readonly>
</div>
<div class="form-group col-md-12 mb-4">
<label for="standard">Select Standard</label>
<select class="form-control" id="standard" name="standard" required>
<option>FYJC</option>
<option>SYJC</option>
</select>
</div>
<div class="col-sm-12">
<div class="row">
<div class="col-6">
<div class="form-group">
<label for="txtSeatNo">SSC Seat No</label>
<input type="text" class="form-control input-lg" id="txtSeatNo" name="txtSeatNo" autocomplete="off" aria-describedby="nameHelp" placeholder="SSC Seat No" maxlength="7" required>
</div>
</div>
<div class="col-6">
<div class="form-group">
<label for="confirmSeatNo">Re-enter SSC Seat No</label>
<input type="text" class="form-control input-lg" id="confirmSeatNo" name="confirmSeatNo" autocomplete="off" aria-describedby="nameHelp" placeholder="Re-enter SSC Seat No" maxlength="7" required>
</div>
</div>
</div>
</div>
<?php if (isset($_GET['flag']) != 'newsyjc') { ?>
<div class="col-sm-12">
<div class="row">
<div class="col-6">
<div class="form-group">
<label for="txtSscAppNo">Enter Unique Application ID</label>
<input type="text" class="form-control input-lg" placeholder="UNIQUE APPLICATION ID" autocomplete="off" name="txtSscAppNo" id="txtSscAppNo" maxlength="6" required />
</div>
</div>
<div class="col-6">
<div class="form-group">
<label for="confirmSscAppNo">Re-enter Unique Application ID</label>
<input type="text" class="form-control input-lg" placeholder="Re-enter UNIQUE APPLICATION ID" autocomplete="off" name="confirmSscAppNo" id="confirmSscAppNo" maxlength="6" required />
</div>
</div>
</div>
</div>
<?php } ?>
<div class="col-sm-12">
<div class="row">
<div class="col-6">
<div class="form-group">
<label for="txtContact">Enter Contact No.</label>
<input type="text" class="form-control input-lg" id="txtContact" name="txtContact" autocomplete="off" placeholder="Contact" maxlength="10" required>
</div>
</div>
<div class="col-6">
<div class="form-group">
<label for="confirmContact">Re-enter Contact No.</label>
<input type="text" class="form-control input-lg" id="confirmContact" name="confirmContact" autocomplete="off" placeholder="Re-enter Contact" maxlength="10" required>
</div>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="row">
<div class="col-6">
<div class="form-group">
<label for="txtEmail">Enter Email ID</label>
<input type="email" class="form-control input-lg" id="txtEmail" name="txtEmail" aria-describedby="emailHelp" autocomplete="off" placeholder="Email ID" required>
</div>
</div>
<div class="col-6">
<div class="form-group">
<label for="confirmEmail">Re-enter Email ID</label>
<input type="email" class="form-control input-lg" id="confirmEmail" name="confirmEmail" aria-describedby="emailHelp" autocomplete="off" placeholder="Re-enter Email ID" required>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="d-inline-block mr-3">
<label class="control control-checkbox">
<input type="checkbox" required />
<div class="control-indicator"></div>
I Agree the terms and conditions
</label>
</div>
<button type="submit" class="btn btn-lg btn-primary btn-block mb-4" name = "btnSignup" id = "btnSignup"
<?php echo isset($_POST["btnSignup"]) ? "disabled" : "";?> >Sign Up</button>
<p>Already have an account?
<a class="text-blue" href="login.php">Sign in</a>
</p>
</div>
</div>
</form>
PHP Code :
if (isset($_POST['btnSignup'])) {
$standard = trim($_POST['standard']);
$SeatNo = trim($_POST['txtSeatNo']);
$cSeatNo = trim($_POST['confirmSeatNo']);
$FormNo = trim($_POST['txtFormNo']);
$contact = trim($_POST['txtContact']);
$cContact = trim($_POST['confirmContact']);
$Email = trim($_POST['txtEmail']);
$cEmail = trim($_POST['confirmEmail']);
$code = md5(uniqid(rand()));
$stmt = $user->runQuery("SELECT * FROM stud_personal_details WHERE SeatNo=:SeatNo");
$stmt->execute(array(":SeatNo"=>$SeatNo));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if ($flag == 'newsyjc') {
$SscAppNo = '';
$cSscAppNo = '';
if ($stmt->rowCount() > 0) {
$msg = "<div class='alert alert-error'>
<strong>Sorry !</strong> Seat No is Already Registered.<br>
Please enter your correct Seat No OR <a class='btn btn-success btn-lg' href='login.php'>Click here to login !</a>
</div>";
} else if ($standard == 'SYJC') {
if ($user->stud_personal_details($SeatNo, $FormNo, $SscAppNo, $Password, $contact, $code, $Email) &&
$user->stud_admission_details($SeatNo, $SscAppNo) &&
$user->stu_app($SeatNo, $code) &&
$user->Marks($SeatNo) ) {
$user->send_sms($SeatNo, $Password, $Email);
$msg = "<div class='alert alert-success' role='alert'>
<strong>Success!</strong> Your account is created.<br>
Password have been SMS on ".$contact." and mailed at ".$Email."<br>
<p><a class='text-blue' href='login.php'>Click here to login !</a></p>
</div>";
//header("refresh:3;login.php?flag=".$flag);
} else {
$msg = "<div class='alert alert-danger' role='alert'>
<strong>Sorry !</strong> Something went wrong.<br>
Contact college office or IT Charge of College.
</div>";
}
}
} else if ($days > 0) {
$SscAppNo = trim($_POST['txtSscAppNo']);
$cSscAppNo = trim($_POST['confirmSscAppNo']);
if (strlen($SeatNo) != 7 ) {
$msg = "<div class='alert alert-danger' role='alert'>
<i class='mdi mdi-alert mr-1'></i> SSC Seat Number is a 7 alpha-numberic combination.<br>
Please enter again.
</div>";
} else if ($cSeatNo !== $SeatNo) {
$msg = "<div class='alert alert-danger' role='alert'>
<i class='mdi mdi-alert mr-1'></i> <strong>Sorry!</strong> SSC Seat Number doesn't match.<br>
Please enter again.
</div>";
} else if (strlen($SscAppNo) != 6 ) {
$msg = "<div class='alert alert-danger' role='alert'>
<i class='mdi mdi-alert mr-1'></i> UNIQUE APPLICATION ID should be 6 numberic value.<br>
Please enter again.
</div>";
} else if ($cSscAppNo !== $SscAppNo) {
$msg = "<div class='alert alert-danger' role='alert'>
<i class='mdi mdi-alert mr-1'></i> <strong>Sorry!</strong> UNIQUE APPLICATION ID doesn't match.<br>
Please enter again.
</div>";
} else if (strlen($contact) != 10 ) {
$msg = "<div class='alert alert-danger' role='alert'>
<i class='mdi mdi-alert mr-1'></i> Contact No. should be of 10 digits.
</div>";
} else if ($contact!==$cContact) {
$msg = "<div class='alert alert-danger' role='alert'>
<i class='mdi mdi-alert mr-1'></i> <strong>Sorry!</strong> Contact No. Doesn't match.
</div>";
} else if ($cEmail!==$Email) {
$msg = "<div class='alert alert-danger' role='alert'>
<i class='mdi mdi-alert mr-1'></i> <strong>Sorry!</strong> Email Doesn't match.<br>
Please enter again.
</div>";
} else if ($stmt->rowCount() > 0) {
$msg = "<div class='alert alert-danger' role='alert'>
<i class='mdi mdi-alert mr-1'></i> <strong>Sorry !</strong> Seat No is Already Registered.<br>
Please enter your correct Seat No OR <a class='btn btn-success btn-lg' href='login.php?days=".$days."'>Click here to login !</a>
</div>";
} else if ($standard == 'FYJC') {
if ($user->stud_personal_details($SeatNo, $FormNo, $SscAppNo, $Password, $contact, $code, $Email) &&
$user->stud_admission_details($SeatNo, $SscAppNo) &&
$user->stu_app($SeatNo, $code) &&
$user->Marks($SeatNo) ) {
$user->send_sms($SeatNo, $Password, $Email, $contact);
$msg = "<div class='alert alert-success' role='alert'>
<strong>Success!</strong> Your account is created.<br>
Password have been send on ".$contact." and also mailed at ".$Email."<br>
<a class='btn btn-success btn-lg' href='login.php?days=".$days."'>Click here to login !</a>
</div>";
} else {
$msg = "<div class='alert alert-danger' role='alert'>
<strong>Sorry !</strong> Something went wrong...<br>
Contact college office or IT Charge of College.
</div>";
}
}
}
}
It stays disabled incase of some error or otherwise even after success. I mean to say it should stay disable when clicked but should get enable as soon as some error or success occurs so that user can again fill the form and click on submit again.

Categories