Jump to content

php function not being called


MDanz

Recommended Posts

Here's some of my code.  The fault is when AJAX sends the dataString to sendpm.php, it should call the function.  But nothing is happening.  If i put the sendprivatemessage query in sendpm.php page, the data is sent to mysql.  What is the solution, so i don't have to put the query on sendpm.php?

 

jquery - some of it

$.ajax({
	type: "POST",
	url: "/sendpm.php",
	data: dataString,
	success: function() {
	window.location.href = 'http://www.stackway.com/cp/messages=outbox';
	}

	});

 

sendpm.php

include "database.php";

$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['subject'];
$body = $_POST['body'];

$database2 = new Database();
$database2->opendb();
$database2->sendprivatemessage($to,$from,$subject,$body);
$database2->closedb();

 

 

sendprivatemessage function

function sendprivatemessage($to,$from,$subject,$body) {

	$insert = mysql_query("INSERT INTO privatemessage VALUES ('','$subject','$body','$to','$from','1',NOW(),'','','')",$this-connect);

	}

 

Link to comment
https://forums.phpfreaks.com/topic/248774-php-function-not-being-called/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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