vibhaJ 126 Master Poster
<?
	$count = 0;
$result_stringXa = "<select>
<option value = 'lb1'>ListItem1</option>
<option value = 'lb2'>ListItem2</option>
<option value = 'lb3'>ListItem3</option>
</select>";

if(preg_match('<select>', $result_stringXa))
{
	$count++;
}
$string = $result_stringXa;
$pattern = '/<select>/';
$replacement = "<select 'lb$count'>";
echo preg_replace($pattern, $replacement, $string);

?>
vibhaJ 126 Master Poster

Try this code

$query="UPDATE $tbl_name SET Password = '".$new_Password."' WHERE Password='".$Curr_Password."' and id=$ID and Status=1";
	$result = mysql_query($query) or die('Error : '.mysql_error());

	if(mysql_affected_rows()) 
	{
		echo 'Successfully Updated';
	}
	else
	{
		echo 'Not Updated';
	}
vibhaJ 126 Master Poster

Can you post your input string and expected output string?

vibhaJ 126 Master Poster

You just want to use the array values of newvalues.php to template.php.
I am not sure if i am correct or not.
Check below code.

<?
	include('newvalues.php');
	
	echo '<h2>New Values</h2>';
	echo '<pre>';
	print_r($lang);
	
	$langTemp = array(
	'this_key'  =>  'some other value',
	'something_else_key' => 'an old value',
	'another_key'  => 'spaghettiness');
	echo '<h2>Before replace</h2>';
	echo '<pre>';
	print_r($langTemp);
	
	foreach($langTemp as $key=>$val)
	{
		$langTemp[$key] = $lang[$key];
	}
	
	echo '<h2>After replace</h2>';
	echo '<pre>';
	print_r($langTemp);
?>
vibhaJ 126 Master Poster
vibhaJ 126 Master Poster
vibhaJ 126 Master Poster

What happened??
Is this fixed???

vibhaJ 126 Master Poster
vibhaJ 126 Master Poster

You need implode function.Which will bing array into string with comma ",".

$qryInsertLeaveApplication = "INSERT INTO global_leave_replacement_application (pic_staffcode)VALUES('".implode(',',$pic_staffcode)."')";
vibhaJ 126 Master Poster

Firefox error console may give you hint.

vibhaJ 126 Master Poster

Why you are setting so much session variables?
I think your logic is messy.

Try below code if it helps you.

<?  session_start();
	// list of username and password
	$users = array("user1" =>"3202", "user2" =>"2002", "user3" =>"1061", "user4"=>"1400", "user5"=>"1001");


if( isset($_POST['username']) && isset($_POST['password']) ) // form sibmitted with username and password
{ 
	foreach($users as $username=>$password)
	{
		if($username==$_POST['username'] && $password==$_POST['password']) // check username and password is vaalid or not
		{
			$_SESSION['username'] = $_POST['username'] ; // username is correct so set session 
			$_SESSION['password'] = $_POST['password'] ; // password is correct so set session 		
			
			header("Location: home.php ");
			exit;
		}
	}
	echo "Incorrect username and password.";	// no match found
	exit;
}

?>

YeeeEE.... 500 POSTS ON DANIWEB.. M HAPPY :)

vibhaJ 126 Master Poster

No ben,
You don't have to change your php mail code.
If you are not getting emails post your code here for checking.

vibhaJ 126 Master Poster

can i set time let say that for 3 second that loading text will visible after 3 second that request has to proceee.


thanx

I would suggest you to not limit it for static 3 sec.
Because sometimes based on server speed it may differs.
I had situation in past where sometimes it takes millisecond or some times if ajax page is taking time then it may take some more seconds.
So better to not take fix 3 SECONDS.

vibhaJ 126 Master Poster

I have modified it.
If you don't have header then each time user press F5 mail will be sent.
Its always good practice to have header after form submission.

<?php
 if(isset($_POST["send"]))
 {
    // php mail sending code
	header("location:contactus.php?succ");
	exit;    
 }
?>
     <form id="form1" name="form1" method="post" action="">
    <table width="362" border="0" align="center" class="tbltxt">   
    <tr>
    <td height="30" colspan="2" style="color:#174AA8; text-decoration:underline;"><b>Send us a message!</b></td>
    </tr>
     <?php
        if(isset($_GET['succ']))
        {
    ?>
     <tr>
    <td height="30" colspan="2" style="color:#ff0000;">Mail is successfully sent.</td>
    </tr>
    <?php
       }
    ?>
    <tr>
    <td width="95" height="30"><label for="Name">Name</label></td>
    <td width="257"height="30"><input name="Name" type="text" id="Name" style="width:200px;" /></td>
    </tr>
    <tr>
    <td height="30"><label for="Subject">Subject</label></td>
    <td height="30"><select name="Subject" id="Subject" style="width:200px;">
    <option value="Technical issue">Technical issue</option>
    <option value="Rates">Rates</option>
    <option value="Other">Other</option>
    </select></td>
    </tr>
    <tr>
    <td height="30">Email address</td>
    <td height="30"><input name="Email" type="text" id="Email" style="width:200px;" /></td>
    </tr>
    <tr>
    <td valign="top">Message</td>
    <td><label for="Message"></label>
    <textarea name="Message" id="Message" rows="5" style="width:200px;"></textarea></td>
    </tr>
    <tr>
    <td height="30">&nbsp;</td>
    <td height="30"><input type="submit" name="send" id="send" value="Send now" />
    <input type="reset" name="Reset" id="button" value="Clear form" /></td>
    </tr>
    </table>
    <p>&nbsp;</p>
    </form>
karthik_ppts commented: Useful post +4
vibhaJ 126 Master Poster

I prefer below steps:
1. create div for loading text or image.
2. With binding ajaxStart event we can show loading div.
3. With binding ajaxStop event we can hide loading div.
4. This way in you page whenever ajax ia called loading div will automatically shown.

Below is code for that..

<!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 type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
</head>

<body>
<!-- ################# Ajax Loading start ################# -->
<script language="javascript">
$(document).bind('ajaxStart', function() {
  $('#ajaxLoading').show();
});
$(document).bind('ajaxStop', function() {
  $('#ajaxLoading').hide();
});
</script>
<div id="ajaxLoading" style="background-color:#777777;position:fixed;height:100%;width:100%;left:0px;top:0px;opacity:0.7;filter:alpha(opacity=70); display:none;"><div style="position:absolute;top:30%;left:45%;">Loading....</div>
</div>
<!-- ################# Ajax Loading end ################# -->


<script language="javascript">
$(document).ready(function () {
$('#form').submit(function() {
						   
  $.ajax({
    type: 'get',
    url: 'search_hotel.php',
    data:  $('#'+this.id).serialize(),
	dataType: "html",
	async:false,
    success: function(result){
      $('#dsr').html(result);
    }    
  });  
  return false;
});
});
</script>
<form id="form" name="form" method="post">
Name : <input name="" type="text" />
<input name="submit" value="submit" type="submit" />
</form>
</body>
</html>
vibhaJ 126 Master Poster

See this example.
In you code you can change %1$s to %1 as all 3 string order is fixed.

echo $hyperlink = sprintf('<a href="http://%s" target="%s">%s</a>', 'url', 'target', 'showingtext');
vibhaJ 126 Master Poster
vibhaJ 126 Master Poster

Correction...

$information = mysql_query("SELECT * FROM table WHERE informationtype='message' OR informationtype='email'");
vibhaJ 126 Master Poster

Thanks pritaeas for info.

vibhaJ 126 Master Poster

here we go...

<?
	if(isset($_POST['search']))
	{
		echo 'Search Result :<br />';
		$width = mysql_escape_string($_POST['width']);
		$profile = mysql_escape_string($_POST['profile']);
		$size = mysql_escape_string($_POST['size']);
		
		$where = " 1=1 ";
		if($width != "")
			$where.=" AND width='$width'";
		if($profile != "")
			$where.=" AND profile='$profile'";
		if($size != "")
			$where.=" AND size='$size'";
			
		$sql = "select * from mobile where $where";
		$rs = mysql_query($sql);
		while($sar = mysql_fetch_assoc($rs))
		{
			echo '<br />'.$sar['mobile_name'];
		}
	}
?>
<form name="frm" method="post">
WIDTH :
<select name="width">
<option value="">- - Select Width - -</option>
<option value="200">200</option>
<option value="250">250</option>
<option value="300">300</option>
</select>
PROFILE :
<select name="profile">
<option value="">- - Select Profile - -</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="150">150</option>
</select>
SIZE :
<select name="size">
<option value="">- - Select Size - -</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
</select>
<input name="search" value="Search" type="submit" />
</form>

You can change drop down values as per your need.

vibhaJ 126 Master Poster

This post should be in Internet Marketing > Search Engine Optimization.

vibhaJ 126 Master Poster

This is just demo code.
Change your database table field names and run it.

<?
	if(isset($_POST['search']))
	{
		echo 'Search Result :<br />';
		$width = mysql_escape_string($_POST['width']);
		$profile = mysql_escape_string($_POST['profile']);
		$size = mysql_escape_string($_POST['size']);
		
		$where = " 1=1 ";
		if($width != "")
			$where.=" AND width='$width'";
		if($profile != "")
			$where.=" AND profile='$profile'";
		if($size != "")
			$where.=" AND size='$size'";
			
		$sql = "select * from mobile where $where";
		$rs = mysql_query($sql);
		while($sar = mysql_fetch_assoc($rs))
		{
			echo '<br />'.$sar['mobile_name'];
		}
	}
?>
<form name="frm" method="post">
WIDTH :
<input name="width" type="text" />
PROFILE :
<input name="profile" type="text" />
SIZE :
<input name="size" type="text" />
<input name="search" value="Search" type="submit" />
</form>

Hope this helps.

vibhaJ 126 Master Poster

Usually when you install WAMP, mysql is automatically configured.You don't need extra efforts.
After successful installation when you open http://localhost/phpmyadmin you can see phpmyadmin window.
Try to reinstall wamp.

vibhaJ 126 Master Poster

Yes i do understand your point.
You have included file using require and your loading time is showing in minus for some reason.I think require should not create any issue. Posted link was just for sharing.
Can you post your php code for review?

vibhaJ 126 Master Poster
vibhaJ 126 Master Poster

MySQL is a relational database management system.
Phpmyadmin is just a user interface with mysql.
There are some software based tool like Workbench, SQLyog, Mysql query browser and some web based application like phpmyadmin.

vibhaJ 126 Master Poster

Loading time is not fixed every time.
It may differ. check this for any site.

vibhaJ 126 Master Poster

Your code is right.
Are you facing any error?

vibhaJ 126 Master Poster

You can use mysql_real_escape_string function before inserting data in mysql.
http://in2.php.net/manual/en/function.mysql-real-escape-string.php

vibhaJ 126 Master Poster

You can use 'selected' for that.
Check below code you will understand.

<select name="selectbox">
<option value="">- - Select - -</option>
<option value="Computer">Computer</option>
<option value="Hello" selected="selected">Hello</option>
<option value="World">World</option>
</select>
vibhaJ 126 Master Poster

Frankly speaking i hate reg expression, because its output is also unpredictable and we cant debug it.
I always used to google it and use it.
I found it here http://php.net/manual/en/function.preg-match-all.php#allnotes

vibhaJ 126 Master Poster
vibhaJ 126 Master Poster

Try this.

<?
	$replaced_content = " abcs is here {blog:vibhadevit} mnop dsgdh 3535 {blog:computer} after blog content";
	preg_match_all('/{blog:[A-Za-z0-9_]+}/', $replaced_content, $matches, PREG_SET_ORDER);
	echo '<pre>';
	print_r($matches);
?>
vibhaJ 126 Master Poster

Alert box is client side property, that can not be accessed via PHP.
Any reason why you don't want JS?

vibhaJ 126 Master Poster
dalip_007 commented: excellent +3
vibhaJ 126 Master Poster

Here is a code for exporting table to csv.

<?
	mysql_connect('localhost','root','');
	mysql_select_db('test');
	
	$sql = "select student_name,student_sirname from student";

	// Query Database	
	$filename = 'file.csv';		
	$rsSearchResults = mysql_query($sql) or die(mysql_error());
	
	$out = '';
	
	// fiels to export
	$out .='Student Name,Sirname';
	$out .="\n";
	
	// Add all values in the table
	while ($l = mysql_fetch_array($rsSearchResults)) {
	for ($i = 0; $i < 2; $i++) {
	$out .=''.$l["$i"].',';
	}
	$out .="\n";
	}
	// Output to browser with appropriate mime type
	header("Content-type: text/x-csv");	
	header("Content-Disposition: attachment; filename=$filename");
	echo $out;
	exit;	
?>
vibhaJ 126 Master Poster

As kartik said you only need to run query part in phpmyadmin, not PHP.

vibhaJ 126 Master Poster

As i asked you before your php open tag seems closed. Try below code.

<?php error_reporting(E_ALL);?>
<!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>
<?php
	/* CREATE TABLE `tbl_hindi` (
	  `data` varchar(1000) character set utf8 collate utf8_bin default NULL
	) ENGINE=InnoDB DEFAULT CHARSET=latin1;
	
	INSERT INTO `tbl_hindi` VALUES ('कंप्यूटर'); */
	
	mysql_connect('localhost','root','');
	mysql_select_db('test');	
	
	mysql_query('SET character_set_results=utf8');
	mysql_query('SET names=utf8');
	mysql_query('SET character_set_client=utf8');
	mysql_query('SET character_set_connection=utf8');
	mysql_query('SET character_set_results=utf8');
	mysql_query('SET collation_connection=utf8_general_ci');
	
	if(isset($_POST['save']))
	{
		$sql = "insert into tbl_hindi values ('".$_POST['data']."')";
		mysql_query($sql);
		echo '<br />Data inserted successfully.<br />';
	}
	
	$sql = "select * from tbl_hindi";
	$res = mysql_query($sql);		
		
?>
<form  method="post">
<table width="900%" border="0">
  <tr>
    <td>Add New : <input type="text" name="data" size="20" />
<input type="submit" name="save" value="Save" /></td>
  </tr>
  <tr>
    <td>-----------------------------</td>
  </tr>
  <tr>
    <td><strong>Hindi Data</strong></td>
  </tr>
  <?php while($sar = mysql_fetch_assoc($res)) { ?>
  <tr>
    <td><?php echo $sar['data'];?></td>
  </tr>
  <?php } ?>
</table>
</form>
</body>
</html>
vibhaJ 126 Master Poster

php code for drop down.

<?
	$sql = "select * from tbl_country";
	$res = mysql_query($sql);
	echo '<select name="country">';
	while($sar = mysql_fetch_assoc($res))
	{
		echo '<option value="'.$sar['countryId'].'">'.$sar['countryName'].'</option>';
	}
	echo '</select>';
?>
vibhaJ 126 Master Poster

I was also facing so many issues for mail attachment.
Finally i end up with this.
I have made this function, hope this helps you.

<?php

	//=======================================
	//   mail sending start
	//=======================================
		$to = 'vibha@domainname.com';
		$fromName = 'Administrator';
		$fromEmail = 'admin@domainname.com';
		$subject = 'Subjest is here';		
		$message = 'Message is here..Message is here..Message is here......Message is here';
		$template = 'demo.tpl';				
		$files = array('demo.txt','demo.xlsx');		
		if(sendEmail($to,$fromName,$fromEmail,$subject,$message,$cc='',$bcc='',$files))
			echo 'Mail successfully sent.';
		else
			echo 'Mail sending failed.';
	//=======================================
	//   mail sending end
	//=======================================	


function sendEmail($to,$fromName,$fromEmail,$subject,$message,$cc='',$bcc='',$files=array(),$debug=false)
{
	// starting of headers
	$headers = 'From: '.$fromName.' <'.$fromEmail.'>';
	if($cc != '')
		$headers .= "\r\nCc: ". $cc;
	if($bcc != '')
		$headers .= "\r\nBcc: ". $bcc;
		
	// boundary 
	$semi_rand = md5(time()); 
	$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
	 
	// headers for attachment 
	$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; 
	 
	// multipart boundary 
	$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; 
	if(count($files))
		$message .= "--{$mime_boundary}\n";
	 
	// preparing attachments
	for($x=0;$x<count($files);$x++)
	{
		$file = fopen($files[$x],"rb");
		$data = fread($file,filesize($files[$x]));
		fclose($file);
		$data = chunk_split(base64_encode($data));
		$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" . 
		"Content-Disposition: attachment;\n" . " filename=\"$files[$x]\"\n" . 
		"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
		if($x < (count($files)-1))
			$message .= "--{$mime_boundary}\n";
		else
			$message .= "--{$mime_boundary}--\n";	
		
	}
		
	if($debug)
	{
		echo '<br />$to: '.$to;
		echo '<br />$fromName: '.$fromName;
		echo '<br />$fromEmail: '.$fromEmail;
		echo '<br />$subject: '.$subject;
		echo '<br />$message: '.$message;
		echo '<br />$cc: '.$cc;
		echo '<br />$bcc: '.$bcc;
		echo '<br />$file: '.print_r($file);		
	}
	
	if(mail($to, $subject, $message, $headers))
	{		
		return true;
	} …
vibhaJ 126 Master Poster

Try this code, you will understand how to use hidden field.

<?
	if(isset($_POST['save']))
	{
		echo 'Form Values:<br />';
		echo '<br />Name Label: '.$_POST['name_label'];
		echo '<br />Name Value: '.$_POST['name'];
		echo '<br />Email Label: '.$_POST['email_label'];
		echo '<br />Email Value: '.$_POST['email'];
		exit;
	}
?>
<form id="form1" name="form1" method="post" action="">
<table width="500" border="0" cellspacing="3" cellpadding="3">
  <tr>
    <td>Your Name<input type="hidden" name="name_label" value="Your Name" /></td>
    <td>
      <label>
        <input type="text" name="name" id="name" />
        </label>
   
    </td>
  </tr>
  <tr>
    <td>Your Email<input type="hidden" name="email_label" value="Your Email" /></td>
    <td><input type="text" name="email" id="email" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="save" id="button" value="Save" /></td>
  </tr>
</table> 
</form>
vibhaJ 126 Master Poster

You can not load form submission page withing specified ID.
What is the reason for that requirement?
You can design thank-you.html same as contact page and instead of form show thank texts.

vibhaJ 126 Master Poster

you want language translator?
You can use google translator for that.

vibhaJ 126 Master Poster

You can not get labels after form submission.
You can create hidden type field and value can be same as label, then when form submitted you can get hidden field value for labeling.

vibhaJ 126 Master Poster
vibhaJ 126 Master Poster

Try this.

<?php
$cnt = 0;
if (($handle = fopen("test.csv", "r")) !== FALSE) {
    while (($csvadata = fgetcsv($handle, 0, ",")) !== FALSE) {      
	   $data[$cnt++] = $csvadata;
    }
    fclose($handle);
	unset($data[2]);
}
$fp = fopen('test.csv', 'w');
foreach ($data as $fields) {
    fputcsv($fp, $fields);
}
fclose($fp);
?>
vibhaJ 126 Master Poster

Now I've to search the the biggest values of the array and replace them with a zero. How can I do it???

Can you give one example with live values?

vibhaJ 126 Master Poster

Try this.

RewriteEngine On                          
RewriteRule ^([^/]+)$ /index.php?url=$1 [L]
RewriteRule ^/article/([^/]+)$ /index.php?url=$1&type=news [L]
vibhaJ 126 Master Poster

[by mistake]

vibhaJ 126 Master Poster

Can you use your login credentials in below code and post output.
Because i think there is something wrong in credentials only.

<?php

$db_host = "localhost";
$db_user = "root";
$db_password = "";
$db_database = "db_name"

$link = mysql_connect($db_host, $db_user, $db_password);
if (!$link) {
    die('Not connected : ' . mysql_error());
}

// make foo the current db
$db_selected = mysql_select_db($db_database, $link);
if (!$db_selected) {
    die ('Db selection error : ' . mysql_error());
}

?>
lovell_82 commented: great help +1