PDA

View Full Version : PHP Form to vB Thread



Moh
02-07-2008, 03:57 PM
Is there any way I can have a PHP Form (Different Server to Forum) which submits the information to a Forum Thread?

So it would log into an account with permissions to post in that cat, and post the inflammation submitted as a new thread (With a custom title also).

Does anyone know anyway of doing this?

Thanks in advanced.

Independent
02-07-2008, 05:37 PM
Is there any way I can have a PHP Form (Different Server to Forum) which submits the information to a Forum Thread?

So it would log into an account with permissions to post in that cat, and post the inflammation submitted as a new thread (With a custom title also).

Does anyone know anyway of doing this?

Thanks in advanced.
Copy the code of the postreply, then set the database up so it connects and does the thread?

today
02-07-2008, 08:35 PM
There's a mod to send all contact us emails to threads instead? Edit the templates for the contact us page.?

Agnostic Bear
02-07-2008, 09:55 PM
Is there any way I can have a PHP Form (Different Server to Forum) which submits the information to a Forum Thread?

So it would log into an account with permissions to post in that cat, and post the inflammation submitted as a new thread (With a custom title also).

Does anyone know anyway of doing this?

Thanks in advanced.

Yep, there's definitely a way to do it :)

Moh
04-07-2008, 12:30 PM
Copy the code of the postreply, then set the database up so it connects and does the thread?
Yea, I kinda did that, but didn't copy the code.

It takes a second to load though :@

It has to do:


Inserts the post to the posts database
Gets the post id from the post database
Inserts the thread to the thread database
Gets the thread id from the thread database
Updates the posts if with the thread information in the posts database
Updates the forum information in the forum database - this allows us to see them on the "New Posts" and the "Newest Posts".



There's a mod to send all contact us emails to threads instead? Edit the templates for the contact us page.?
Yea, we got that one for the forum contact us, but we also have one for the site.

mat64
06-07-2008, 11:15 AM
There used to be a hack for vBulletin called "Form Hack" which you can see here (http://www.vbulletin.org/forum/showthread.php?t=126676). It's a 3.6 addon however so it might not work aswell as you hope. But if your handy with PHP you might be able to use elements of this to get what your looking for.

Moh
07-07-2008, 07:10 PM
There used to be a hack for vBulletin called "Form Hack" which you can see here (http://www.vbulletin.org/forum/showthread.php?t=126676). It's a 3.6 addon however so it might not work aswell as you hope. But if your handy with PHP you might be able to use elements of this to get what your looking for.
Yea, I did it manually.

If any one else wishes to do this, this is the code which does it:


require_once('./global.php');
require_once('./includes/class_dm.php');
require_once('./includes/class_dm_threadpost.php');

$title = "$name - $reason";
$pagetext = "Name: $name
Email: $email
Reason: $reason
Message: $message
IP: $ip";
$dateline = time();
$username = "Admin"; // Enter the username of the user you wish to submit the post
$userid = "1"; // Enter the user id of the username
$forumid = "1"; // Enter the forum cat id you wish the post to be posted in

mysql_query("INSERT INTO `post` (`username`, `userid`, `title`, `dateline`, `pagetext`, `ipaddress`, `visible`, `allowsmilie`) VALUES ('$username', '$userid', '$title', '$dateline', '$pagetext', '$ip', '1', '1')");

$sql = mysql_query("SELECT * FROM `post` WHERE `username` = '$username' AND `userid` = '$userid' AND `ipaddress` = '$ip' AND `title` = '$title'");
$fetch = mysql_fetch_array($sql);

$post_id = $fetch["postid"];

mysql_query("INSERT INTO `thread` (`title`, `firstpostid`, `lastpostid`, `lastpost`, `forumid`, `postusername`, `postuserid`, `lastposter`, `dateline`, `visible`) VALUES ('$title', '$post_id', '$post_id', '$dateline', '$forumid', '$username', '$username', '$username', '$dateline', '1')");

$sqls = mysql_query("SELECT * FROM `thread` WHERE `lastpost` = '$dateline'");
$fetchs = mysql_fetch_array($sqls);

$thread_id = $fetchs["threadid"];

mysql_query("UPDATE `post` SET `threadid` = '$thread_id', `parentid` = '$thread_id' WHERE `postid` = '$post_id'");

$sqlss = mysql_query("SELECT * FROM `forum` WHERE `forumid` = '$forumid'");
$fetchss = mysql_fetch_array($sqlss);
$threadcount = $fetchss["threadcount"];
$newthreadcount = $threadcount + 1;

mysql_query("UPDATE `forum` SET `lastpost` = '$dateline', `lastposter` = '$username', `lastpostid` = '$post_id', `lastthread` = '$title', `lastthreadid` = '$thread_id', `threadcount` = '$newthreadcount' WHERE `forumid` = '$forumid'");

Want to hide these adverts? Register an account for free!