Information not being submitted into the database - php

I'm not quite sure what's going on, I've done almost everything I can think of to try and resolve this issue but I'm still stuck where I left off.
So the recovery questions are being submitted into the DB but when you are set to cancel them the cancel value doesn't change whatsoever.. I'm absolutely confused.
<?php
/*
* #CANCEL
* ~~~~~~~~~~~~
* #FILE DESCRIPTION: Cancels set recovery questions
* #LAST MODIFIED: August 29, 2015
*/
require('../includes/config.php');
require('../structure/database.php');
require('../structure/base.php');
require('../structure/user.php');
$database = new database($db_host, $db_name, $db_user, $db_password);
$base = new base($database);
$user = new user($database);
//get config settings from db
$config = $base->loadConfig();
//set some basic vars
$username = $user->getUsername($_COOKIE['user'], 2);
$rank = $user->getRank($username);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:IE>
<head>
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<title><?php
echo $data['wb_title'];
?></title>
<link href="../css/basic-3.css" rel="stylesheet" type="text/css" media="all">
<link href="../css/main/title-5.css" rel="stylesheet" type="text/css" media="all">
<link href="../css/kbase-2.css" rel="stylesheet" type="text/css" media="all" />
<link rel="shortcut icon" href="../img/favicon.ico" />
<?php
include('../includes/google_analytics.html');
?>
<style>
fieldset {
text-align: left;
border: 2px solid #625437;
width: 95%;
position: relative;
margin: 10px;
padding-left: 10px;
background-color:transparent;
}
legend {
color: #625437;
font-weight: bold;
font-size: 15px;
}
</style>
<script type="text/javascript">
function goBack()
{
window.history.back();
}
</script>
</head>
<div id="body">
<?php
$base->getNavBar($username, $path, $rank);
?><br/><br/>
<br/><br/>
<div style="text-align: center; background: none;">
<div class="titleframe e">
<b>Cancel recovery questions</b><br />
Main Menu
</div>
</div>
<img class="widescroll-top" src="../img/scroll/backdrop_765_top.gif" alt="" width="765" height="50" />
<div class="widescroll">
<div class="widescroll-bgimg">
<div class="widescroll-content">
<?php
if (!$user->isLoggedIn()) {
echo 'You must be logged in to access this content.';
} else {
$info = $database->processQuery("SELECT `cancel` FROM `recoveries` WHERE `userid` = ?", array($user->getUserId($_COOKIE['user'])), true);
//if ($database->getRowCount() == 1) {
//echo 'You need to have recovery questions in order to cancel them. You can set them here or return to the homepage.';
if ($info[0]['cancel'] >= 1) {
echo 'Your recovery questions have already been set to cancel.';
} elseif (isset($_GET['confirm'])) {
//cancel the recovery questions
$database->processQuery("UPDATE `recoveries` SET `cancel` = ? WHERE `userid` = ?", array(
time(),
$user->getUserId($_COOKIE['user'])
), false);
echo '<center>Your recovery questions have successfully been set to cancel.<br><center>Main page</center>';
} else {
?>
<b>Are you sure you wish to cancel your recovery questions?</b> Once you confirm this action your recovery questions will be active
for another two weeks, after that they will be deleted.<br><br> This action can be reversed by clicking the "Set recovery questions" link on the website homepage.
<br/><br/>
<center>I wish to continue | I wish to go back</center>
<?php
}
}
?>
<center><img src="../img/kbase/scroll_spacer.gif" ></center>
<div style="clear: both;"></div>
</div>
</div>
</div>
<img class="widescroll-bottom" src="../img/scroll/backdrop_765_bottom.gif" alt="" width="765" height="50" />
<div class="tandc"><?php
echo $data['wb_foot'];
?></div>
</div>
</body>
</html>
As for this being commented out
//if ($database->getRowCount() == 1) {
//echo 'You need to have recovery questions in order to cancel them. You can set them here or return to the homepage.';
It's because if it is, when the page is loaded that's all that shows...nothing else, even if the recovery options are set in the database.
Any ideas? really stuck here.

Related

some problem with session in php with id?

when i logging in with user and pass session id not activate in site in wamp worked but when i uploaded to 000webhost not working i wnat solution for my problem and this my code
index.php
<?php
session_start();
include 'connection.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Tekkadan</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Baloo">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
body {
font-family: 'Baloo', cursive !important;
}
h3{
font-family: 'Baloo', cursive !important;
}
b{
font-family: 'Baloo', cursive !important;
}
.mySlides {display: none}
</style>
</head>
<body>
<!-- Navbar -->
<div class="w3-top">
<div class="w3-bar w3-black w3-card">
<a class="w3-bar-item w3-button w3-padding-large w3-hide-medium w3-hide-large w3-right" href="javascript:void(0)" onclick="myFunction()" title="Toggle Navigation Menu" ><img src="sidr.png" style="height: 30px;width: 30px;background-color: #841818;"></i></a>
HOME
<?php if(empty($_SESSION['sess_guild'])){?>
تسجيل دخول
<?php }else{?>
الجيني
البروفايل
تسجيل خروج
<?php } ?>
<?php if(!empty($_SESSION['sess_auth'])){
if ($_SESSION['sess_auth']=="admin" || $_SESSION['sess_auth']=="co" || $_SESSION['sess_auth']=="giny" || $_SESSION['sess_auth']=="warning") {?>
الادمن
<?php }} ?>
</div>
</div>
<!-- Navbar on small screens (remove the onclick attribute if you want the navbar to always show on top of the content when clicking on the links) -->
<div id="navDemo" class="w3-bar-block w3-black w3-hide w3-hide-large w3-hide-medium w3-top" style="margin-top:46px">
HOME
<?php if(empty($_SESSION['sess_guild'])){?>
تسجيل دخول
<?php }else{?>
الجيني
الادمن
تسجيل خروج
البروفايل
<?php } ?>
</div>
and proccess of login.php
<?php
include 'connection.php';
session_start();
if(empty($_SESSION['sess_guild'])){
$user=$_POST['user'];
$pass=$_POST['pass'];
$sql = mysqli_query($conn,"SELECT * FROM users WHERE user ='".$user."' AND pass='".$pass."' ");
$row = mysqli_fetch_assoc($sql);
$numrows = mysqli_num_rows($sql);
if ($numrows == 0) {
echo "invaild pass or user";
}else{
$_SESSION['sess_user']=$row[user];
$_SESSION['sess_guild']=$row[guild];
$_SESSION['sess_auth']=$row[authiroty];
if ($_SESSION['sess_guild'] == "forever") {
$sqla="SELECT * FROM forever WHERE user='".$_SESSION['sess_user']."'";
$sqlc="SELECT COUNT(id) FROM forever ";
$forever=mysqli_query($conn,$sqlc);
$iduser=mysqli_query($conn,$sqla);
$rowuser = mysqli_fetch_assoc($iduser);
$_SESSION['sess_id']= "$rowuser[id]";
$_SESSION['sess_giny']= "$rowuser[giny]";
}
header('Location:index.php');
}elseif(!empty($_SESSION['sess_guild'])){
echo "nooooo";
}
?>
i want when user click in profile
البروفايل
i need link get the sess_id from process when click this link
or i want if click on profile get link for profile like this https://stackoverflow.com/users/11227805/rashed-kamal

How to delete data in the current page then redirecting to another page with a back button

My current page is displayitems.php. I got a button type='hidden' with a style and a background image of the button and a hidden input type='hidden .'
I can retrieve the id of the image when clicked. Whenever I click on the button (with image) it displays the the exact image of the button in another page which is userdetails.php and I got a back button that will redirect to displayitems.php.
Now my problem here is if I click another button (image) it display the past image instead of a new one can any of you delete the past image then display the current button that I click
This is my homepage
<?php
require 'header.php';
?>
<main>
<?php
require 'uploaditems.php';
echo "<br>";
require 'loginlogout.php';
echo "<div>";
require 'displayitems.php';
echo "</div>";
?>
</main>
My displayitems.php
<?php
if(isset($_SESSION['userId'])){
require "includes/dbh.php";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="style.css" type="text/css" media="screen" href="style.php"/>
<script src="main.js"></script>
<style>
.product{
border:1px solid
margin:-1px 19px 3px -1px;
padding: 10px;
text-align:center;
bacgkround-color:#efefef;
}
</style>
</head>
<body>
<?php
include_once 'includes/dbh.php';
$sql="SELECT * FROM gallery ORDER BY orderitems DESC;";
$stmt=mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)){
echo "sql statement failed in displayitems.php";
}else{
mysqli_stmt_execute($stmt);
$result=mysqli_stmt_get_result($stmt);
if(mysqli_num_rows($result)>0){
while($row=mysqli_fetch_assoc($result)){
?>
<div class="col-md-3">
<form method="POST" action="userdetails.php">
<input type="hidden" name="hiddenId" value=<?php echo $row['idGallery'];?>>
<div class="product" style="float: left;">
<button type="hidden" name='displaydetails'
style='background-
image:url(images/<?php echo $row['imgFullNameGallery'];?>
);width:150px; height:200px; margin:auto; background-size:100% 100%; b
ackground-repeat:no-repeat;>
</button>
</form>';
<br>
<br><br><h3><?php echo $row['nameitem']?></h3>
<h3><?php echo $row['price']?></h3>
<br>
</div>
</div>
<?php
}
}
}
}
?>
</body>
</html>
and my userdetails.php
<?php
session_start();
if(isset($_POST['displaydetails'])){
if(isset($_SESSION['userId'])){
This is how I got the hidden id of the image
$idofimg=$_POST['hiddenId'];
require 'includes/dbh.php';
And i've created a query where I want all the data of the hidden id
$sql="SELECT * FROM gallery WHERE idGallery=? ;";
$stmt=mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)){
echo "sql statement failed in displayitems.php";
}else{
mysqli_stmt_bind_param($stmt,'i',$idofimg);
mysqli_stmt_execute($stmt);
$result=mysqli_stmt_get_result($stmt);
if(mysqli_num_rows($result)>0){
while($row=mysqli_fetch_assoc($result)){
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-
scale=1">
<link rel="stylesheet" type="text/css" media="screen"
href="main.css" />
<script src="main.js"></script>
</head>
<body>
<img src="images/<?php echo $row['imgFullNameGallery'];?>" style
=width:330px; height:300px; margin:auto; background-size:100% 100%;
background-repeat:no-repeat;>
<div>
<h3>Details</h3>
<table>
<tr>
<td>Condition:</td>
<td>ha</td>
</tr>
</div>
This is where I want to put my condition where I will delete all this current data and go back to index2.php and then when clicked another image button it will display the current image not the past image
<form action='index2.php' method='POST'>
<button type='submit'>BACK</button>
<?php
$count=1;
?>
</form>
<?php
}
}
}
} else{
echo "fail";
}}
?>
</body>
</html>
here in my displayitems.php my input type="hidden" name="hiddenId" value=> is only getting 1 value when the button type="hidden" name='displaydetails'> is not getting any value when clicked. So when I go to userdetails.php it only display 1 details because of the input type. so I should remove the input type in displayitems.php and just give the button a value so whenever it was click it will generate a new id and display also a new details.
just change this to displayitems.php
<input type="hidden" name="hiddenId" value=<?php echo $row['idGallery'];?>>
<div class="product" style="float: left;">
<button type="hidden" name='displaydetails'
style='background-
image:url(images/<?php echo $row['imgFullNameGallery'];?>
);width:150px; height:200px; margin:auto; background-size:100% 100%; b
ackground-repeat:no-repeat;>
</button>
to this
<div class="product" style="float: left;">
<button type="hidden" name='displaydetails' value=<?php echo
$row['idGallery'];?>
style='background-
image:url(images/<?php echo $row['imgFullNameGallery'];?>
);width:150px; height:200px; margin:auto; background-size:100% 100%; b
ackground-repeat:no-repeat;>
</button>
and to userdetails.php
if(isset($_POST['displaydetails'])){
if(isset($_SESSION['userId'])){
$idofimg=$_POST['hiddenId'];
to this
if(isset($_POST['displaydetails'])){
if(isset($_SESSION['userId'])){
$idofimg=$_POST['displaydetails'];

PHP doesn't redirect to specific page

I tried to send password to the PHP commands. But when I echo it to check condition, it works. But if I don't echo but using headers() instead , it won't redirect if the password is correct. But if the password isn't correct, it redirects to an error page to show error.
Here is my code.
<?php
//require_once "condb.php";
?>
<?php
if (isset($_POST['BTN_ENTER']))
{
$password=$_POST['password'];
//echo $password;
if ($password == "test")
{
//echo "ok!";
header('location:survey.php');
}else
{
//echo "not ok!";
header('location:error.php');
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">
</script>
<script src="js/bootstrap.min.js"></script>
</head>
<style>
div#index
{
height: 100px;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
</style>
<body style="background-color:#4da6ff;">
<div align="center" id="index" class="row col-sm-12 col-md-6 col-lg-12 col-xs-12">
<p style="font-size:32px;color:#66ff33;">Please enter passcode.</p>
<form method="POST">
<div align="center" class="row col-sm-12 col-md-12 col-lg-12 col-xs-12"
style="margin:0 auto;">
<input type="password" class="form-control input-lg" placeholder="Please enter a passcode." style="width:40%;height:50%" name="password" autofocus><br>
</div>
<button type="submit" class="btn btn-success btn-lg" name="BTN_ENTER"
style="height:50%;width:20%;">ตกลง
</button>
</form>
</div>
Can you try this?
if ($password == "test")
{
header('Location: survey.php', true, 302);
die();
}
else
{
header('Location: error.php', true, 302);
die();
}
First thing you should use session or cookie if you want to access the value globally.
Try using javascript snippet for redirection
echo "<script>window.location='survey.php';"</script>";

My code is working on local but doesnt work in server [duplicate]

This question already has answers here:
How do I get PHP errors to display?
(27 answers)
Closed 3 years ago.
i have 6 php pages, all work perfectly on pc and on host. except one, my search.php doesn't work on host (by the way it works on pc perfectly too). Somehow when i try to run search.php i don't even get error, only thing which i get is white screen. Here my codes ;
<?php
session_start();
if(!$_SESSION['auth'])
{
echo 'bu sayfaya erişim izniniz yok.';
header("Location: uyegirisi.html");
}
?>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>First try</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<style>
li
{
display: inline;
padding: 0px 20px 0px 20px;
}
ul
{
padding:10px;
background: rgba(0,0,0,0.5);
}
a
{
color: black;
font-size: 30px;
}
p
{
color: #0f0f0f;
font-size: 24px;
font-family: Helvetica;
}
.bor
{
font-size: 23px;
border:2px;
}
.hr
{
color : #0000F8;
size : 4;
}
</style>
</head>
<body>
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4" align="center">
<header>
<ul>
<li>Kayıt ekranı</li>
<li> Çıkış Yap</li>
</ul>
</header>
<form action="musteriarama.php" method="get">
<div class="hiza">
<label for="Arama"></label>
<input type="text" class="form-control" id="Arama" name="Arama">
</br>
</br>
<input class="but btn btn-primary btn-lg" type="submit" name="gonder" value="Müşteri Ara">
</div>
</form>
</div>
<div class="col-md-4"></div>
</div>
</body>
</html>
<?php
$db =new mysqli('localhost', 'root', '' , 'musteritakip');
if($db->connect_errno) die ('Bağlantı hatası:' . $db->connect_errno);
if(isset($_GET['gonder'])){
#Ekleme işlemi
$stmt = $db ->prepare("select * from musteri_bilgileri where (isim like ?)");
if($stmt === FALSE) die("Sorgu hatası". $db ->error);
$ara ='%'.$_GET['Arama'].'%';
$stmt->bind_param("s", $ara);
$stmt->execute();
$sonuc =$stmt->get_result();
if($sonuc -> num_rows <1) die("<p>"."bulunamadı");
while ($row = $sonuc->fetch_array())
{
echo '<div>';
echo '<p>'.$row['isim'];
echo '&nbsp&nbsp ';
echo $row['soyad'];
echo '&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp';
echo '<form action="detaylar.php" method="post">';
echo'<input type="hidden" value="'.$row['id'].'" name="gelenid">';
echo '<input type ="submit" value="Detaylar" style="margin-bottom:-35px;" name="detaylargonder"></input>';
echo '<hr width="100%" >';
echo '</form>';
echo '</br>';
echo '</br>';
echo '</div>';
}
}
?>
You must have missed something while you were uploading it. You haven't clearly described what's not working or about the error, we can only advice you.Follow below steps to solve your issue:
First add error_reporting(E_ALL); ini_set('display_errors', 'On'); at top of your script.
Check the browser's console log's, it will display relevant errors.
As you are getting blank page, please check your code, you might be getting 500 internal server error when you haven't code it correctly.
Check your syntax.
Check your application & DB configuration.

How to set css at time of PDF creation in yii2?

Pdf fuction*
This function is call from ajax after getting data from this function it's call anothe file here I am display data which is coming from data base.That file all css part in style tag using then as it is style tag prind in pdf as a text and if this all css file include in css folder then pdf is not create in proper format
public function actionInvoicespacking(){
$pdf = Yii::$app->pdf;
$modelShipment = Shipment::find()->orderBy('ship_id DESC')->one();
if(count($modelShipment) == 0) {
$shipid= 1;
} else
{
$shipid= $modelShipment->ship_id;
}
$htmlContent = file_get_contents('http://localhost/shepherdlogistics_v1.0/backend/views/shipment/invoicespackingdata.php');
$pdf->content = $htmlContent;
return $pdf->render();
}
invoicespackingdata.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Invoice</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.fontawesome.min.css">
<link rel="stylesheet" href="css/stylepdf.css">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<style type="text/css">
body {
font-size: 18px;
font-family: cambria;
}
.nopadd {
padding: 0px;
}
</style>
</head>
<body>
<div class="container">
<br>
<br>
<div class="">
<div class="col-lg-2 nopadd">
<img src="logopdf.png" alt="logo" width="100%">
</div>
<div class="col-lg-10">
<h1 style="font-size: 55px;font-weight: bold; padding: 23px 0px;">
SHEPHERD LOGISTICS CO. W.L.L.</h1>
</div>
</div>
</div>
</div>
As the demo states:
Any <style> tag will be skipped (you must use cssInline property for this)
If you have just a few styles to add to the pdf, you can pass it like this:
$pdf->content = $htmlContent;
$pdf->cssInline = '.class1 {color: red} .class2 {color:blue}';
But if you have alot of styles, you can also consider change the default cssFile to any file you want with the correct css. (by default, this property is #vendor/kartik-v/yii2-mpdf/assets/bootstrap.min.css

Categories