| | |
value pass from one script to another script
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2008
Posts: 5
Reputation:
Solved Threads: 0
Hi.. I am new in php +ajax.....Now i am doing project in php+ajax+linux environment...i create a login page using php,ajax,mysql,, i have mysql tables are. register,slideshow,,,,,In register table having following field...
1.uid (autoincrement)2.first (firstname)3.last(surname)4.user(username),5.pass(password)
In slide show table having following field,,,
1.uid 2.pid(presentation id,autoincrment) 3.slideno 4.description 5.location(this is what image file is store that particular location)..
my login programs are..
//login.html
The above program is successfully logged .. and i fetch uid in $insert variable...This is my quetion...
uid,pid,slideno,description,location will be stored automaticallyin slideshow table..while i upload file....
my upload proram is given below...
please send me the correct coding ..
1.uid (autoincrement)2.first (firstname)3.last(surname)4.user(username),5.pass(password)
In slide show table having following field,,,
1.uid 2.pid(presentation id,autoincrment) 3.slideno 4.description 5.location(this is what image file is store that particular location)..
my login programs are..
//login.html
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<html> <head> <script language="javascript" type="text/javascript"> //Browser Support Code function ajaxFunction() { var ajaxRequest; // The variable that makes Ajax possible! try { // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e) { // Internet Explorer Browsers try { ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function() { if(ajaxRequest.readyState == 4) { var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; document.getElementById('message').style.visibility = 'hidden'; } } var user= document.getElementById('user').value; var pass= document.getElementById('pass').value; var queryString = "?user=" + user + "&pass=" + pass; document.getElementById('message').style.visibility = 'visible'; ajaxRequest.open("GET","login.php" + queryString, true); ajaxRequest.send(null); } </script> </head> <body> <div id="message" style="position:absolute; top:1%; left:95%; margin-left:-100px; font-size:14;background-color: red ;color: white;width: 165px; height: 25px; overflow: auto;visibility: hidden">Executing...</div> <form> <center> <img src="" style="visibility:hidden" width="0%" height="0%"> <table border="0" bgcolor="#CCCCFF" cellspacing="1" cellpadding="3" width="287"> <tr> <td align="left" colspan="2" width="275"><b><font size="5" color="#000080">Login</font></b></td> </tr> <tr> <td align="right" width="81"><b><font color="#000080">User Name:</font></b></td> <td width="184"> <input type="text" id="user"> </td> </tr> <tr> <td align="right" width="81"><b><font color="#000080">Password:</font></b></td> <td width="184"> <input type="password" id="pass"> </td> </tr> <tr> <td colspan="2" align="center" width="275"><input type="button" onclick="ajaxFunction()" value="Login" ></td> </tr> </table> <div id="ajaxDiv"> </center> </form> </body> </html> //login.php <?php $user=$_GET['user']; $pass=$_GET['pass']; $conn = mysql_connect("localhost","root","") or die("could not connect server"); $db = mysql_select_db("thiru",$conn) or die("could not connect database"); $query= "select * from register"; $res = mysql_query($query) or die("query failed" . mysql_error()); $num_rows=mysql_num_rows($res); while($rr=mysql_fetch_array($res)) { if($user==$rr[3] && $pass==$rr[4]) { //get uid $insert=$rr[0]; //echo"welcome" .$user; $flag=true; } } if($flag==false) { echo"userid and password mismatch"; } mysql_close($conn); ?>
uid,pid,slideno,description,location will be stored automaticallyin slideshow table..while i upload file....
my upload proram is given below...
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
//upload.html file <html> <head> <script type="text/javascript" language="javascript"> function upload() { var oForm = document.uploadform; oForm.submit(); } </script> </head> <body> <div id="message" class="drag" style="position:absolute; top:50%; left:50%; margin-left:-100px; font-size:12;background: transparent; width: 75px; height: 75px; overflow: auto; visibility: hidden"> </div> <center> <form name="uploadform" action="upload.php" method="POST" ENCTYPE="multipart/form-data" target="hiddenFrame"> Open : <input style="font:normal 10px Verdana" size="35" align="left" type="file" name="code" id="code"> <br><button onClick="upload();return false">Upload</button> </form> <iframe src="about:blank" name="hiddenFrame" width="400" height="400" frameborder="1" ></iframe> </center> </body> </html> //upload php file <?php $uploaddir='/var/www/html/upload/'; $uploadfile=$uploaddir.basename($_FILES['code']['name']); echo '<pre>'; if (move_uploaded_file($_FILES['code']['tmp_name'], $uploadfile)) { echo "File was successfully uploaded.\n"; print "</pre>"; $conn=mysql_connect("localhost","root",""); $db=mysql_select_db("thiru"); $query = "insert into slide(sloc)values('$uploadfile')"; $result=mysql_query($query); echo"<br>"; mysql_close($conn); $filename=$_FILES['code']['name']; echo"filename:"; echo $filename; echo"<br>"; } else { echo "please choose a correct file!!"; } ?>
Last edited by ~s.o.s~; Apr 23rd, 2008 at 2:46 pm. Reason: Added code tags, learn to use them.
![]() |
Similar Threads
- How to pass the parameters to a script? (Python)
- how can i pass a value from java script to JSP scriplet (JSP)
- pass value in cgi script to javascript (JavaScript / DHTML / AJAX)
- How to pass the values of javascript in perl (JavaScript / DHTML / AJAX)
- Auto Addition Script (PHP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Graphs
- Next Thread: Delay placing links
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box browser captchaformproblem cart child close codes column css date debugger decimal dependent design disablefirebug dom download element embed engine enter error events ext file firefox form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp jump libcurl listbox maps masterpage math media menu microsoft mimic mp4 onmouseoutdivproblem onmouseover onreadystatechange paypal pdf php player position post problem programming prototype redirect regex safari scale scriptlets scroll search security select software sql textarea unicode w3c web website window windowofwords \n





