Jump to content

request help?


fosh387

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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