
thenature4u
Members-
Posts
54 -
Joined
-
Last visited
Never
Everything posted by thenature4u
-
my code is like this <? define('ABOUT US','We are the development People'); ?> i want to read this .php file and save this content to a variable. Thanks for reply.
-
Thanks for your reply, but i need to read the content from .php file for other purposes. if you have any idea, let me know.
-
i want to read some static content from .php file. i want to read and and keep that in a variable. help me. Thanks in advance
-
while($row = mysql_fetch_array) { change this to while($row = mysql_fetch_array($result)) {
-
in internet explorer its working fine, where as coming to firefox its showing symbol with the output. thanking u in advance. <!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>Ajax Auto Suggest</title> <script type="text/javascript" src="jquery-1.2.1.pack.js"></script> <script type="text/javascript"> function lookup(inputString) { if(inputString.length == 0) { // Hide the suggestion box. $('#suggestions').hide(); } else { $.post("rpc.php", {queryString: ""+inputString+""}, function(data){ if(data.length >0) { $('#suggestions').show(); $('#autoSuggestionsList').html(data); } }); } } // lookup function fill(thisValue) { $('#inputString').val(thisValue); setTimeout("$('#suggestions').hide();", 200); } </script> <style type="text/css"> body { font-family: Helvetica; font-size: 11px; color: #000; } h3 { margin: 0px; padding: 0px; } .suggestionsBox { position: relative; left: 30px; margin: 10px 0px 0px 0px; width: 200px; background-color: #212427; -moz-border-radius: 7px; -webkit-border-radius: 7px; border: 2px solid #000; color: #fff; } .suggestionList { margin: 0px; padding: 0px; } .suggestionList li { margin: 0px 0px 3px 0px; padding: 3px; cursor: pointer; } .suggestionList li:hover { background-color: #659CD8; } </style> </head> <body> <div> <form> <div> Type your county: <input type="text" size="30" value="" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" /> </div> <div class="suggestionsBox" id="suggestions" style="display: none;"> <img src="upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" /> <div class="suggestionList" id="autoSuggestionsList"> </div> </div> </form> </div> </body> </html>
-
in internet explorer its working fine, where as coming to firefox its showing  symbol with the output. thanking u in advance. <!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>Ajax Auto Suggest</title> <script type="text/javascript" src="jquery-1.2.1.pack.js"></script> <script type="text/javascript"> function lookup(inputString) { if(inputString.length == 0) { // Hide the suggestion box. $('#suggestions').hide(); } else { $.post("rpc.php", {queryString: ""+inputString+""}, function(data){ if(data.length >0) { $('#suggestions').show(); $('#autoSuggestionsList').html(data); } }); } } // lookup function fill(thisValue) { $('#inputString').val(thisValue); setTimeout("$('#suggestions').hide();", 200); } </script> <style type="text/css"> body { font-family: Helvetica; font-size: 11px; color: #000; } h3 { margin: 0px; padding: 0px; } .suggestionsBox { position: relative; left: 30px; margin: 10px 0px 0px 0px; width: 200px; background-color: #212427; -moz-border-radius: 7px; -webkit-border-radius: 7px; border: 2px solid #000; color: #fff; } .suggestionList { margin: 0px; padding: 0px; } .suggestionList li { margin: 0px 0px 3px 0px; padding: 3px; cursor: pointer; } .suggestionList li:hover { background-color: #659CD8; } </style> </head> <body> <div> <form> <div> Type your county: <br /> <input type="text" size="30" value="" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" /> </div> <div class="suggestionsBox" id="suggestions" style="display: none;"> <img src="upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" /> <div class="suggestionList" id="autoSuggestionsList"> </div> </div> </form> </div> </body> </html>
-
I got the code for auto completion from these sites. if anyone needs go through the following links. http://nodstrum.com/2007/09/19/autocompleter/ http://www.brandspankingnew.net/archive/2006/08/ajax_auto-suggest_auto-complete.html
-
if any one have the code for auto completion, just let me know. thanking you in advance.
-
no. dont u know auto complete? the user should be able to access those values(after clicking a particular value the should be displayed in text box).
-
i working with 3 files, i am displaying the code in the 3 files here. iam getting the output also, but the output format is not correct. just iam able to display the names when he writes something in the text box. but the user has to click the names, which are getting from array. how to do this one. thanking u in advance, txthint.html <html> <head> <script src="clienthint.js"></script> </head> <body><form name="f1"> <table> <tr> <td> First Name: </td> <td> <input type="text" id="txt1" onkeyup="addlocdata(str=this.value)"> </td> </tr> <tr> <td> <p>Usernames: <span id="txtHint"></span></p> </td> <td> <div id="dispid"></div> </td> </tr> </form> </body> </html> clienthint.js var req; function loadReq(){ var req = false; req=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP"); return req; } function loadviapost(url, id, parameters,str) { req=loadReq(); if (str==0) { document.getElementById("dispid").innerHTML=""; return; } if(req) { req.onreadystatechange = function(){ if (req.readyState==4){ document.getElementById(id).innerHTML=req.responseText; } } req.open("POST", url, true); //These lines are necessery req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.setRequestHeader("Content-length", parameters.length); req.setRequestHeader("Connection", "close"); req.send(parameters); } } function addlocdata(str) { var poststr = "q=" + encodeURI( document.forms.f1.txt1.value ); loadviapost('gethint.php', 'dispid', poststr,str); } gethint.php <?php header("Cache-Control: no-cache, must-revalidate"); // Date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Fill up array with names $a[]="Anna"; $a[]="Brittany"; $a[]="Cinderella"; $a[]="Diana"; $a[]="Eva"; $a[]="Fiona"; $a[]="Gunda"; $a[]="Hege"; $a[]="Inga"; $a[]="Johanna"; $a[]="Kitty"; $a[]="Linda"; $a[]="Nina"; $a[]="Ophelia"; $a[]="Petunia"; $a[]="Amanda"; $a[]="Raquel"; $a[]="Cindy"; $a[]="Doris"; $a[]="Eve"; $a[]="Evita"; $a[]="Sunniva"; $a[]="Tove"; $a[]="Unni"; $a[]="Violet"; $a[]="Liza"; $a[]="Elizabeth"; $a[]="Ellen"; $a[]="Wenche"; $a[]="Vicky";//get the q parameter from URL $q=$_REQUEST["q"];//lookup all hints from array if length of q>0 if (strlen($q) > 0) { $hint=""; for($i=0; $i<count($a); $i++) { if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q)))) { if ($hint=="") { $hint=$a[$i]; } else { $hint=$hint." \n ".$a[$i]; } } } } // Set output to "no suggestion" if no hint were found // or to the correct values if ($hint == "") { $response="no suggestion"; } else { $response=$hint; } //output the response echo $response; ?>
-
i already tried that one, its generating 8 characters but displaying only 5. i want to display total 8 characters. Thanks for reply
-
i have some code for captcha, its working. but my problem is, its printing only 5 characters, i want to increase upto 8 characters. please help me mtc.class.php <?php /** * My Two Cents - A simple comment system * 2005-2007 © Andreas Gohr <[email protected]> */ if(!defined('MTC')) define('MTC','MTC'); // used for all POST/GET vars and CSS classes // The MTC main class class MTC { // DB connection var $db_host = 'localhost'; var $db_user = 'mtc'; var $db_pass = 'mtc'; var $db_name = 'mtc'; // web path to the class file var $self = 'mtc.class.php'; // antispam var $blacklist = 'blacklist.txt'; var $captcha = true; var $audio = false; var $showmail = false; // output var $addcss = true; var $target = ''; // admin stuff var $adminpass = ''; var $notify = ''; var $gravopts = '&rating=R'; // language strings var $lang = array( 'name' => 'Your Name:', 'email' => 'Your E-Mail:', 'web' => 'Website (optional):', 'captcha' => 'Security Code:', 'comment' => 'Your two Cents:', 'info' => 'No HTML allowed. URLs will be linked with nofollow attribute. Whitespace is preserved.', 'audio' => 'Click to hear the security code spelled.', 'nofield' => 'Sorry, you need to fill all necessary fields!', 'noemail' => 'Sorry, this mail address doesn\'t look valid.', 'noweb' => 'Sorry, this web address doesn\'t look valid.', 'nocaptcha' => 'Sorry, the security code was wrong.', 'nospam' => 'Sorry, spamming is not allowed here.', ); // you may want to change this for more secure captchas var $secret = 'CHANGEME!'; // internal only var $db_link; var $captchafnt; var $audiodir = ''; var $message = ''; var $page = ''; /** * Constructor */ function MTC(){ $this->captchafnt = glob(dirname(__FILE__).'/MTC/fonts/*.ttf'); $this->audiodir = dirname(__FILE__).'/MTC/audio/'; // auto set the secret (for lazy ones) $secret .= $_SERVER['HTTP_USER_AGENT']; $secret .= $_SERVER['SERVER_SOFTWARE']; $secret .= __FILE__; $secret = md5($secret); if($this->target){ $this->target = 'target="'.$this->target.'"'; } } /** * To be called in the head section. Handles intializing * and POST/GET variables */ function init($page = ''){ if(!$page){ $this->page = $_SERVER['PHP_SELF']; }else{ $this->page = $page; } // we do not touch other's variables if(get_magic_quotes_gpc() && !defined('MAGIC_QUOTES_STRIPPED')){ if (!empty($_POST[MTC])) $this->_remove_magic_quotes($_POST[MTC]); if (!empty($_GET[MTC])) $this->_remove_magic_quotes($_GET[MTC]); if (!empty($_REQUEST[MTC])) $this->_remove_magic_quotes($_REQUEST[MTC]); } echo $this->print_css(); if($_POST[MTC]['do'] == 'add'){ $this->_add_comment(); }else if($_POST[MTC]['do'] == 'del'){ $this->_del_comment(); } } /** * return the number of comments */ function comment_count($page=''){ if(!$page) $page = $this->page; $page = md5($page); $sql = "SELECT COUNT(*) as cnt FROM mtc_comments WHERE page = '$page'"; $handle = $this->_get_dbhandle(); if(!$handle) return false; $result = mysql_query($sql,$handle); $row = mysql_fetch_assoc($result); mysql_free_result($result); return $row['cnt']; } /** * List available comments */ function comments($page=''){ if(!$page) $page = $this->page; $page = md5($page); $sql = "SELECT id, name, mail, web, text, date FROM mtc_comments WHERE page = '$page' ORDER BY date"; $handle = $this->_get_dbhandle(); if(!$handle) return; $result = mysql_query($sql,$handle); while ($row = mysql_fetch_assoc($result)) { $this->format_comment($row); } mysql_free_result($result); } /** * Show the form to add new comments */ function comment_form(){ /*echo '<div class="'.MTC.'_form" id="'.MTC.'_form">'; $this->_print_message(); echo '<form action="#'.MTC.'_form" method="post" accept-charset="utf-8">'; echo '<input type="hidden" name="'.MTC.'[do]" value="add" style="display:none" />'; echo '<input type="hidden" name="'.MTC.' " value="'.htmlspecialchars($this->page).'" style="display:none" />'; echo '<div class="'.MTC.'_name">'; echo '<label for="'.MTC.'_name">'.$this->lang['name'].'</label>'; echo '<input type="text" name="'.MTC.'[name]" value="'.htmlspecialchars($_POST[MTC]['name']).'" id="'.MTC.'_name" />'; echo '</div>'; echo '<div class="'.MTC.'_mail">'; echo '<label for="'.MTC.'_mail">'.$this->lang['email'].'</label>'; echo '<input type="text" name="'.MTC.'[mail]" value="'.htmlspecialchars($_POST[MTC]['mail']).'" id="'.MTC.'_mail" />'; echo '</div>'; echo '<div class="'.MTC.'_web">'; echo '<label for="'.MTC.'_web">'.$this->lang['web'].'</label>'; echo '<input type="text" name="'.MTC.'[web]" value="'.htmlspecialchars($_POST[MTC]['web']).'" id="'.MTC.'_web" />'; echo '</div>';*/ if($this->captcha){ echo '<div class="'.MTC.'_captcha">'; //echo '<label for="'.MTC.'_captcha">'.$this->lang['captcha'].'</label>'; // echo '<input type="text" name="'.MTC.'[captcha]" value="" id="'.MTC.'_captcha" />'; echo '</div>'; $this->print_captcha(); } /*echo '<div class="'.MTC.'_text">'; echo '<label for="'.MTC.'_text">'.$this->lang['comment'].'</label>'; echo '<textarea cols="40" rows="10" name="'.MTC.'[text]" id="'.MTC.'_text">'.htmlspecialchars($_POST[MTC]['text']).'</textarea>'; echo '</div>'; echo '<input type="submit" value="Save" />'; echo '<p class="'.MTC.'_info">'.$this->lang['info'].'</p>'; echo '</form>'; echo '</div>';*/ } /** * Defines how a comment is printed. You may want to tweak this, but using CSS should be * enough usually */ function format_comment($row){ static $number = 0; $number++; $md5 = md5($row['mail']); $obf = strtr($row['mail'],array('@' => ' [at] ', '.' => ' [dot] ', '-' => ' [dash] ')); $text = htmlspecialchars($row['text']); $text = preg_replace('/\t/',' ',$text); $text = preg_replace('/ /',' ',$text); $text = preg_replace_callback('/((https?|ftp):\/\/[\w-?&;#~=\.\/\@]+[\w\/])/ui', array($this,'_format_link'),$text); $text = nl2br($text); $opts = str_replace('@MD5@',$md5,$this->gravopts); echo '<div class="'.MTC.'_comment" id="comment-'.$number.'">'; echo '<img src="http://www.gravatar.com/avatar.php?gravatar_id='.$md5.$opts.'" alt="" />'; echo '<a href="#comment-'.$number.'" rel="self bookmark" class="'.MTC.'_link">'.$number.'</a>'; echo '<div class="'.MTC.'_text">'; echo $text; echo '</div>'; echo '<div class="'.MTC.'_info">'; echo '<div class="'.MTC.'_date">'; echo $row['date']; echo '</div>'; echo '<div class="'.MTC.'_user">'; if($row['web']){ echo '<a href="'.htmlspecialchars($row['web']).'" rel="nofollow" '.$this->target.' class="url">'; echo htmlspecialchars($row['name']); echo '</a>'; }elseif($this->showmail){ echo '<a href="mailto:'.htmlspecialchars($obf).'" class="mail">'; echo htmlspecialchars($row['name']); echo '</a>'; }else{ echo htmlspecialchars($row['name']); } echo '</div>'; echo '</div>'; echo '<div class="'.MTC.'_clear"></div>'; $this->_admin_opts($row['id']); echo '</div>'; } /** * Prints minimal CSS for initial styling. Can be suppressed * with the addcss property. */ function print_css(){ if(!$this->addcss) return; echo '<style type="text/css">'; echo '.'.MTC."_message { text-align: center; color: #f00 }"; echo '#'.MTC."_form input { margin-left: 50px; display: block; width: 250px; }"; echo '#'.MTC."_form textarea { margin-left: 50px; display: block; width: 550px; }"; echo '#'.MTC."_form div.".MTC."_name { float: left; }"; echo '#'.MTC."_form div.".MTC."_mail { float: left; }"; echo '#'.MTC."_form div.".MTC."_web { float: left; clear: left;}"; echo '#'.MTC."_form div.".MTC."_captcha { float: left; clear: left;}"; echo '#'.MTC."_form img.".MTC."_captcha { float: left; margin-left: 50px;}"; echo '#'.MTC."_form div.".MTC."_text { clear: left; }"; echo 'div.'.MTC."_comment { border-bottom: 1px solid #000; margin-top: 0.5em; }"; echo 'div.'.MTC."_comment img { float:left; z-index: 10}"; echo 'div.'.MTC."_comment a.".MTC."_link { text-decoration: none; position: absolute; color: #999; font-size: 1.5em; z-index:50; float: left; font-weight: bold;}"; echo 'div.'.MTC."_comment div.".MTC."_date { display: inline; margin-right: 0.5em }"; echo 'div.'.MTC."_comment div.".MTC."_info { margin-left: 100px; font-style: italic;}"; echo 'div.'.MTC."_comment div.".MTC."_user { display: inline; }"; echo 'div.'.MTC."_comment div.".MTC."_text { margin-left: 100px; margin-bottom: 1em; }"; echo 'div.'.MTC."_comment div.".MTC."_clear { clear: both; line-height: 1px; height: 1px; }"; echo '</style>'; } /** * Creates a simple 200x50 CAPTCHA image */ function captcha_image(){ $text = $this->x_Decrypt($_REQUEST[MTC]['captcha'],$this->secret); // create a white image $img = imagecreate(200, 50); imagecolorallocate($img, 255, 255, 255); // add some lines as background noise for ($i = 0; $i < 60; $i++) { $color = imagecolorallocate($img,rand(100, 250),rand(100, 250),rand(100, 250)); imageline($img,rand(0,200),rand(0,50),rand(0,200),rand(0,50),$color); } // draw the letters for ($i = 0; $i < strlen($text); $i++){ $font = $this->captchafnt[array_rand($this->captchafnt)]; $color = imagecolorallocate($img, rand(0, 100), rand(0, 100), rand(0, 100)); $size = rand(16,25); $angle = rand(-30, 30); $x = 10 + $i * 40; $cheight = $size + ($size*0.5); $y = floor(50 / 2 + $cheight / 4); imagettftext($img, $size, $angle, $x, $y, $color, $font, $text[$i]); } header("Content-type: image/jpeg"); imagejpeg($img); imagedestroy($img); } /** * Stiches an audio CAPTCHA */ function captcha_audio(){ $text = $this->x_Decrypt($_REQUEST[MTC]['captcha'],$this->secret); $text = strtolower($text); // prepare wave files $wavs = array(); for($i=0;$i<5;$i++){ $wavs[] = $this->audiodir.'/'.$text{$i}.'.wav'; } // send stiched one header('Content-type: audio/x-wav'); header('Content-Disposition: attachment;filename=captcha.wav'); echo $this->_joinwavs($wavs); } /** * Print the HTML for the CAPTCHA */ function print_captcha(){ $code = $this->_gen_rand(); // Here the value of text1 is use for store in session by rakesh.. $text1 = $code; $code = $this->x_Encrypt($code,$this->secret); echo '<input type="hidden" name="MTC " value="'.htmlspecialchars($code).'" style="display:none" />'; if($this->audio){ $_SESSION['captchaUser']=htmlspecialchars($text1); echo '<a href="../mtc/'.$this->self.'?MTC[do]=audio&MTC[captcha]='.urlencode($code).'" title="'.$this->lang['audio'].'">'; } echo '<img src="../mtc/'.$this->self.'?MTC[do]=captcha&MTC[captcha]='.urlencode($code).'" width="200" height="50" alt="CAPTCHA" class="'.MTC.'_captcha" border="0" />'; if($this->audio){ echo '</a>'; } } /** * Generate a 5 char random code */ function _gen_rand(){ $code = ''; for($i=0;$i<5;$i++){ $code .= chr(rand(65, 90)); } return $code; } /** * Callback to autolink a URL (with shortening) */ function _format_link($match){ $url = $match[1]; str_replace("\\\\'","'",$url); if(strlen($url) > 40){ $title = substr($url,0,30).' … '.substr($url,-10); }else{ $title = $url; } $link = '<a href="'.$url.'" '.$this->target.' rel="nofollow">'.$title.'</a>'; return $link; } /** * Join multiple wav files * * All wave files need to have the same format and need to be uncompressed. * The headers of the last file will be used (with recalculated datasize * of course) * * @link http://ccrma.stanford.edu/CCRMA/Courses/422/projects/WaveFormat/ * @link http://www.thescripts.com/forum/thread3770.html * @link http://www.splitbrain.org/blog/2006-11/15-joining_wavs_with_php */ function _joinwavs($wavs){ $fields = join('/',array( 'H8ChunkID', 'VChunkSize', 'H8Format', 'H8Subchunk1ID', 'VSubchunk1Size', 'vAudioFormat', 'vNumChannels', 'VSampleRate', 'VByteRate', 'vBlockAlign', 'vBitsPerSample' )); $data = ''; foreach($wavs as $wav){ $fp = fopen($wav,'rb'); $header = fread($fp,36); $info = unpack($fields,$header); // read optional extra stuff if($info['Subchunk1Size'] > 16){ $header .= fread($fp,($info['Subchunk1Size']-16)); } // read SubChunk2ID $header .= fread($fp,4); // read Subchunk2Size $size = unpack('vsize',fread($fp, 4)); $size = $size['size']; // read data $data .= fread($fp,$size); } return $header.pack('V',strlen($data)).$data; } /** * Prints the form tags for admin */ function _admin_opts($id){ if(!$_REQUEST[MTC]['admin']) return; echo '<div class="'.MTC.'_admform">'; echo '<form action="#'.MTC.'_form" method="post" accept-charset="utf-8">'; echo '<input type="hidden" name="'.MTC.'[do]" value="del" style="display:none" />'; echo '<input type="hidden" name="'.MTC.' " value="'.htmlspecialchars($this->page).'" style="display:none" />'; echo '<input type="hidden" name="'.MTC.'[id]" value="'.$id.'" style="display:none" />'; echo '<label for="'.MTC.'_admpass">Admin Password:</label>'; echo '<input type="password" name="'.MTC.'[admpass]" value="" id="'.MTC.'_admpass" />'; echo '<input type="submit" value="Delete" />'; echo '</form>'; echo '</div>'; } /** * Does the work for deleting a comment */ function _del_comment(){ $page = trim($_POST[MTC]['page']); $id = trim($_POST[MTC]['id']); $admpass = $_POST[MTC]['admpass']; if(! ($page && $id && $admpass) ){ $this->message .= 'Sorry, missing parameters! Admin password given?'; return; } if($this->adminpass != $admpass){ $this->message .= 'Sorry, wrong password.'; return; } $page = md5($page); $id = addslashes($id); $sql = "DELETE FROM mtc_comments WHERE page = '$page' AND id = '$id'"; $handle = $this->_get_dbhandle(); if(!$handle) return; mysql_query($sql,$handle); $this->message = 'Comment deleted'; } /** * Does the work for adding a comment */ function _add_comment(){ $page = trim($_POST[MTC]['page']); $name = trim($_POST[MTC]['name']); $mail = trim($_POST[MTC]['mail']); $web = trim($_POST[MTC]['web']); $text = trim($_POST[MTC]['text']); $cptc = trim($_POST[MTC]['captcha']); $code = trim($_POST[MTC]['code']); if(! ($page && $name && $mail && $text) ){ $this->message .= $this->lang['nofield']; return; } if($this->captcha){ if(!$cptc || !$code || (strtoupper($cptc) != strtoupper($this->x_Decrypt($code,$this->secret))) ){ $this->message .= $this->lang['nocaptcha']; return; } }else{ $code = $this->_gen_rand(); } if($web && !preg_match('=https?://=i',$web)){ $this->message .= $this->lang['noweb']; return; } if(!$this->_isvalid_mail($mail)){ $this->message .= $this->lang['noemail']; return; } if($this->_check_blacklist($text)){ $this->message .= $this->lang['nospam']; return; } $ip = $_SERVER['REMOTE_ADDR']; $this->_mail($page,$name,$mail,$text,$ip,$_SERVER['PHP_SELF']); $url = addslashes($page); $page = md5($page); $name = addslashes($name); $mail = addslashes($mail); $web = addslashes($web); $text = addslashes($text); $ip = addslashes($ip); $code = addslashes($code); $sql = "INSERT IGNORE INTO mtc_comments SET page = '$page', name = '$name', mail = '$mail', web = '$web', text = '$text', date = NOW(), ip = '$ip', url = '$url', captcha = MD5('$code')"; $handle = $this->_get_dbhandle(); if(!$handle) return; mysql_query($sql,$handle); // clear form $_POST[MTC]['page'] = ''; $_POST[MTC]['name'] = ''; $_POST[MTC]['mail'] = ''; $_POST[MTC]['web'] = ''; $_POST[MTC]['text'] = ''; } /** * If the notify property is set this function will send a * mail for each comment created. */ function _mail($page,$name,$mail,$text,$ip,$url){ if(!$this->notify) return; $body = "The following comment was added:\n\n"; $body .= "Name: $name\n"; $body .= "Mail: $mail\n"; $body .= "Date: ".date('r')."\n"; $body .= "IP : $ip\n"; $body .= "Page: $page\n"; $body .= "URL : http://".$_SERVER['HTTP_HOST'].$url."\n\n"; $body .= $text; $body = base64_encode($body); $header = "MIME-Version: 1.0\n"; $header .= "Content-Type: text/plain; charset=UTF-8\n"; $header .= "Content-Transfer-Encoding: base64"; $subject = '['.MTC.'] New comment added'; mail($this->notify,$subject,$body,$header); } /** * Output a message if one is set */ function _print_message(){ if(!$this->message) return; print '<div class="'.MTC.'_message">'; print htmlspecialchars($this->message); print '</div>'; } /** * Connect to the database and return a handle */ function _get_dbhandle(){ if($this->link) return $this->link; $this->link = @mysql_connect($this->db_host, $this->db_user, $this->db_pass); if(!$this->link){ $this->message .= 'Could not connect to database: '.mysql_error(); return false; } if(!@mysql_select_db($this->db_name)){ $this->message .= 'Could not select database'; return false; } return $this->link; } /** * Uses a regular expresion to check if a given mail address is valid * * May not be completly RFC conform! * * @link http://www.webmasterworld.com/forum88/135.htm * * @param string $email the address to check * @return bool true if address is valid */ function _isvalid_mail($email){ return eregi("^[0-9a-z]([+-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$", $email); } /** * Spamcheck against wordlist * * Checks the wikitext against a list of blocked expressions * returns true if the text contains any bad words * * @author Andreas Gohr <[email protected]> */ function _check_blacklist($text){ if(!@file_exists($this->blacklist)) return false; $blockfile = file($this->blacklist); //how many lines to read at once (to work around some PCRE limits) if(version_compare(phpversion(),'4.3.0','<')){ //old versions of PCRE define a maximum of parenthesises even if no //backreferences are used - the maximum is 99 //this is very bad performancewise and may even be too high still $chunksize = 40; }else{ //read file in chunks of 600 - this should work around the //MAX_PATTERN_SIZE in modern PCRE $chunksize = 200; } while($blocks = array_splice($blockfile,0,$chunksize)){ $re = array(); #build regexp from blocks foreach($blocks as $block){ $block = preg_replace('/#.*$/','',$block); $block = trim($block); if(empty($block)) continue; $re[] = $block; } if(preg_match('#('.join('|',$re).')#si',$text)) return true; } return false; } /** * remove magic quotes recursivly * * @author Andreas Gohr <[email protected]> */ function _remove_magic_quotes(&$array) { if(!is_array($array)) return; foreach (array_keys($array) as $key) { if (is_array($array[$key])) { remove_magic_quotes($array[$key]); }else { $array[$key] = stripslashes($array[$key]); } } } /** * Simple XOR encryption * * @author Dustin Schneider * @link http://www.phpbuilder.com/tips/item.php?id=68 */ function x_Encrypt($string, $key){ for($i=0; $i<strlen($string); $i++){ for($j=0; $j<strlen($key); $j++){ $string[$i] = $string[$i]^$key[$j]; } } return $string; } /** * Simple XOR decryption * * @author Dustin Schneider * @link http://www.phpbuilder.com/tips/item.php?id=68 */ function x_Decrypt($string, $key){ for($i=0; $i<strlen($string); $i++){ for($j=0; $j<strlen($key); $j++){ $string[$i] = $key[$j]^$string[$i]; } } return $string; } } /** * Main */ if($_REQUEST['MTC']['do'] == 'captcha'){ $mtc = new MTC(); $mtc->captcha_image(); }elseif($_REQUEST['MTC']['do'] == 'audio'){ $mtc = new MTC(); $mtc->captcha_audio(); } //Setup VIM: ex: et ts=4 enc=utf-8 : ?> page1.php <?php session_start(); ?> <table border="0" width="65%" style="border:1px solid #68B6DF"> <tr> <td> <?php require_once("mtc/mtc.class.php"); $MTC = new MTC(); $MTC->audio = true; ?> <?php $MTC->comment_form(); ?> <?php echo $code=$_SESSION['cap'] ?> </td> </tr> </table>
-
culd you explain the code for insertind data from text file into mysql database using php. ex: data.txt this file contains below details. name:XXX office: mobile: email:[email protected] name:XXX office: mobile: email:[email protected] name:XXX office: mobile: email:[email protected] these details insert into database table structure is( name office mobile email) please explain this
-
I Need Help with Dynamically Adding New Form Fields! Please?!
thenature4u replied to jadeoracle's topic in PHP Coding Help
register www.naukri.com, in registration(in 2nd page) u will find dynamically adding new form fields. see the view source code. he done using java script......... -
if u have any idea let me know where can i get the source code for making forum using php and mysql...........
-
hi iam working for a online forum.. <a href="date.php">Date</a> here the user can see the underline on Date(Date). I dont want to show underlines. how to do it.......
-
when the user logins for the first time the if condition will fail. because after he logins only we will create the sessions. if suppose he logins using login.html page(action=login.php). if username and password are correct he enters into login.php otherwise he stay at login.html only. now my doubt is how can we check for session variables whether are they exists or not in login.php. obviously the sessions will not be started before login.php. so every time he redirected to the login.html page only.... we create the session variables when the user successfully enters into login.php only.
-
hi, when the user clicks the logout.php the session variables are destroying. my doubt is when the user clicking back, again they are entering into the pages. how to check whether session variables exist or not. if the sessions variables are not exist i use header to go login.html page. if yes the user can enter the pages.......in every page i want to check whether session variables exist or not...... In every page for example login.php page(in login.html form action=login.php) how to check whether session variables exist or not?????? thankyou in advance.....
-
form is there in one php file and mysql insertion is there in another php file.....how to use the above the code.... because same form and mysql insertion are there in the same file.....iam unable to understand.. thankyou in advance
-
when the user is refreshing the page the same data(data type is text) is again inserting into the database...how to avoid it.....
-
[SOLVED] using JavaScript confirm box with php
thenature4u replied to thenature4u's topic in PHP Coding Help
i changed my code to like this..... still iam getting error like this.... Delete query undefined why iam unable to retreve the value of qid in function confirmation...... function confirmation(qid) { var answer = confirm("Delete Query "+qid+" ?") if (answer){ alert("Query Deleted") window.location = 'quedelete.php?qid='+qid; } else{ alert("No action taken") } } <a href="javascript:confirmation()(<? echo $row['qid']; ?>)"> Delete query</a> -
THIS IS MY CODE........ <?php $con = mysql_connect("localhost","root",""); mysql_select_db("mytest", $con); $sql="select qid,uid,fname,mailid,query,date from uqueries"; $res= mysql_query($sql) or die(mysql_error()); echo "<br><br><br><br><br>"; include "services.html"; echo "<br><br><br><br><br>"; echo "<center>"; echo "<table border=1> <tr> <th>qid</th> <th>name</th> <th>query</th> <th>date</th> <th>Delete Query</th> <th>Delete User</th> </tr>"; while($row = mysql_fetch_array($res)) { ?> <script type="text/javascript"> <!-- function confirmation() { var answer = confirm("Delete Query <? echo $row['qid']; ?> ?") if (answer){ alert("Query Deleted") window.location = 'quedelete.php?qid=<?php echo $row['qid'] ?>'; } else{ alert("No action taken") } } function confirmat() { var answer = confirm("Delete User <? echo $row['uid']; ?> ?") if (answer){ alert("User Deleted") window.location = 'usdelete.php?uid=<?php echo $row['uid'] ?>'; } else{ alert("No action taken") } } //--> </script> <?php echo "<tr>"; echo "<td>" . $row['qid'] . "</td>"; echo "<td>" . $row['fname'] . "</td>"; echo "<td>" . $row['query'] . "</td>"; echo "<td>" . $row['date'] . "</td>"; ?> <td> <a href="javascript:confirmation()"> Delete query</a> </td> <td> <a href='javascript:confirmat()'> Delete User</a> </td> </tr> <?php } ?> </table> </center> IAM DEVELOPING THIS FOR ADMIN PURPOSE. HE CAN DELETE A QUERY OR USER... EVERY QUERY AND USER ARE HAVING THE UNIQUE VALUES......I WOULD LIKE TO DELETE A QUERY OR USER BY USING HIS UNIQUE ID. THE ADMIN HAS TO CONFIRM BEFORE DELETING.. HERE MY ERROR IS WHENEVER IAM DELETING A QUERY, THE VALUE OF $qid IS ALWAYS THE LAST VALUE, WHICH COME FROM THE DATABASE. IF SUPPOSE IN uqueries(table name) TABLE i have 12,13,34,6,78 and 23 are there, when i am going to delete a query always the $qid value is 23 only(last value).. where is the error.......
-
hi, iam using linux server........ how to read msword doc file and how to stores the data in a variable..... thanking u in advance........
-
hi, iam using linux server. i want to convert an msword .doc file to .txt. if u have any idea let me know........ thanking u in advance.....
-
DO U HAVE ANY IDEA ABOUT FRAME BREAKING USING JAVA SCRIPT...... IF U KNOW PLEASE HELP ME.........