Avatar billede rboege Novice
17. april 2010 - 23:45

Form to Post - PHPBB

Tja, det jeg ønsker er at lave en Form to post funktion, så jeg har en formular seperat efter mit phpbb board (i samme direktory).

Det jeg overordnet ønsker er at gæster på boardet (siden) skal kunne udfylde en formular (recruitment formular) og posten/formularen bliver posted på forumet som en specific bruger.

jeg fandt dette script på nettet, som jeg tænkte jeg kunne bruge.. MEN, der er et "IF" i det, og dermed, kræver den at man skal være logget ind. og det er som sådan også fint nok, jeg ønsker bare dne automatisk logger ind som brugeren "Recruitment" med et password "recruitment312) eller lign, i ved sikkert hvad jeg mener.

Her er koden:

app.php

<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);


// Start session management
$user->session_begin();
$auth->acl($user->data);

if ($user->data['username'] == "Your ingame name here" || $user->data['username']== "Member")
{
echo "Please Login to the forums and try again.";
}
//echo "<script type=\"text/javascript\">".
//"window.close();".
//"</script>";
else
{
echo "<html>
<head><title>America's Army Application Form</title></head>
<body>
<form action='poster.php' method='post'>
Enter your America's Army Username: <input type='text' size='25' name='username' /><br>
Enter your PB Guid: <input type='text' MAXLENGTH='32' size='40' name='guid' /><br>
Enter your Age: <input type='text' MAXLENGTH='2'size='2' name='age' /><br>
Enter your Tracker ID: <input type='text' name='trackid' /><br>
Do you have a mic? <input type='text' name='mic' /><br>
Do you have Vent? <input type='text' name='vent' /><br>
Have you ever been banned by an Anti Cheating Community. If yes, Why? <input type='text' name='banned' /><br>
Why do you want to join this clan: <input type='text' name='reason' /><br>
If someone invited you to join the clan, please state his/her name: <input type='text' name='ref' /><br><br>
<input type='submit' />
</form>
</body>
</html>";
}


?>

-------------

poster.php

<?php

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);

//Yeah, I know this is not needed but I did it for simplicity
$username = $_POST["username"];
$guid = $_POST["guid"];
$age = $_POST["age"];
$tracker = $_POST["trackid"];
$microphone = $_POST["mic"];
$vent = $_POST["vent"];
$banned = $_POST["banned"];
$reason = $_POST["reason"];
$ref = $_POST["ref"];
$ip = $_SERVER["REMOTE_ADDR"];

$message = "AA Username: $username
PB Guid: http://www.hazardaaclan.com/history/accounthistory.php?guid=$guid
Age: $age
Tracker ID: http://aaotracker.com/usertracker.php?userid=$tracker
Mic? $microphone
Ventrilo? $vent
Banned? $banned
Reason for wanting to join? $reason
Refered by: $ref";

$time = time();

// note that multibyte support is enabled here
$rawsubject = "Americas Army Application for $username";
$my_subject    = utf8_normalize_nfc($rawsubject, '', true);
$my_text    = utf8_normalize_nfc($message, '', true);

// variables to hold the parameters for submit_post
$poll = $uid = $bitfield = $options = '';

generate_text_for_storage($my_subject, $uid, $bitfield, $options, false, false, false);
generate_text_for_storage($my_text, $uid, $bitfield, $options, true, true, true);

$data = array(
    'forum_id'        => 9,
    'icon_id'        => false,

    'enable_bbcode'        => true,
    'enable_smilies'    => true,
    'enable_urls'        => true,
    'enable_sig'        => true,

    'message'        => $my_text,
    'message_md5'    => md5($my_text),
               
    'bbcode_bitfield'    => $bitfield,
    'bbcode_uid'        => $uid,

    'post_edit_locked'    => 0,
    'topic_title'        => $my_subject,
    'notify_set'        => false,
    'notify'            => false,
    'post_time'         => 0,
    'forum_name'        => '',
    'enable_indexing'    => true,
);

submit_post('post', $my_subject, $user->data['username'], POST_NORMAL, $poll, $data);

echo "Application Submitted, You may close this window.";

?>

-----

Håber inderligt der er nogen experter derude der kan hjælpe med dette.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester