fosh387 Posted May 3, 2010 Share Posted May 3, 2010 i'm trying to create a frind system in which the request is sent, and stores both the user and the recipent in database, however having som etrouble below are the scripts i have created so far, the trouble is that when "make friend" is clicked nothing actually happens - any help would be great <html> <link rel="stylesheet" type="text/css" href="web.css"/> <head> <title>Social.NET</title> <script type='text/javascript' src='http://edward/ajax/prototype.js'> </script> <script type='text/javascript'> function ajaxrequest() { var a = document.getElementById('school').value; var request = new Ajax.Request ('http://edward.solent.ac.uk/~FoshRachel/dissertation/search3.php', { method: 'post', parameters: 'school=' + a, onComplete: resultsReturned } ); } function resultsReturned(xmlHTTP) { document.getElementById('result').innerHTML = xmlHTTP.responseText; } function request(id) { var firstname = document.getElementById('id').value; var request = new Ajax.Request ('http://edward.solent.ac.uk/~FoshRachel/dissertation/request.php?firstname="+firstnamevalue+"', { method: 'get', parameters: 'id=' + id, onComplete: resultsReturned } ); } </script> <style type='text/css'> #result { border-style: ridge; border-color: #FF3300; border-width: 5px; background-color: #ffffff; width: 800px; height: 400px; overflow: auto } </style> </head> </head> <body> <h1>Social.NET</h1> <br/> <h3>Please enter your search details below</h3> <form method="post" action="search3.php"> <label for="school">SCHOOL:</label> <input name="school" id="school"/> <br/> <input type="button" value="Go!" onclick="ajaxrequest()" /> </form> <?php session_start(); $s=$_POST["school"]; $conn = mysql_connect("localhost", "FoshRachel", "chAcre8E"); mysql_select_db("FoshRachel"); $result=mysql_query("SELECT * FROM Users WHERE school='$s'"); if(mysql_num_rows($result)=="") { echo "NO results available<br/>"; echo "Click <a href='ajax3.html'>here</a> to try again"; } else { while($row = mysql_fetch_array($result)) echo "Name: " . $row['firstname'] . " " . $row['secondname'] . " <br/> School: " . $row['school'] . " <br/> Date of Birth: " . $row['day'] . "/" . $row['month'] . "/" . $row['year'] . "<br/>" . "<input type='button' value='Make Friend' action='request(id)'/>" . "<br/><br/>"; } mysql_close($conn); ?> <?php session_start(); $_POST["username"]=$u; $_POST["password"]=$p; // Test that the authentication session variable exists if ( !isset ($_SESSION["gatekeeper"])) { echo "You're not logged in. Go away!"; } else { $id = $_GET["firstname"]; $username = $_SESSION["gatekeeper"]; $conn = mysql_connect("localhost", "FoshRachel", "chAcre8E"); mysql_select_db("FoshRachel"); $result = mysql_query("select username from Users where firstname ='$id'"); $result2 = mysql_query("select username from Users where username='$username'"); $row=mysql_fetch_array($result); $row2=mysql_fetch_array($result2); mysql_query("INSERT INTO friends (friend, username, request) VALUES ('$row[friend]','$row2[username],'1')"); echo "A friendship request has been sent to $row[friend] "; mysql_close($conn); } ?> Link to comment https://forums.phpfreaks.com/topic/200532-request-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.