Users can use the same email address for different registration.
Tried using different solutions from developers on Stack Overflow who have experienced the same problems that I have, including making the emailUsers column a UNIQUE KEY in the database table, and implementing some sort of jQuery, but not successful. Think the problem is I am missing an 'else if' block for duplicate email, but all the various ways I tried to implement this, it does not do anything.
<div id="signup">
<div class="container">
<div class="row">
<div class="col-sm-6 offset-sm-1">
<div class="signup-left position-fixed text-center">
<img src="img/200.png">
<br><br><br>
<?php
if(isset($_GET['error']))
{
if($_GET['error'] == 'emptyfields')
{
echo '<div class="alert alert-danger" role="alert">
<strong>Error: </strong> Fill In All The Fields
</div>';
}
else if ($_GET['error'] == 'invalidmailuid')
{
echo '<div class="alert alert-danger" role="alert">
<strong>Error: </strong> Please enter a valid email and user name
</div>';
}
else if ($_GET['error'] == 'invalidmail')
{
echo '<div class="alert alert-danger" role="alert">
<strong>Error: </strong> Please enter a valid email
</div>';
}
else if ($_GET['error'] == 'invaliduid')
{
echo '<div class="alert alert-danger" role="alert">
<strong>Error: </strong> Please enter a valid user name
</div>';
}
else if ($_GET['error'] == 'passwordcheck')
{
echo '<div class="alert alert-danger" role="alert">
<strong>Error: </strong> Passwords donot match
</div>';
}
else if ($_GET['error'] == 'usertaken')
{
echo '<div class="alert alert-danger" role="alert">
<strong>Error: </strong> This User name is already taken
</div>';
}
else if ($_GET['error'] == 'invalidimagetype')
{
echo '<div class="alert alert-danger" role="alert">
<strong>Error: </strong> Invalid image type
</div>';
}
else if ($_GET['error'] == 'imguploaderror')
{
echo '<div class="alert alert-danger" role="alert">
<strong>Error: </strong> Image upload error, please try again
</div>';
}
else if ($_GET['error'] == 'imgsizeexceeded')
{
echo '<div class="alert alert-danger" role="alert">
<strong>Error: </strong> Image too large
</div>';
}
else if ($_GET['error'] == 'sqlerror')
{
echo '<div class="alert alert-danger" role="alert">
<strong>Website Error: </strong> Contact admin to have the issue fixed
</div>';
}
}
else if (isset($_GET['signup']) == 'success')
{
echo '<div class="alert alert-success" role="alert">
<strong>Signup Successful</strong> Please Login from the login menu
</div>';
}
?>
<form id="signup-form" action="includes/signup.inc.php" method='post' enctype="multipart/form-data">
<input type="submit" class="btn btn-light btn-lg" name="signup-submit" value="Signup">
<br><br>
<a href="login.php">
<i class="fa fa-sign-in fa-2x social-icon" aria-hidden="true"></i>
</a>
<a href="contact.php">
<i class="fa fa-envelope fa-2x social-icon" aria-hidden="true"></i>
</a>
</div>
</div>
I want to be able to block a user from registering with the same email, and to generate an error message when the user tries to do this.
EXTRA INFO: Can post further, detailed methods of me trying to make the emailUsers column a UNIQUE KEY, but when I do this, new users can no longer register, even if they use a different email.
Related
THIS IS THE THE MAIN-PAGE.PHP upon clicking on the add button a modal will appear
THIS IS THE FORM THAT I PUT IN A BOOTSRAP MODAL, the form has an action="add.php" which is a seperated php file
this is the add.php code, I don't know how to display the $status on main-page.php because it is in the add.php file.
$run_sql = mysqli_query($conn, $sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error($conn), E_USER_ERROR);
if ($run_sql===true){
move_uploaded_file($tmp_profile_img,"upload/$profile_img");
$status = '<div class="alert alert-info alert-dismissible fade show" role="alert">
<strong>The data has been inserted SUCCESSFULLY</strong> You should check in on some of those fields below.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
else{
$status = '<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>The data was NOT inserted SUCCESSFULLY</strong> Please try again.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
header("Location:main-page.php");
?>
You can send query to the main-page.php , like this
header("Location:main-page.php?status=success");
in the main-page.php, you can get it, link this
$status = isset($_GET["status"]) ? $_GET["status"] : null
this worked
main-page.php
<?php
if(isset($_GET['status']) AND $_GET['status'] == 'success'){
echo '<div class="alert alert-info alert-dismissible fade show" role="alert">
<strong>Holy guacamole!</strong> You should check in on some of those fields below.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}elseif(isset($_GET['status']) AND $_GET['status'] == 'fail'){
echo '<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>Holy guacamole!</strong> You should check in on some of those fields below.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}else{
echo '<div class="alert alert-info alert-dismissible fade show" role="alert">
<strong>Holy guacamole!</strong> You should check in on some of those fields below.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
?>
add.php
$run_sql = mysqli_query($conn, $sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error($conn), E_USER_ERROR);
if ($run_sql===true){
move_uploaded_file($tmp_profile_img,"upload/$profile_img");
header("Location:main-page.php?status=success");
}
else{
header("Location:main-page.php?status=fail");
}
but I don't know if it's a clean code
I am making a blood donation system where user donates blood on a date, The specific date is saved in the DB now after 90 days I want to enable his status so that user can donate blood again, How can I compare the saved date compare it with today so that exactly user can donate blood again.
I already tried
#if ($donationDate == \Carbon\Carbon::now()->subMonths(3))
<div class="alert alert-success" role="alert">
<strong>Donate Now</strong>
</div>
#else
<div class="alert alert-danger" role="alert">
<strong>Sorry you cannot donate blood</strong>
</div>
#endif
and also
#if ($donationDate >= \Carbon\Carbon::now()->subMonths(3))
<div class="alert alert-success" role="alert">
<strong>Donate Now</strong>
</div>
#else
<div class="alert alert-danger" role="alert">
<strong>Sorry you cannot donate blood</strong>
</div>
#endif
and other $donationDate->greaterThanEqual(\Carbon\Carbon::now())
nothing is working
You can do it like this.
#if ($donationDate >= date('Y-m-d', strtotime('-90 days')))
<div class="alert alert-success" role="alert">
<strong>Donate Now</strong>
</div>
#else
<div class="alert alert-danger" role="alert">
<strong>Sorry you cannot donate blood</strong>
</div>
#endif
Don't know but this is working for Now! 😅
#if(\Carbon\Carbon::today()->subDays(90) >= $donationDate)
<div class="alert alert-success" role="alert">
<strong>Donate Now</strong>
</div>
#else
<div class="alert alert-danger" role="alert">
<strong>Sorry you cannot donate blood</strong>
</div>
#endif
I am facing a problem which in my code the error div loads earlier before it shows the error . could someone please help me to fix that
this is my view file
<div class="alert alert-danger mg-b-0" role="alert">
<?php echo form_error('index'); ?>
<?php
if(isset($error)){
echo 'Your Index number is not registered with our system[enter image description here][1]' .
'<br />'.'Click here to Register'.
'<br />';
}else{
'<br />';
}
?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
here is the screenshot of this
you already printed the alert before the check so if there is no $error it will already show an empty alert, you have to check first then echo your whole divs inside:
<?php if (isset($error)): ?>
<div class="alert alert-danger" role="alert">
<?php echo $error ?> <!-- or write whatever you want -->
</div>
<?php endif ?>
Hello friends I have a form when i enter correct value and pressing submit button i am getting success message
if i am entering wrong value then
i am not getting error message please suugest something
Controller
if($getHours <= 16)
{
DB::table('labors')->insert($labors_data);
session::flash('status', 'Labor Timesheet Added Successfully');
return Redirect:: to('ViewLaborD2S');
}
else
{
session::flash('status', 'You have entered More than 16 Hours');
return Redirect:: to('ViewLaborD2S');
}
View
#if (session('status'))
<div class="alert alert-success">
<p style="text-align:center;">{{ session('status') }}</p>
</div>
#else(session('message'))
<div class="alert alert-danger">
<p style="text-align:center;">{{ session('message') }}</p>
</div>
#endif
I want to show Success message if i entered correct value
and if i enter wrong value show error message
Try this:
#if (Session::has('status'))
<div class="alert alert-success">
<p style="text-align:center;">{{ Session::pull('status') }}</p>
</div>
#endif
First of all, I made research but couldn't find anything about it.
I'm sending flash data to users when they update or add something. My controller file's related part is like this;
function hizmet_ekle()
{
if($this->mhizmetler->hizmet_ekle())
{
$this->session->set_flashdata('ok', 'hizmet sisteme eklendi!');
redirect('panel/hizmetler');
}
else
{
$this->session->set_flashdata('hata', 'Bir hata oluştu. Lütfen tekrar deneyin!');
redirect('panel/hizmetler');
}
}
And my view's related parts are like this;
<?php if($this->session->flashdata('ok')): ?>
<div class="alert alert-success fade in widget-inner">
<button type="button" class="close" data-dismiss="alert">×</button>
<i class="fa fa-check"></i> <?php echo $this->session->flashdata('ok');?>
</div>
<?php endif; if($this->session->flashdata('hata')): ?>
<div class="alert alert-danger fade in widget-inner">
<button type="button" class="close" data-dismiss="alert">×</button>
<i class="fa fa-times"></i> <?php echo $this->session->flashdata('hata');?>
</div>
<?php endif; echo validation_errors('
<div class="alert alert-danger fade in widget-inner">
<button type="button" class="close" data-dismiss="alert">×</button>
<i class="fa fa-times"></i> ', '
</div>'); ?>
My system has a few different languages, it means I have to send different notification messages(session flashdata's) for each language but I can't use lang key in my controller file. How can I handle it?
Thanks in advance.
I found it!
I have to use it like this;
$this->session->set_flashdata('ok', $this->lang->line("greek"));