</div>!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Freak </title> <link rel="stylesheet" href="root/Style/Style.css"> <link rel="stylesheet" href="root/Style/content.css"> <script language="javascript" type="text/javascript"> function ajax_post(){ // Creat out XMLHttpRequest Object var hr = new XMLHttpRequest(); // Creat some variables we need to send to out php file var url = "my_parse_file.php"; var fn = document.getElementById("first_name").value; //var ln = document.getElementById("last_name").value; //var vars = "firstname="+fn+"&lastname="+ln; var vars = "firstname="+fn; hr.open("POST",url,true); //set content type header information for sending url encoded variables in the request hr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); // Access the onreadystatechange event for the XMLHttpRequest object hr.onreadystatechange = function(){ if(hr.readyState==4 && hr.status==200) { var return_data = hr.responseText; document.getElementById("status").innerHTML = return_data; } } // send the data to PHP now ... and wait for response to update the status div hr.send(vars);// actually execute the request document.getElementById("status").innerHTML = "processing..."; document.getElementById("first_name").value=""; } </script> </head> <body> <?php include_once("Template_PageTop.php");> <div id="pageMiddle"> <div id="sidebar"> <img src="root/Style/noimage.gif" alt="" id="profilepic" > <div id="profilename">Jems Saiyed </div> <a href=""><img src="root/Style/friend reqest_sidebar.png" alt=""></a> <a href=""> Friends </a> <br> <a href=""><img src="root/Style/classmates_sidebar.png" alt=""></a> <a href=""> Classmates </a> <br> <a href=""><img src="root/Style/photos_sidebar.png" alt=""></a> <a href="">Photos</a> <br> <a href=""><img src="root/Style/message_sidebar.png" alt=""></a> <a href="">Messages</a> </br></br></br></div> <div id="sidebar-b"> Status of the week </div> <div id="content"> <br> <a href=""><img src="root/Style/photos_sidebar.png" alt=""> Share Photo/Video</a> <br> <form action="inst.php" method="post"> <textarea name="first_name" style="width:50%;height:100px;"> </textarea> <input name="myBtn" type="submit" value="post" onClick="javascript:ajax_post();" style="margin-left:45%"> </form> <div id="contener"> <div id="status" style="margin:10px;"></div> </div> </br></br></div> </div> <?php include_once("Template_PageBottom.php"); > </body> </html> my_pase_file.php <php <br mode="hold" />echo $_POST['firstname']; >>inst.php $con = mysqli_connect('localhost',"root",""); mysqli_select_db($con,"dbsocial"); $firstname = $_POST['first_name']; echo $firstname; $sql = "SELECT * FROM status"; mysqli_query($con,"INSERT INTO status (data) VALUES ('$firstname') "); $result = mysqli_query($con,$sql); while($row = mysqli_fetch_array($result)) { echo "<hr>".$row['data'];"<hr>"; } $output = mysqli_query($con,$sql); mysqli_close($con);
Quote:<textarea name="first_name" id = "first_name" style="width:50%;height:100px;"> </textarea> <input name="myBtn" type="submit" value="POST" onClick="javascript:ajax_post();" style="margin-left:45%">
Quote:<form action="inst.php" method="post"> <textarea name="first_name" style="width:50%;height:100px;"> </textarea> <input name="myBtn" type="submit" value="post" onClick="javascript:ajax_post();" style="margin-left:45%"> </form>
Quote: $firstname = $_POST['firstname']; $con = mysqli_connect('localhost',"root",""); mysqli_select_db($con,"dbsocial"); $sql = "SELECT * FROM status Order by Id DESC"; mysqli_query($con,"INSERT INTO status (data) VALUES ('$firstname')"); $result = mysqli_query($con,$sql); while($row = mysqli_fetch_array($result)) { echo "".$row['data'];""; } $output = mysqli_query($con,$sql); mysqli_close($con); ?>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)