vibhaJ 126 Master Poster
$db=mysql_select_db("qserves1_uksurvey", $con);
$sql =  "SELECT * FROM forms WHERE Number='".$_POST['Number']."'";
$res = mysql_query($sql, $con) or die (mysql_error());
if(mysql_num_rows($res)>0)
{
	echo 'forms already exist with number:'.$_POST['Number'];
	exit;
}
else
{
	$sql="INSERT INTO forms (date, Receivingsky, Title, Firstname, Lastname, House, Street, Town, County, Postcode, Number, WarrantyCoverForSky, Tvmake, Warrantycover, Payingmonthly, Agentnotes, Agentname)
	VALUES
	(NOW(),'$_POST[Receivingsky]','$_POST[Title]','$_POST[Firstname]','$_POST[Lastname]','$_POST[House]','$_POST[Street]','$_POST[Town]','$_POST[County]','$_POST[Postcode]','$_POST[Number]','$_POST[WarrantyCoverForSky]','$_POST[Tvmake]','$_POST[Warrantycover]','$_POST[Payingmonthly]','$_POST[Agentnotes]','$_POST[Agentname]')";
	$sql_result = mysql_query($sql, $con) or die (mysql_error());

}

Same with second table.
Try it and let me know still there is no fix.

vibhaJ 126 Master Poster

There is ';' after if condition line# 6.Remove it.
What you exactly want?
you want to replace </div> with <br> tag?

vibhaJ 126 Master Poster

You don't need below code.It is generating problem.
Remove it and then run.

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
vibhaJ 126 Master Poster

Have some patience and dont repeat thread... :)

vibhaJ 126 Master Poster

below is code.
with the help of in_array function.

<?
	$childarr = explode(",", $row["children_pref"]);	
?>
<input type="checkbox" name="children_pref[]" value="0" <?=(in_array('0',$childarr))?('checked'):('');?> >None<br>
<input type="checkbox" name="children_pref[]" value="1" <?=(in_array('1',$childarr))?('checked'):('');?>> 1<br>
<input type="checkbox" name="children_pref[]" value="2" <?=(in_array('2',$childarr))?('checked'):('');?>> 2<br>
<input type="checkbox" name="children_pref[]" value="3" <?=(in_array('3',$childarr))?('checked'):('');?>> 3<br>
<input type="checkbox" name="children_pref[]" value="4" <?=(in_array('4',$childarr))?('checked'):('');?>> 4<br>
<input type="checkbox" name="children_pref[]" value="5" <?=(in_array('5',$childarr))?('checked'):('');?>> 5<br>
<input type="checkbox" name="children_pref[]" value="6" <?=(in_array('6',$childarr))?('checked'):('');?>> 6 or more<br>
vibhaJ 126 Master Poster

I use this code found from one forum.
Hope this helps you.

<?php
if (!isset($_POST["timezoneoffset"])){
?>
 <form method="post" action="<?php echo $_SERVER["PHP_SELF"];  ?>" id="time_form" name="time_form">
 <script type="text/javascript">
  tzo = - new Date().getTimezoneOffset()*60;
  document.write('<input type="hidden" value="'+tzo+'" name="timezoneoffset">');
 </script>
 <input type="submit" value="Get Server Client TimeZone Difference" name="Ok">
 </form>
<?php
}else{
 $serverTimezoneOffset = (date("O") / 100 * 60 * 60);
 echo 'Server Timezone Offset : ' . ($serverTimezoneOffset/(60*60)) .' hours';
 echo '<br />';
 $clientTimezoneOffset = $_POST["timezoneoffset"];
 echo 'Client Timezone Offset : ' . ($clientTimezoneOffset/(60*60)) .' hours';
 echo '<br />';
 $serverTime = time();
 echo 'Server date time : ' . strftime("%d %b %Y %H:%M", $serverTime);
 echo '<br />';
 $serverClientTimeDifference = $clientTimezoneOffset-$serverTimezoneOffset;
 $clientTime = $serverTime+$serverClientTimeDifference;
 echo 'Client date time : ' . strftime("%d %b %Y %H:%M", $clientTime);
 echo '<br />';
 echo 'Difference : ' . ($serverClientTimeDifference/(60*60)) . " hours";
 echo '<br />';
}
?>
vibhaJ 126 Master Poster

First code: use window.location.href

<head>
<script type="text/javascript">
function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  window.location.href = 'index.php?width=' + myWidth+'&height='+myHeight;
 }

</script>
</head>

<body onLoad="alertSize();">
<a href="#">Go to Album</a>
</body>

Second Code: use $_GET to get url variable.

echo '<td width="'.$cellwidth.'%" align="center"><a href="view2.php?id='.$index.'"&height='.$_GET['myHeight'].'&width='.$_GET['myWidth'].'><img src="./thumb/'.$dirArray[$index].'" width="90%" alt="Smile"></td>';
vibhaJ 126 Master Poster

Where is the select query for question table?
Post that query and also any error is you getting.

vibhaJ 126 Master Poster

This code return array of emails.

<?
	$str = '"ceo@facekut.com" <ceo@facekut.com>,"Rahul Mahajan" <creative.rahul007@gmail.com>';
	$pattern = '/<([^"]*)>/';
	preg_match_all($pattern, $str, $matches, PREG_OFFSET_CAPTURE, 3);	
	foreach($matches[1] as $val)
	{
		foreach($val as $key=>$each)
		{
			if($key==0)
				$email[]=$each;
		}
	}
	print_r($email);
	
	
?>
dalip_007 commented: Vibha is exceptionally excellent. +2
vibhaJ 126 Master Poster

Use this code to remain selected last value.

<option <?=($_REQUEST['wex']==$category_arr['experience'])?('selected'):('');?> value="<?=$category_arr['experience']?>"><?=$category_arr['experience']?></option>
vibhaJ 126 Master Poster

Welcome.. make this thread solved :P

vibhaJ 126 Master Poster

Post complete error with line number. and check what is exact written there on given line number.

vibhaJ 126 Master Poster

And this way you can call it...

$catAll = catArray(0,1,'&sdot;&sdot;&sdot;&sdot;&sdot;');
echo '<pre>';
print_r($catAll);
vibhaJ 126 Master Poster

I have made this function after mane efforts.
This will surely help you.
select is a function which will return two dimension array from query.

function catArray($id,$dash,$separate='__')
{
	$resCat = select("select * from category where parentId=".$id);
	for($i=0;$i<count($resCat);$i++)
	{
		$con='';
		for($j=1;$j<$dash;$j++)
			$con.=$separate;
		$arr[$resCat[$i]['categoryId']] = $con.$resCat[$i]['name'];
		
		$temp = select("select * from category where parentId=".$resCat[$i]['categoryId']);
		if(count($temp)>0)
		{	
			$dash++;
			$res = catArray($resCat[$i]['categoryId'],$dash,$separate);						
			$arr = $arr + $res;						
			$dash--;					
		}
	}
	return $arr;
}

Let me know output.

vibhaJ 126 Master Poster

can you please post code!

vibhaJ 126 Master Poster

Remove isset from $_REQUEST in delete code.

$checkbox = $_REQUEST['checkbox'];
$countaa = count($checkbox);
vibhaJ 126 Master Poster
$("#idtext").change(function(){			
		$('.alltr').hide();		
		$('div[id*="'+$("#idtext").val()+'"]').show();	
});

I think this should work.

vibhaJ 126 Master Poster
vibhaJ 126 Master Poster
vibhaJ 126 Master Poster

Give class 'alltr' to all tr.
And then try below code.

$("#idtext").change(function(){			
		$('.alltr').hide();		
		$('#'+$("#idtext").val()).show();		
});
vibhaJ 126 Master Poster

Here is your query.

SELECT name,SUBSTRING(name,1,LOCATE('_',name)-1) FROM `student`
vibhaJ 126 Master Poster

Your question is unclear.
You just want to change or hide extension of file on website?

vibhaJ 126 Master Poster

Why don't you try php code.

<?
	$temp = explode('_', $option);
	unset($temp[count($temp)]);
	$option = implode('_', $temp);	
?>
vibhaJ 126 Master Poster

'select' tag can not have value.
Value is only for 'option'.
When form is submitted add this php code to debug it.
echo $_POST; exit;

vibhaJ 126 Master Poster

foreach takes array as an argument.
$values must be an array.echo $value and you will know that.
html field name should be 'check[]' will make $values an array.

vibhaJ 126 Master Poster

Thanks Kraai for guidance.
I am curious to know if bots can read captcha or not?
As captcha is a image so do they have image reader or something else?

vibhaJ 126 Master Poster

Hi Friends,

I am having one contact-us php script.
Here i have used php mail function to send email to admin.
Even-though i have also used captcha coding, admin is still continuously getting spam (dummy texts) contact us emails.
Actually I am not sure how spammers do such activity.
If i use authentication email rather than simple mail function, does it work?
How can i stop such emails?

Any guidance will be appreciated.
Thanks,
Vibha

vibhaJ 126 Master Poster
//Accesses users
$query = mysql_query("SELECT * FROM users WHERE login='$username'");
//Checks if users do not exist (Checks rows)
if($query)
{
	$num_result = mysql_num_rows($query);
	echo $num_result;
}
else
{
	echo 'No result in select query';
	exit;
}

Try this and post output.

vibhaJ 126 Master Poster

Yes ardav,i have to use template.
And it is editable in admin side ckeditor.
My coding is in core php not any framework.
Do you have any logic?

vibhaJ 126 Master Poster

Hi,
First of all you need email access information of accounts you want to grab.
It can be done using PHP IMAP.
Check this link
Once you have emails in php variables insert into your mysql database.
Hope this helps.

GreaseJunkie commented: Dead-on response to my needs! +1
vibhaJ 126 Master Poster

Hello All,

I am having one email template code as shown below.

<table width="400" border="0">
  <tr>
    <td><strong>Id</strong></td>
    <td><strong>Name</strong></td>
    <td><strong>Address</strong></td>
  </tr>
  <tr>
    <td>##ID##</td>
    <td>##NAME##</td>
    <td>##ADDRESS##</td>
  </tr>
</table>

Site administrator manage this.
Now i want php code to dynamic replace ##key## code.
It is simple for one record but here it is in table format. So m not able to clear it.
Once php code runs it check in database and outputs like as below:

<table width="400" border="0">
  <tr>
    <td><strong>Id</strong></td>
    <td><strong>Name</strong></td>
    <td><strong>Address</strong></td>
  </tr>
  <tr>
    <td>1</td>
    <td>Ria</td>
    <td>abc</td>
  </tr>
  <tr>
    <td>2</td>
    <td>Tom</td>
    <td>mno</td>
  </tr>
  <tr>
    <td>3</td>
    <td>John</td>
    <td>pqr</td>
  </tr>
</table>
vibhaJ 126 Master Poster

Try to debug your code.
Add below code at line#11

echo $itemsql; exit;

Use that query and run in phpmyadmin.
Check output result.

vibhaJ 126 Master Poster

Check this code..
let me know output.

<?
	$sqlQuery=mysql_query("select * from tbl_page_detail where page_name='Home'");
	$sqlArr=mysql_fetch_array($sqlQuery);
	$cat = $sqlArr['page_cat'];
	
	$sql = "select * from tbl_category where cat_id IN ($cat)";
	$res = mysql_query($sql);
	$str = '';
	while($sar = mysql_fetch_assoc($res))
	{
		$str.=','.$sar['cat_name'];
	}
	echo 'Category Names : '.$str;
?>
vibhaJ 126 Master Poster

1) when you save news also save expire date in database.e.g.
<?
$expDate = date('Y-m-d H:i:s', mktime(date("H"), date("i"), date("s"), date("m") , date("d")+7, date("Y"))); // expire after 7days
?>
2) where ever you are showing news in select query filter expire date for fetching news from db.e.g.
<?
$currDate = date('Y-m-d H:i:s');
$sql ="select * from news where expDate<='".$currDate."'";
?>

vibhaJ 126 Master Poster

Heres a code:
Try it...

<script language="javascript" type="text/javascript">
function toggleMe(val) 
{
	var designation = document.getElementById('designation');
	var organization = document.getElementById('organization');
	if(val=='Trainee')
	{
		designation.style.display = "none";
		organization.style.display = "none";
	}
	else
	{
		designation.style.display = "block";
		organization.style.display = "block";
	}
}
</script>
   
<select name="select" onchange="toggleMe(this.value)">   
    <option value="0">Select any one</option> 
    <option value="Trainee">Trainee</option>  
    <option value="Product">Product</option> 
</select>
      
<input name="designation" type="text" id="designation" />
<input name="organization" type="text" id="organization" />
vibhaJ 126 Master Poster

@cereal : yes you are right.. apart from phpmyadmin do you have any idea how can i can achieve it in my php login page.(i dont want user to remember password in browser)
@ardav : keepass is cool.. i will use it now onwards.

vibhaJ 126 Master Poster

Hello All,

I wand Firefox to remember my password when i login in phpmyadmin.
But Firefox doesn't ask me to 'Remember password'.
When i inspect phpmyadmin form using developer tool, i done see any trick.

Secondly i also want in my website coding that when user log in Firefox don't ask for save password.How to do that?

Any suggestions?

vibhaJ 126 Master Poster

Here i have written complete code.
Try it, its easy to understand.

<?
	mysql_connect('localhost','root','');
	mysql_select_db('test');	
	
	if(isset($_REQUEST['delete']))
	{
		$deleteCb = $_REQUEST['deleteCb'];
		for($i=0;$i<count($deleteCb);$i++)
		{
			$news_id = $deleteCb[$i];
			$q = "delete from newslist where news_id= ".$news_id;
			mysql_query($q);		
		}
		header("location:test.php");
		exit;
	}
?>
<form name="form" id="form" method="post">
<table width="400" border="1" cellspacing="0" cellpadding="0">
<?
	$q="select * from newslist";
	$rs = mysql_query($q);		
	if(mysql_num_rows($rs))
	{
?>
	<tr>
		<td>Delete</td>
		<td>Title</td>
	</tr>
<?
	while($sar = mysql_fetch_assoc($rs))
	{
?>	
	<tr>
		<td><input name="deleteCb[]" type="checkbox" value="<?=$sar['news_id'];?>" /></td>
		<td><?=$sar['title'];?></td>
	</tr>
<? } ?>
	<tr>
		<td><input name="delete" value="Delete Selected" type="submit" /></td>
		<td>&nbsp;</td>
	</tr>	
<?	}
	else
	{
?>
	<tr>
		<td></td>
		<td>No result found</td>
	</tr>
<? } ?>		
</table>
</form>
vibhaJ 126 Master Poster

post your list.txt content.
Will give you exact code to create drop down from that file.

vibhaJ 126 Master Poster

Your while loop is not proper.
See below code.

elseif(isset($_POST['EventId'])){

	require_once('database.php');
	$Search=$_POST['Search'];
	$query="select * from participation where EventId ='$Search'";
	$result=mysqli_query($dbc,$query) or die('Not Connected');
	while($row=mysqli_fetch_array($result))
	{
		$LoginId= $row['LoginId'];
		echo $LoginId;
		$query="select * from registration where LoginId='$LoginId'";
		$resultReg=mysqli_query($dbc,$query) or die('Not Connected to Reg');
		while($rowReg=mysqli_fetch_array($resultReg))
		{
			echo "<table border='2'><tr><td> Name--".$rowReg['Name']."</td>
			<td>Contact Number--".$rowReg['ContactNumber']."</td>
			<td>Email--".$rowReg['Email']."</td>
			<td>Address--".$rowReg['Address']."</td></tr></table>";
		}
	}
}
vibhaJ 126 Master Poster

You can identify exact mysql error by using below code.

$result=mysqli_query($dbc,"insert into events (Title,City,Content,Photo,Date) values ('$Title','$City','$Content','$path','$Date')") or die(mysql_error());

Exact error will guide you.

vibhaJ 126 Master Poster

Don't call user_login function in login.php.
Just remove function user_login from all.
I think you can not redirect within a php function like this so avoid it.

vibhaJ 126 Master Poster

Why are you usign function for login?
You can direct do below:

<?php session_start(); 
mysql_connect("localhost", "dbuser", "dbpassword"); 
mysql_select_db("myDB");

if (isset($_POST['username']) && isset($_POST['pword']))
{
	
	$username = mysql_real_escape_string($_POST['username']); 
	$password = md5( mysql_real_escape_string($_POST['pword']) );
	$sql = mysql_query("SELECT * FROM usersystem WHERE username = '$username' AND password = '$password' LIMIT 1"); 
	$rows = mysql_num_rows($sql); 
	
	if ($rows<1)
	{ 
	echo "&serverResponse=Incorrect username/password"; 
	}
	else 
	{
	$result = mysql_query("SELECT total FROM usersystem WHERE username = '$username'") or die( mysql_error() );
	$row=mysql_fetch_assoc($result);
	$total = $row['total'];
	header( "Location: play.php" ) ;
	setcookie("username", "$username", time()+3600);
	setcookie("total", "$total", time()+3600);
	$_SESSION['username'] = $username;
	
	
	} 
}
?>

Reason for checking play.php is below:
Sometimes it happens that you have successfully login but in your protected page say play.page session is not set because of any reason, then even user is rediretd to play.php he is again thrown to login page.
I have this scenario in past so i asked you to check.

vibhaJ 126 Master Poster

Also try below debugging.
echo "SELECT * FROM usersystem WHERE username = '$username' AND password = '$password' LIMIT 1"; exit;
Run that output in phpmyadmin sql tab. Just crosscheck query returns result.

vibhaJ 126 Master Poster

so issue is with play.php page.Post its code here.

And also try print_r($_SESSION); exit; after session _start(); function on play.php.Which will show sessions available on that page.

vibhaJ 126 Master Poster

Debug code using:
echo $mail_body = $htmlContent; exit;

See what you have in browser.

coxdabd commented: Perfect reply, great solution to my problem. +1
vibhaJ 126 Master Poster

Why dont you try jquery.
Its easy to use.
Check this code.

<html>
<body>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js">
<script language="javascript" type="text/javascript">
function ajaxFunction(age,wpm,sex)
{
	$.ajax({
	  url: 'example.php?age='+age+"&wpm="+wpm+"&sex="+sex,
	  success: function(data) {
		$('.ajaxDiv').html(data);    
	  }
	});
}
</script>
<input type='button' onclick='ajaxFunction(1,2,3)' value='Query MySQL' />
<div id='ajaxDiv'></div>
</body>
</html>
vibhaJ 126 Master Poster

You mean user is not redirected to play.php even he is valid user?

<?
{
$username = mysql_real_escape_string($username); 
$password = md5( mysql_real_escape_string($password) );
$sql = mysql_query("SELECT * FROM usersystem WHERE username = '$username' AND password = '$password' LIMIT 1"); 
$rows = mysql_num_rows($sql); 

	if ($rows<1)
	{ 
		echo "&serverResponse=Incorrect username/password"; 
	}
	else 
	{
		setcookie("username", "$username", time()+3600);
		$result = mysql_query("SELECT total FROM usersystem WHERE username = '$username'") or die( mysql_error() );
		$row=mysql_fetch_assoc($result);
		$total = $row['total'];
		setcookie("total", "$total", time()+3600);
		$_SESSION['username'] = $username;
		
		header( "Location: play.php" ) ;
		exit;
	} 
}
?>

Add echo 'hi';exit; in first line of play.php. Post your output.

vibhaJ 126 Master Poster

Check this page, if it helps you.
If you dont want to show button on print then call printpage function on body tag onload.

<html>

<head>
 <title>New Page 1</title>
<script language="javascript">
 function printpage()
  {
   window.print();
  }
</script>
</head>

<body>

<form>
 <input type="button" value="Print" onclick="printpage();">
</form>
</body>

</html>
vibhaJ 126 Master Poster

Check with this code. What it alerts?

$.post("ajax.php", { Name:'doodle', Fathers_name:'anything' }, 
    function(data){
        alert(data);
    }
);