Where is settings.inc.php in included?
In index.php OR includes.inc.php?
And what is the order of include coding?
Where is settings.inc.php in included?
In index.php OR includes.inc.php?
And what is the order of include coding?
Check this code.
<? session_start();
$sendAfter = (10)*(60); // in seconds
$sendEmail = false;
$now = date('Y-m-d H:i:s');
if(!isset($_SESSION['sent_time'])) // if you are first time send email
{
$sendMail = true;
$_SESSION['sent_time'] = $now;
}
else
{
$diff = strtotime($now) - strtotime($_SESSION['sent_time']);
if($diff >= $sendAfter)// if difference is more than 10 min then only send mail
{
$sendMail = true;
$_SESSION['sent_time'] = $now;
}
}
if($sendMail)
echo "mail sending code here";
else
echo "nothing to do";
?>
Why do you want two separate table?
You can have only one table and use number of TD you want.
Make loop proper for closing each TD & TR.
Generally if form post some data on any page, better you do all db related operations or other php coding at top of page and then redirect user to some page using header.
header('Location:index.php');
without header you may face problem.
e.g. if user POST data and you have insert query in database and if you won't have header then each time user press refresh there will be record inserted in database every time.
Mark thread solved !
check this code:
<!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>Untitled Document</title>
<script language="javascript">
function check(theForm)
{
var checker;
var checkbox = document.getElementById("tacBox");
if (checkbox.checked)
{
document.getElementById("myCheckBox").innerHTML = '<div id="mustCheck"> </div>';; // changes the innerHTML to equal the adder
checker = true;
}
else
{
document.getElementById("myCheckBox").innerHTML = '<div id="incorrect"> ***YOU MUST ACCEPT THE TERMS AND CONDITIONS*** </div>';
checker = false;
}
return checker;
}
</script>
</head>
<body>
<form name="form" id="form" onsubmit="return check(this);" >
<input id="tacBox" name="tacBox" type="checkbox" value="1" /> check box
<span id="myCheckBox"></span>
<input name="submit" value="submit" type="submit" />
</form>
</body>
</html>
Hope ID is auto increamented and primary field.
When you insert new record then its id is greater than prev.
thus if you search all results with one date and see MAX(ID), it returns last inserted row for that date.
Try with quote.
SELECT * FROM `date` WHERE date BETWEEN '2011-01-01' AND '2011-12-31'
Below is not a complete code,it is just a logic.
Try to implement at your end.
<select name="dropd" id="dropd">
<option value=""> - - Select - -</option>
<?
if(manager is logged in)
{
$res = select manager list from database
while($rs = mysql_fetch_assoc($res))
{
?>
<option value="<?=$rs['manager-id']?>"><?=$rs['manager-name']?></option>
<?
}
}
if(employee is logged in)
{
$res = select employee list from database
while($rs = mysql_fetch_assoc($res))
{
?>
<option value="<?=$rs['employee-id']?>"><?=$rs['employee-name']?></option>
<?
}
}
?>
</select>
Second approach is good. BTW m not MAN, m MISS :)
Okay.. check later and post result.
what is html code of drop down boxes?
you need to give value to option tag e.g.
<option value="2200">2200</option>
There are lots of ready available script.
Download files and try out demo.
http://barcode-coder.com/en/barcode-php-class-203.html
http://www.createwebsite.info/generating-barcodes-with-php/
http://www.mribti.com/barcode/sample.php
Check if sessions are displaying on the same page or not?
<?php
session_start();
$_SESSION['color']='red';
$_SESSION['size']='small';
$_SESSION['shape']='round';
echo '<pre>';
print_r($_SESSION);
?>
What about this:
$sql="SELECT TOTALMW,TOTALMVAR,ID FROM generators
WHERE date='2011-08-11' // search with date
ORDER BY ID desc limit 0,1";
<?
$links = array(
array("url"=>"...first.php","label"=>"first"),
array("url"=>"...second.php","label"=>"second"),
array("url"=>"...third.php","label"=>"third"),
array("url"=>"...fourth.php","label"=>"fourth")
);
$link = $links[array_rand($links)];
echo "<ul>";
echo "<li><a href=\"{$link['url']}\">{$link['label']}</a></li>";
echo "</ul>";
?>
Ohhh... you have same code 6 times..Is this code by you?
for debugging echo sql query and run it directly in database and check if you are getting desired result.
echo $sql="SELECT * from generators WHERE convert(datetime,convert(char(10),TIMESTOMPX,101))= '$search'";
exit;
I think you need group by.
check this http://vibhajadwani.wordpress.com/2011/08/03/left-join-with-limit/
Once your first row is displayed second row should be in next line.
something like
<?
$rowCnt = 6;
while($row1 = mysql_fetch_array($this->result))
{
$this->Cell($w[0], $rowCnt, $row1['tran_id'], 0, 'L', $fill);
$this->Cell($w[1], $rowCnt, $row1['account_number'], 'LR', 0, 'R', $fill);
$this->Cell($w[2], $rowCnt, $row1['transaction_type'], 'LR', 0, 'L', $fill);
$this->Cell($w[3], $rowCnt, $row1['transaction_amount'], 'LR', 0, 'L', $fill);
$this->Cell($w[4], $rowCnt, $row1['transaction_date'], 'LR', 0, 'L', $fill);
$this->Cell($w[5], $rowCnt, $row1['approved_status'], 'LR', 0, 'L', $fill);
$fill=!$fill;
$rowCnt++ ;
}
?>
Oh.. i forget you already posted html code on first post..
Can you try below one..
Use any static date which is there in database and post output..
<?php
require_once('../config/lang/eng.php');
require_once('../tcpdf.php');
// extend TCPF with custom functions
class MYPDF extends TCPDF {
public function myconnection(){
$this->con = mysql_connect("localhost","root","");
mysql_select_db("bank", $this->con);
$date = '2011-08-11'; // use any date which is there in database
$this->result = mysql_query("SELECT * FROM transaction WHERE transaction_date = '".$date."' ORDER BY tran_id") or die( '<strong>Error: </strong>'. mysql_errno().':'.mysql_error());
Post the html code where you have form fields.
Try
$date = $_POST['date'];
instead of
$date = var_dump($_POST['date']);
And also make sure date should be in proper format i.e. 20011-08-20
<script language = "Javascript">
function isValidNumber(str)
{
var tomatch= /^[0-9]{10}$/
if(tomatch.test(str))
return true;
else
return false;
}
function Validate()
{
function validateEmail(f){
if(isEmail(f.email.value)==false)
{
alert('Please enter a valid email address');
f.email.select();
return false;
}
return true;
}
function isEmail(string){
if(string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z-0-9]+((\.|-)[A-Za-z-0-9]+)*\.[A-Za-z-0-9]+$/)!=-1)
return true;
else
return false;
}
if (document.form1.first_name.value == '')
{
alert('Please fill in your first name!');
return false;
}
if(!document.form1.first_name.value.match(/^[a-zA-Z]+$/)){
alert('Please enter only string values!');
return false;
}
if (document.form1.last_name.value == '')
{
alert('Please fill in your last name!');
return false;
}
if(!document.form1.last_name.value.match(/^[a-zA-Z]+$/)){
alert('Please enter only string values!');
return false;
}
if (isEmail(document.form1.email.value) == '')
{
alert('Please enter a valid email address!');
return false;
}
if (document.form1.phone_number.value == '')
{
alert('Please fill in phone number!');
return false;
}
else
{
if(!isValidNumber(document.form1.phone_number.value))
{
alert('Please enter only numbers');
return false;
}
}
if (document.form1.user_type.value == '')
{
alert('Please fill in your user type!');
return false;
}
if (document.form1.username.value == '')
{
alert('Please fill in your desired username!');
return false;
}
if (document.form1.password.value == '')
{
alert('Please fill in your desired password!');
return false;
}
if (document.form1.confirm_password.value == '')
{
alert('Please fill in your password again for confirmation!');
return false;
}
if (document.form1.password.value !=
document.form1.confirm_password.value)
{
alert("The two passwords are not identical! "+
"Please enter the same password again for confirmation");
return false;
}
return true;
}
</script>
function validNumber(str)
{
var tomatch= /^[0-9]{10}$/
if(tomatch.test(str))
return true;
else
return false;
}
Didn't understand the logic of writing echo "0__notice__Email is empty."; and expecting Email is empty as output. Can u explain..
It may be because of un paired { or }.
Post complete code.
Also its good practice to write 'header' after php logical code.
So you can replace below code
echo "<script language='javascript' type='text/javascript'>
location.href = 'cash_transactions.php?msg=".$message."';
</script>";
with
header("location:cash_transactions.php?msg=".$message);
exit;
<?
if($row_rs_details['image_main'] == "")
$src = 'propertyimages/dot.gif';
else
$src = $row_rs_details['image_main'];
?>
<img src="<?php echo $src ?>" width="240" height="160" border="0" />
Is your both table have one to one mapping OR one to many mapping?
Also you should have primary key in both table.
If one to one mapping then check below query in phpmyadmin.
select * from account LEFT JOIN account_details ON account.account_number = account_details.account_number
You need to JOIN query for both table.
Post your table structure.
Yes.. Try to debug printed sql query in phpmyadmin.
echo $sql = "INSERTO INTO users (username) VALUES (?)"; exit;
Using php?? OR using js?
Post your code.
I have checked in IE9.. its working fine. Same view as firefox.
Whats issue?
I have made this code in past.
Hope this will help you.Add it in your code and echo query you will understand it.
You can change upto your requirement.
<?
function searchString($str,$matchAr)
{
$out = '';
$str = preg_replace('/\s\s+/', ' ', $str);
$temp = explode(' ',$str);
foreach($matchAr as $match)
{
$out.="(";
foreach($temp as $value)
{
$out.="$match LIKE '%$value%' AND ";
}
$out = substr($out,0,-4);
$out.=") OR ";
}
return substr($out,0,-4);
}
$where.=" AND (".searchString($key,array('title','name')).")";
// if user type aaa , it will match with title field and name field
// if user type aaa bbb , it will check search must contain aaa bbb both. Either in title or name.
echo $sql = "select * FROM tbl_name WHERE $where ";
?>
Ajax is used for the case:
- Once php page is loaded.
- Then we want any php stuff like database insert,update,delete,select query or any php coding without again refreshing page.
- so here we use ajax, so end user wont realize that some thing happen on server side.
- The code i have given is using jquery. Jquery is JS library, using which we can do all stuff of javascript more easily and min line of coding. Jquery have thousands of function e.h. you have used innerHTML, jquery have http://api.jquery.com/html/.
Hope this helps you.
Mark thread solved.
That is called ajax. and case 2 in my above post.
Hope you have some idea what AJAX is.
<script language="javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<script language="javascript">
function change()
{
$.ajax({ // this function will send php request in back so no need to refresh page
type: "POST",
url: "ajax.php", // in ajax.php check requested flexi variable passed from below line and write update query.
data: "flexi=flexi1",
success: function(msg){
// change html portion
}
});
}
// same for flexi2
</script>
For case 1 you don't need javascript onclick.
<?
if(isset($_POST['alloc1']))
{
$query = 'UPDATE flexi SET allocation = "allocated", user = "'.$_SESSION["username"].'" WHERE flexi="flexi1"';
$result = mysql_query($query);
$result = $_SESSION['allocate'];
header("location:page.php");// page.php is the page where you want to redirect after success update
exit;
}
if(isset($_POST['alloc2']))
{
$query = 'UPDATE flexi SET allocation = "allocated", user = "'.$_SESSION["username"].'" WHERE flexi="flexi2"';
$result = mysql_query($query);
$result = $_SESSION['allocate'];
header("location:page.php");// page.php is the page where you want to redirect after success update
exit;
}
?>
// this should be in form
<input type='button' style='float:right' name="alloc1" value='Allocate'>
<input type='button' style='float:right' name="alloc2" value='Allocate'>
You have placed this code on top.
$query1 = 'UPDATE flexi SET allocation = "allocated", user = "'.$_SESSION["username"].'" WHERE flexi="flexi1"';
$result1 = mysql_query($query1);
$result1 = $_SESSION['allocate'];
$query2 = 'UPDATE flexi SET allocation = "allocated", user = "'.$_SESSION["username"].'" WHERE flexi="flexi2"';
$result2 = mysql_query($query2);
$result2 = $_SESSION['alloc'];
That means each time page is refreshed sql query will update record.
You can do it by 2 way.
1) server side
Use submit button.
When user click on submit button page will be posted and top php code will update record. Top php code will be in if condition.
e.g.
if(isset($_POST('submit'))){ //===update query====}
2) Client side
Use Ajax.
Which meanse once user click on button you will send one ajax request to one page which will update data.
<? define('SITE_ROOT_PATH',$_SERVER['DOCUMENT_ROOT'].'testproject/')
include(SITE_ROOT_PATH.'config.php');
?>
You can add above code in any file of any directory of testproject.
Try this.
<?
$cnt = 1;
foreach($images->photos->photo as $photo)
{
if($cnt==1 || (($cnt-1)%4==0))
echo '<div>';
echo '<a href="http://flickr.com/photos/' . $flickr->username . '/' . $photo->attributes()->id . '"><img src="http://farm' . $photo->attributes()->farm . '.static.flickr.com/' . $photo->attributes()->server . '/' . $photo->attributes()->id . '_' . $photo->attributes()->secret . '_s.jpg" width="55" height="55" alt="flickr"/></a>';
if($cnt==count($images->photos->photo) || $cnt%4==0)
echo '</div>';
$cnt++;
}
?>
Debug your code with echo.
echo both select script and run it in phpmyadmin.
Post what you are getting.
<?php
if ($_POST['submit-login'])
{
$sql = "SELECT * FROM `users` WHERE
`username` = '" . mysql_escape_string($_POST['username']) . "' &&
`password` = '" . mysql_escape_string(md5(SALT_KEY . $_POST['password'] . SALT_KEY)) . "'";
echo 'First Query : <br> :'.$sql;
$user_retrieve = mysql_query($sql);
if (mysql_num_rows($user_retrieve))
{
$ur = mysql_fetch_array($user_retrieve);
$sql = "SELECT * FROM `user_sessions` WHERE `session_id` = '".mysql_escape_string($_COOKIE['PHPSESSID'])."' && `ip_address` = '".mysql_escape_string($_SERVER["REMOTE_ADDR"])."'";
echo 'Second Query : <br> :'.$sql;
exit;
$session_retrieve = mysql_query($sql);
if (mysql_num_rows($session_retrieve))
{
echo "You are already logged in. <a href='members-area.php'>Click Here</a>";
}
else
{
if (empty($_COOKIE['PHPSESSID']))
{
echo "Unknown Error, Please try enabling cookies.";
}else{
$create_session = mysql_query("INSERT into `user_sessions` (session_id, ip_address, uid) values ('".mysql_escape_string($_COOKIE['PHPSESSID'])."', '" . mysql_escape_string($_SERVER["REMOTE_ADDR"]) . "', '" . mysql_escape_string($ur['id']) . "');");
echo "You have successfully logged in. <a href='members-area.php'>Click Here</a>";
}
}
}
else
{ echo "Invalid Username or Password.";
}
}
?>
Try this code.
<!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>Untitled Document</title>
</head>
<body>
<script language="javascript">
function checkvalue()
{
var grWeight = parseInt(document.getElementById('grWeight').value);
var netWeight = parseInt(document.getElementById('netWeight').value);
var crWeight = parseInt(document.getElementById('crWeight').value);
document.getElementById('grWeight').style.backgroundColor = '#FFFFFF';
document.getElementById('netWeight').style.backgroundColor = '#FFFFFF';
document.getElementById('crWeight').style.backgroundColor = '#FFFFFF';
if(grWeight>netWeight && grWeight>crWeight)
document.getElementById('grWeight').style.backgroundColor = '#FCF964';
if(netWeight>grWeight && netWeight>crWeight)
document.getElementById('netWeight').style.backgroundColor = '#FCF964';
if(crWeight>netWeight && crWeight>grWeight)
document.getElementById('crWeight').style.backgroundColor = '#FCF964';
}
</script>
<form>
<table>
<tr>
<td width="172" class="label" > </td>
<td class="content" colspan="3" > Grwt
<input name="grWeight" type="text" class="box" id="grWeight" size="20" maxlength="255" />
ntwt
<input name="netWeight" type="text" class="box" id="netWeight" size="20" maxlength="255" />
crwt
<input name="crWeight" type="text" class="box" id="crWeight" size="20" maxlength="255" />
<input name="click" value="Click here" onclick="return checkvalue();" type="button" />
</td>
</tr>
</table>
</form>
</body>
</html>
function resizeImage($sourceFile,$destFile,$width = '',$height ='')
{
$proportional = true;
$output = 'file';
copy($sourceFile,$destFile);
$file = $destFile;
if ( $height <= 0 && $width <= 0 ) return false;
# Setting defaults and meta
$info = getimagesize($file);
$image = '';
list($width_old, $height_old) = $info;
$final_width = 0;
$final_height = 0;
$dims = getImageBound($width_old, $height_old,$width,$height);
$final_height=$dims['height'];
$final_width=$dims['width'];
if ( $width_old == $final_width && $height_old == $final_height ) return true;
# Loading image to memory according to type
switch ( $info[2] ) {
case IMAGETYPE_GIF: $image = imagecreatefromgif($file); break;
case IMAGETYPE_JPEG: $image = imagecreatefromjpeg($file); break;
case IMAGETYPE_PNG: $image = imagecreatefrompng($file); break;
default: return false;
}
# This is the resizing/resampling/transparency-preserving magic
$image_resized = imagecreatetruecolor( $final_width, $final_height );
if ( ($info[2] == IMAGETYPE_GIF) || ($info[2] == IMAGETYPE_PNG) ) {
$transparency = imagecolortransparent($image);
if ($transparency >= 0) {
$transparent_color = imagecolorsforindex($image, $trnprt_indx);
$transparency = imagecolorallocate($image_resized, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
imagefill($image_resized, 0, 0, $transparency);
imagecolortransparent($image_resized, $transparency);
}
elseif ($info[2] == IMAGETYPE_PNG) {
imagealphablending($image_resized, false);
$color = imagecolorallocatealpha($image_resized, 0, 0, 0, 127);
imagefill($image_resized, 0, 0, $color);
imagesavealpha($image_resized, true);
}
}
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $final_width, $final_height, $width_old, $height_old);
# Preparing a method of providing result
switch ( strtolower($output) ) {
case 'browser':
$mime = image_type_to_mime_type($info[2]);
header("Content-type: $mime");
$output = NULL;
break;
case 'file':
$output = $file;
break;
case 'return':
return $image_resized;
break;
default:
break;
}
# Writing image according to type to the output destination
switch ( $info[2] ) {
case IMAGETYPE_GIF: imagegif($image_resized, $output); break;
case IMAGETYPE_JPEG: imagejpeg($image_resized, $output); break;
case IMAGETYPE_PNG: imagepng($image_resized, $output); break;
default: …
Try user.username in where condition.
$result = mysql_query("SELECT user.password, data1.dob FROM user INNER JOIN data1 ON user.username = data1.username WHERE user.username = '" . $_SESSION['username'] . "'");
Just looked http://www.3gphone.in/acer/27.
CSS is working right..
Same way you have to give URL for product images.
e.g phonepics/956_1.jpg should be http://www.3gphone.in/phonepics/953_1.jpg
You can define site url in config file and append it in all images and css so if your domain transfer you have only change in config file.
Dont give relative path use absolute path while including css or images.
e.g. http://www.3gphone.in/css.css
Can you post live URL that you are referring?
No..
If you don't pass both variable you can't use brandid in coding.
There is one option just pass pname(Acer) and on top of page use select query and get brandid from database table having model 'Acer'.
And if you want SEO friendly url then you have to also save seo friendly product name in php. space is not SEO friendly.
http://www.3gphone.in/Lemon IT 20717 should be http://www.3gphone.in/lemon-it-20717
Refere this link http://htmlblog.net/seo-friendly-url-in-php/ for php function.
Okay.The rule is :
RewriteRule ^([^/]*)$ /products.php?pname=$1 [L]
http://www.3gphone.in/Acer TO http://www.3gphone.in/products.php?pname=Acer
But as i said before if you want this url you can not use brandid in coding.
Place that rule and let me know output.
RewriteEngine On
RewriteRule ^brandid/([^/]*)/([^/]*)$ /products.php?brandid=$1&pname=$2 [L]
Above code will rewrite
http://www.3gphone.in/brandid/27/Acer
to
http://www.3gphone.in/products.php?brandid=27&pname=Acer
If your coding is fetching list from brandid then you have to pass it in URL.