Jump to content

ra_ie_darkness

Members
  • Posts

    22
  • Joined

  • Last visited

Profile Information

  • Gender
    Female

ra_ie_darkness's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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
×
×
  • 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.