Jump to content

dileepd26

Members
  • Posts

    10
  • Joined

  • Last visited

dileepd26's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Sir, I am new to php coding, by mistake email field is visible to others, i need only 1 id there to receive mail, not blank field, see source code, tell me how to correct it to prevent spammers. We appreciate all positive response. Thank you in advance..
  2. Sir/ Madam, I have 2 files, Ex: submit-mail.htm & send-mail.php, which is used to send mail using my webmaster account..htm file is used to send mail to someone using my webmaster email account. Now .htm file shows a blank field to input email id. someone@somewhere.com, etc,. anyone can misuse it.I need to prevent users from modifying default email field, i need to put info@ambtion.com at this place.We appreciate all positive response. Thank you in advance..submit-mail.htm source is below.<html><head><title>Mail sender</title></head><body><form action="mail.php" method="POST"><b>Email</b><br><input type="text" name="email" size=40><p><b>Subject</b><br><input type="text" name="subject" size=40><p><b>Message</b><br><textarea cols=40 rows=10 name="message"></textarea><p><input type="submit" value=" Send "></form></body></html>send-mail.php source is below.<html><head><title>PHP Mail Sender</title></head><body><?php/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */$email = $HTTP_POST_VARS['email'];$subject = $HTTP_POST_VARS['subject'];$message = $HTTP_POST_VARS['message'];/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) { echo "<h4>Invalid email address</h4>"; echo "<a href='java script:history.back(1);'>Back</a>";} elseif ($subject == "") { echo "<h4>No subject</h4>"; echo "<a href='java script:history.back(1);'>Back</a>";}/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */elseif (mail($email,$subject,$message)) { echo "<h4>Thank you for sending email</h4>";} else { echo "<h4>Can't send email to $email</h4>";}?></body></html>
  3. Sir,I changed it as you informed to to null but no results. It only works offline not online. xmlhttp.send(null);
  4. Sir,It is different, That code is also working at my domain, but it'll list result in text format only.i need the results in html format as links,Check the link below.http://www.w3schools.com/php/php_ajax_livesearch.asp
  5. Sir,On line 22 only: { symbol.livesearch.php contains <?php$xmlDoc=new DOMDocument();$xmlDoc->load("links.xml");$x=$xmlDoc->getElementsByTagName('link');//get the q parameter from URL$q=$_GET["q"];//lookup all links from the xml file if length of q>0if (strlen($q)>0){$hint="";for($i=0; $i<($x->length); $i++) { $y=$x->item($i)->getElementsByTagName('title'); $z=$x->item($i)->getElementsByTagName('url'); if ($y->item(0)->nodeType==1) { //find a link matching the search text if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q)) { if ($hint=="") { $hint="<a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } else { $hint=$hint . "<br /><a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } } } }}// Set output to "no suggestion" if no hint were found// or to the correct valuesif ($hint=="") { $response="no suggestion"; }else { $response=$hint; }//output the responseecho $response;?>
  6. Sir,I created errorcheck.php & put the code in it. I also replaced file.php with liveserch.phpWhen i checked for error after uploading it i got the following error. Parse error: parse error, unexpected T_OBJECT_OPERATOR in /0/livesearch.php on line 22
  7. Sir,I checked error log but no data in the log. 0 kb.If required i'll provide my ftp.ambtion.com ID & password so that you help me to make the coding work online.I would like to invite you to accept your new email idjustsomeguy@ambtion.comidjustsomeguy* is your pwd.Thanks.
  8. Sir,As you informed i tried to upload php file with the code to check error. <?phpini_set('log_errors', 1);ini_set('error_log', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'error.log');ini_set('html_errors', 0);ini_set('display_errors', 0);error_reporting(E_ALL);$xmlDoc=new DOMDocument();$xmlDoc->load("links.xml");$x=$xmlDoc->getElementsByTagName('link');//get the q parameter from URL$q=$_GET["q"];//lookup all links from the xml file if length of q>0if (strlen($q)>0){$hint="";for($i=0; $i<($x->length); $i++) { $y=$x->item($i)->getElementsByTagName('title'); $z=$x->item($i)->getElementsByTagName('url'); if ($y->item(0)->nodeType==1) { //find a link matching the search text if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q)) { if ($hint=="") { $hint="<a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } else { $hint=$hint . "<br /><a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } } } }}// Set output to "no suggestion" if no hint were found// or to the correct valuesif ($hint=="") { $response="no suggestion"; }else { $response=$hint; }//output the responseecho $response;?>___
  9. Respected Sir,I am happy to hear from you, Yes my server running PHP, i could run other php files there.NO Javascript errors, Kindly check this linkhttp://www.ambtion.com/0/search.phpthis should get original results as in w3schools.comhttp://www.w3schools.com/php/php_ajax_livesearch.aspThanking you, Dileep Kumar. D
  10. Hi Friends,I am Dileep, from B'lore. I tried to use the code from..http://www.w3schools.com/php/php_ajax_livesearch.aspThis code is working fine when i checked it offline, i created 3 files namely ajaxlivesearch.htm, livesearch.php, links.xml. I published the same code online no results are shown.I appreciate any positive response to solve this problem.Thanks.--------<html><head><script type="text/javascript">function showResult(str){if (str.length==0) { document.getElementById("livesearch").innerHTML=""; document.getElementById("livesearch").style.border="0px"; return; }if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("livesearch").innerHTML=xmlhttp.responseText; document.getElementById("livesearch").style.border="1px solid #A5ACB2"; } }xmlhttp.open("GET","livesearch.php?q="+str,true);xmlhttp.send();}</script></head><body><form><input type="text" size="30" onkeyup="showResult(this.value)" /><div id="livesearch"></div></form></body></html>------------------<?php$xmlDoc=new DOMDocument();$xmlDoc->load("links.xml");$x=$xmlDoc->getElementsByTagName('link');//get the q parameter from URL$q=$_GET["q"];//lookup all links from the xml file if length of q>0if (strlen($q)>0){$hint="";for($i=0; $i<($x->length); $i++) { $y=$x->item($i)->getElementsByTagName('title'); $z=$x->item($i)->getElementsByTagName('url'); if ($y->item(0)->nodeType==1) { //find a link matching the search text if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q)) { if ($hint=="") { $hint="<a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } else { $hint=$hint . "<br /><a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } } } }}// Set output to "no suggestion" if no hint were found// or to the correct valuesif ($hint=="") { $response="no suggestion"; }else { $response=$hint; }//output the responseecho $response;?>
×
×
  • Create New...