Skip to content

Instantly share code, notes, and snippets.

View ErMandeep's full-sized avatar
🎯
Focusing

Mandeep Singh ErMandeep

🎯
Focusing
View GitHub Profile
$password = $_POST['password'];
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// Query the database for username and password
// ...
if(password_verify($password, $hashed_password)) {
// If the password inputs matched the hashed password in the database
// Do something, you know... log them in.
<?php
/**
* In this case, we want to increase the default cost for BCRYPT to 12.
* Note that we also switched to BCRYPT, which will always be 60 characters.
*/
$options = [
'cost' => 12,
];
$hash1 = password_hash("mandeep", PASSWORD_BCRYPT, $options);
@ErMandeep
ErMandeep / display alert message after redirecting page php
Created November 19, 2018 08:22
display alert message after redirecting page php
<?php
header('Location: vendor-dashboard-listing.php?success=1');
?>
// after this paste this code on that page where you have to displace success bootstrap alert message
<?php
@ErMandeep
ErMandeep / Change password in php
Created November 20, 2018 07:00
here is change password code for simple match old password and enter new password
<?php
if(isset($_POST['update_psss'])){
$oldpassword = $_POST['oldpassword'];
$newpassword = $_POST['newpassword'];
$confirmnewpassword = $_POST['confirmnewpassword'];
if ($oldpassword==$oldpassworddb){
<?php
if(isset($_POST['delete_acc']))
{
$login_id = "";
if (isset($_SESSION['id'])) {
$login_id = $_SESSION['id'];
}
if(isset($_POST['listing'])){
$listing = $_POST['listing'];
$view_vender_query1 = " DELETE FROM venders WHERE venderID= $listing";
@ErMandeep
ErMandeep / Get sum of MySQL column in PHP
Created December 1, 2018 04:22
Get sum of MySQL column in PHP
<?php
$result = mysql_query('SELECT SUM(value) AS value_sum FROM codes');
$row = mysql_fetch_assoc($result);
$sum = $row['value_sum'];
?>
<?php
if(isset($_POST['submit'])){
$img1 = pathinfo($_FILES["image"]["name"], PATHINFO_EXTENSION);
$name1 = rand(1,5000).".".$img1;
move_uploaded_file($_FILES["image"]["tmp_name"],"./images/$name1");
$sql = "UPDATE venders SET image1 = '$name1' WHERE id=2";
$query = mysqli_query($connection, $sql);
@ErMandeep
ErMandeep / Encripted image insert and fetch from database in php
Created December 6, 2018 04:24
Encripted image insert and fetch from database in php ( save image in database without upload move to any folder )
<?php
// image upload query
if(count($_FILES["image"]["tmp_name"]) > 0)
{
for($count = 0; $count < count($_FILES["image"]["tmp_name"]); $count++)
{
$image_file = addslashes(file_get_contents($_FILES["image"]["tmp_name"][$count]));
$query = "INSERT INTO images (productID, image) VALUES ('$id_guests', '$image_file')";
$result= mysqli_query($connection,$query);
@ErMandeep
ErMandeep / add to cart number increase using sweet alert
Created December 19, 2018 10:44
add to cart using session and sweet alert
<?php
if(isset($_GET['view'])){
$v_id = $_GET['view'];
}
$query = "SELECT * FROM products WHERE id = $v_id";
$select_image = mysqli_query($connection, $query);
while($row = mysqli_fetch_assoc($select_image)){
$id = $row['id'];
$product_name = $row['product_name'];
@ErMandeep
ErMandeep / fetch select option from database
Created January 11, 2019 09:34
fetch select option from database
<select class="form-control" name="product_category_id" data-placeholder="Choose a Category" tabindex="1">
<?php
$query = "SELECT * FROM category";
$select_image = mysqli_query($connection, $query);
while($row = mysqli_fetch_assoc($select_image)){
$id = $row['id'];
$cat_title = $row['cat_title'];
?>
<option value="<?php echo $cat_title; ?>" <?php if($product_category_id==$cat_title) echo 'selected="selected"'; ?>><?php echo $cat_title; ?></option>
<?php } ?>