Jump to content

ra_ie_darkness

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by ra_ie_darkness

  1. understandable but onsubmit did not work either. I still have the same problem
  2. if(checkEmpty===true && checkNum===true && checkStr===true) didn't work
  3. I have written a fucntion in javascript for validation. The submit button is inside a form <input type="submit" name="submit_request" value="Submit" id="submit_req" onclick="return checkQ(event);" style="backgroundColor:Transparent;border:0;color:blue;width:100;"/> This is the function function checkQ() { //Validation var checkEmpty; //check empty text field var checkNum; //check whether authorized value is greater than the requested value var checkStr //check whether string is entered var qLength = document.getElementsByName("pQuantity[]").length; for(i=0;i<qLength;i++) { var pValue = document.getElementsByName("pQuantity[]")[i].value; //authorized quantity var reQnty = document.getElementsByName("quantity[]")[i].value; //requested quantity if(pValue != "") { checkEmpty = true; } else { alert("Quantity missing"); checkEmpty = false; return false; } if(Number(pValue)>Number(reQnty)) { alert("greater value"); checkNum = false; return false; } else { checkNum = true; } if(!Number(pValue)) { alert("You are only allowed to enter a number"); checkStr = false; return false; } else { checkStr = true; } } if(checkEmpty==true && checkNum==true && checkStr==true) { alert("working"); return true; } } It works fine in chrome and IE but for some reason even when every condition is satifisfied the form is not submitted in firefox. I get the alert dialogue box saying "working" but nothing happens after that. how to fix it
  4. what I am trying to do is something similar to a shopping cart. I am using ajax to display the search results. when i click on one item from the results it gets added to another paragraph. The problem is that when i select the second item it is appended as string to the last item. For example if I select books and pens. It shows bookspens I want each item to be shown separately so that i can send the seperate values to a php script for inserting it as requested items. how can i achieve this without jquery This is the code search.php $keyword = mysql_real_escape_string($_POST['search_res']); $search_q = mysql_query("Select * from products where pname like '%$keyword%'"); if(mysql_num_rows($search_q)!=0) { while($result = mysql_fetch_array($search_q)) { $productid = $result['id']; $name = $result['pname']; echo "<input type='button' name='resultname' id='$productid' value='$name' onclick='throwval(this)'><br/>"; } } index.php <html> <head> <script language="javascript"> function showresult() { var product_name = document.getElementById("searchval").value; if(window.XMLHttpRequest) { XMLHttpRequestObject = new XMLHttpRequest(); } else if(window.ActiveXObject) { XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); } XMLHttpRequestObject.open("POST", "search.php", true); XMLHttpRequestObject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); XMLHttpRequestObject.send("search_res=" + product_name); XMLHttpRequestObject.onreadystatechange = function() { if(XMLHttpRequestObject.readyState == 4) { if(XMLHttpRequestObject.status == 200) { document.getElementById("displayresult").innerHTML = XMLHttpRequestObject.responseText; } } } } function throwval(obj) { var sent_id = obj.id; var v = document.getElementById(sent_id).value; var content = document.createTextNode(v); document.getElementById("newdiv").appendChild(content); } function sendvalues() { var data = document.getElementById("newdiv").textContent; alert(data); } </script> </head> <body> <!--Search Form--> <form method="post" name ="searchform" id="idsearchform" > <input type="text" name="search" id="searchval" /> <input type="button" name="starts" id="btn" value="startsearch" onclick="showresult()"/> </form> <div id="displayresult"> <!--Search results will be displayed here--> </div> Selected : <p id='newdiv'> <!--Selected values will be displayed here--> </p> <form name="form1" method="post" action="send_data.php"> <input type="button" id="sendtophp" name="sendingval" value="next step" onclick="sendvalues()"> </form> <p id='fetched'> </p> </body> </html>
  5. To validate email you can use filter_input() $email = filter_input(INPUT_GET,'email',FILTER_VALIDATE_EMAIL); You can check the username by sending a query to the database mysql_num_rows will return the number of rows containing the username. $q = mysql_query("Select * from table where username='$username'"); if(mysql_num_rows($q)!=0) { echo "Username exists"; }
  6. correction <form method="post" name ="searchform" id="idsearchform" > <input type="text" name="search"/> <input type="button" name="starts" value="search" onclick="showresult(search)"/> </form>
  7. Hello, I am new to ajax and javascript and am trying to create a search engine This is the javascript code var XMLHttpRequestObject = false; if(window.XMLHttpRequest) { XMLHttpRequestObject = new XMLHttpRequest(); } else if(window.ActiveXObject) { XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); } function showresult(search) { if(XMLHttpRequestObject) { var obj = document.getElementById("showresult"); XMLHttpRequestObject.open("POST","index.php",true); XMLHttpRequestObject.setRequestHeader("Content-type","application/x-www-form-urlencoded"); XMLHttpRequestObject.onreadystatechange = function() { if(XMLHttpRequestObject.readystate == 4 $$ XMLHttpRequestObject.status == 200) { obj.innerHTML = XMLHttpRequestObject.responseText; } } XMLHttpRequestObject.send("search=" + search); } //alert("You clicked me"); } PHP + HTML: <form method="post" name ="searchform" id="idsearchform" > <input type="text" name="search"/> <input type="button" name="starts" value="search" onclick="fun(search)"/> </form> <?php if(isset($_POST['starts'])) { $keyword = $_POST['search']; $search_q = mysql_query("Select * from products where pname like '%$keyword%'"); if(mysql_num_rows($search_q)!=0) { while($result = mysql_fetch_array($search_q)) { ?> <div id="showresult"> <?php $name = $result['pname']; echo "$name<br/>"; } } }?> </div> I don't get the search results when i click the search button. What is the issue here
  8. Hello, I am trying to retrieve some data through my php file from an ms access data base $sql = "Select AM_CheckInOut.[CheckInOut_Joint] as nr,AM_CheckInOut.[CheckTime] from AM_CheckInOut where AM_CheckInOut.[Person_Joint]=100170 and AM_CheckInOut.[DeviceID]=2 and mid(AM_CheckInOut.[CheckTime],1,10)='$fixdate';"; echo $sql.'<br/>'; $rs = odbc_exec($odbc_con,$sql) or die("query is not working"); if(!$rs) { echo "unable to execute query"; } while ($rs1= odbc_fetch_array($rs)) { $maxid = $rs1['nr']; echo 'Maximum ID'.$maxid.'<br/>'; } The column AM_CheckInOut.[CheckTime] contains timestamps. That looks something like 2010-06-22 12:42:50. The problem is that when i run the code it does not give me any result however if i paste the same query in msaccess it does return some values. The query that is shown on the browser is Select AM_CheckInOut.[CheckInOut_Joint] as nr,AM_CheckInOut.[CheckTime] from AM_CheckInOut where AM_CheckInOut.[Person_Joint]=100170 and AM_CheckInOut.[DeviceID]=2 and mid(AM_CheckInOut.[CheckTime],1,9)='2011-01-11'; What could be the issue
  9. I changed the settings in my php.ini file and it is working now. Thank you
  10. I'm trying to create a function to upload files on my server It is working fine but the problem is that it doesn't work when I try to upload files larger than 15/20 mb function uploadfile() { global $id; $getid = mysql_query("Select * from user where email='$id'"); while($result = mysql_fetch_array($getid)) { $userid = $result['id']; } $dir = "C:\\xampp\\htdocs\\filehost\\"; $dir.=$userid."\\"; if($_FILES['usr']['size']>2097152) //2megabytes { echo "You cannot upload files greater than 2mb"; } else { if(move_uploaded_file($_FILES['usr']['tmp_name'],$dir.$_FILES['usr']['name'])) { $fname = mysql_real_escape_string($_FILES['usr']['name']); $fsize = $_FILES['usr']['size']; $date = date("Y-m-d"); $dlurl = substr(md5(uniqid()), 0,10); $newdir = mysql_real_escape_string($dir); $fquery = mysql_query("SELECT * from folder where name ='$userid'"); while($row = mysql_fetch_array($fquery)) { $folderid = $row['name']; } echo "File uploaded"; if(!mysql_query("INSERT INTO myfile (fileid,userid,fid,name,size,date,location,dlurl) VALUES ('','$userid','$folderid','$fname','$fsize','$date','$newdir','$dlurl')")) { echo "Identify"; } else { echo "File uploaded"; } } } //echo "File moved"; } I have given a condition which does not allow files larger than 2 mb but instead of getting the message "You cannot upload files greater than 2mb" I get php error messages How can I fix this
  11. okay i am now using move_uploaded_file here is how it looks like <?php class upload { function fupload() { echo "My name is: ".$_FILES['usr']['name']."<br/>"; echo "Location ".$_FILES['usr']['tmp_name']."<br/>"; echo "Size:".($_FILES['usr']['size'] / 1024)." kb <br/>"; echo "File type".$_FILES['usr']['type']."<br/>"; if(file_exists("htdocs/".$_FILES['usr']['name'])) { echo $_FILES['usr']['name']."already exists"; } else { move_uploaded_file($_FILES['usr']['tmp_name'],"/learning/".$_FILES['usr']['name']); echo "File moved"; } } } $up = new upload(); $up->fupload(); ?> is it possible that i am not using the function properly? learning is a folder inside htdocs(xampp) now I am getting this message Warning: move_uploaded_file(/learning/) [function.move-uploaded-file]: failed to open stream: Invalid argument in C:\xampp\htdocs\learning\uploadfile.php on line 19 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\phpA56E.tmp' to '/learning/' in C:\xampp\htdocs\learning\uploadfile.php on line 19
  12. changing the file name did not work still getting the same warning message
  13. Thanks, i will rename the file but does that mean there is no problem in my code other than the file name is there a problem if there is a space in the file name if so then how will i solve this problem considering a user wants to upload a file that has spaces in its name
  14. I'm using xampp on windows vista I am a beginner in php and am working on creating a file hosting website got a form to upload the file from the client in uploadform.php <html> <body> <form method="post" action="uploadfile.php" enctype="multipart/form-data"> <input type="file" name="usr" id="usr"/><br /> <input type="submit" value="Upload"/> </form> </body> </html> the file handling code is in uploadfile.php <?php class upload { function fupload() { $dir = "C:\\xampp\htdocs\learning\fileshare database.txt"; echo "My name is: ".$_FILES['usr']['name']."<br/>"; echo "Location ".$_FILES['usr']['tmp_name']."<br/>"; echo "Size:".($_FILES['usr']['size'] / 1024)." kb <br/>"; echo "File type".$_FILES['usr']['type']."<br/>"; if(file_exists("htdocs/".$_FILES['usr']['name'])) { echo $_FILES['usr']['name']."already exists"; } else { copy($_FILES['usr']['name'],$dir); echo "File moved"; } } } $up = new upload(); $up->fupload(); ?> The problem is that it does not copy the file from the tmp directory to the specified one the error i get is: Warning: copy(fileshare databse.txt) [function.copy]: failed to open stream: No such file or directory in C:\xampp\htdocs\learning\uploadfile.php on line 20 I am facing the same problem if i try move_uploaded_file () function Could any one help with this issue, thanks
  15. I understand that but I want display the login status message below the login button how can i do that
  16. I am trying to create an index page which contains registration and login field the problem that i get is on successful login a warning is displayed session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\Eventz.com\index.php:116) in C:\xampp\htdocs\Eventz.com\index.php on line 235 This is the login part of my index.php this tag is inside an html table below the login form I also have a registration form and its php code above the login form <?php if (isset($_REQUEST['pass'])) { $id=$_POST['id']; $pass=$_POST['pass']; $conn =mysql_connect("localhost","root",""); if (!$conn) { die('Could not connect: ' . mysql_error()); } /* checking connection....success! */ $e=mysql_select_db('test', $conn); if(!$e) { die(''.mysql_error()); } else { echo 'database selected successfully'; } if (isset($_REQUEST['id']) || (isset($_REQUEST['pass']))) { if($_REQUEST['id'] == "" || $_REQUEST['pass']=="") { echo "login fields cannot be empty"; } else { $sql=mysql_query("Select email,password from login where email='$id' AND password='$pass'"); $count=mysql_num_rows($sql); if($count==1) /* $count checks if username and password are in same row */ { session_start(); $_SESSION['id']=$id; echo "</br>Login Successful</br>"; } else { echo "</br>invalid</br>"; echo "please try to login again</br>"; } } } } ?> Any help or suggestion would be appreciated
  17. I'm using xampp and am trying to create a login session...these are the my php files login.php <form action='login1.php' method='post'> Email: <input type='text' name='id'></br> Pass : <input type='password' name='pass'></br> <input type='submit' name='login' value='login'> login1.php <?php $id=$_POST['id']; $pass=$_POST['pass']; $conn=mysql_connect("localhost","root",""); if (!$conn) { die('Could not connect: ' . mysql_error()); } $e=mysql_select_db('test', $conn); if(!$e) { die(''.mysql_error()); } else { echo 'database selected successfully'; } $sql=mysql_query("Select email,password from login where email='$id' AND password='$pass'"); $count=mysql_num_rows($sql); if($count==1) { session_start(); echo "</br>Login Successful</br>"; echo "Please wait 5 seconds "; /* redirct to the specified page */ header("refresh:5;url=empty.php"); } else { echo "please try to login again</br>"; echo "you will be redirected to the login page in 5 seconds"; /* redirct to the specified page */ header("refresh:5;url=login.php"); } mysql_close(); ?> empty.php <?php session_start(); $logi=$_SESSION['id']; echo 'welcome '.$logi; ?> empty.php is supposed to display the email id from login.php I checked it about an hour ago and it was working fine but now it gives me an error Undefined index: id in C:\xampp\htdocs\littleprogress\empty.php on line 4 I didn't change anything after checking it. only cleared the history and cookies of my firefox browser what could be the problem
  18. yes I have posted those in sendmail.ini and have displayed that in this post (not the real password)
  19. Thank you for the reply. Here is the detail of what i've tried so far I am trying to use google's smtp server these are the changes that i have made in php.ini [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = smtp.gmail.com ; http://php.net/smtp-port smtp_port = 465 ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = postmaster@localhost ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" Below is a part of send mail.ini smtp_server=smtp.gmail.com ; smtp port (normally 25) smtp_port=465 ; the default domain for this server will be read from the registry ; this will be appended to email addresses when one isn't provided ; if you want to override the value in the registry, uncomment and modify smtp_ssl=auto default_domain=google.com ; log smtp errors to error.log (defaults to same directory as sendmail.exe) ; uncomment to enable logging ;error_logfile=error.log ; create debug log as debug.log (defaults to same directory as sendmail.exe) ; uncomment to enable debugging ;debug_logfile=debug.log ; if your smtp server requires authentication, modify the following two lines auth_username=mygmailid@gmail.com auth_password=mygmailpassword Finally this is the php file that i am trying to run <?php $to='reciever@gmail.com'; $subject='mysub'; $message='messagebody.'; $headers = 'From: mygmailid@gmail.com' . "\r\n" . 'Reply-To: mygmailid@gmail.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to,$subject,$message,$headers); echo 'see'; ?> when i use the port 586 I only get "see" (from the last line of my php file) but the recipients have not received any mail but when i use port 465 the page keeps on loading forever and nothing happens. I need to know what i'm doing wrong and how to fix it
  20. Hello, I am trying to create a registration module where an email would be sent to the user after registration. I am using xampp and have tried php mailer http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php4/0.90/ but couldn't get it to work... I've been told that it is possible to send an email from localhost through smtp... I need to know how to accomplish that. Am a beginner. suggestions and help would be appreciated
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.