Monkuar Posted May 8, 2009 Share Posted May 8, 2009 I got the variables down and everything it works I even tested it!! But I want it to send the message when somone fills it out instead of everytime i refresh it sends the message, lol thanks $SDK->write_pm ("1", "Hello!", "Hello! This is a test message sent to user id 1"); Currently everytime i refresh my page it sends this message to user id 1 of my forum [witch is me] and title: Hello! and message next.. How can i put this into a form so people can fill out what to say and to who and click submit.. so it doesnt send message everytime u refresh. here is the function for it: function write_pm($to_id, $title, $message, $cc = array(), $sentfolder = '0') { if (!$this->is_loggedin()) { $this->sdkerror($this->lang['sdk_membersonly']); return FALSE; } if (!$to_id) { $this->sdkerror($this->lang['sdk_pm_no_recipient']); return FALSE; } if (!$title OR strlen($title) < 2) { $this->sdkerror($this->lang['sdk_pm_title']); return FALSE; } if (!$message OR strlen($message) < 2) { $this->sdkerror($this->lang['sdk_pm_message']); return FALSE; } $sendto = array(); $this->DB->query("SELECT m.name, m.id, m.view_pop, m.mgroup, m.email_pm, m.language, m.email, m.msg_total, g.g_use_pm, g.g_max_messages FROM ibf_groups g, ibf_members m WHERE m.id='" . intval($to_id) . "' AND g.g_id=m.mgroup"); if ($row = $this->DB->fetch_row()) { // Just incase if (!$row['id']) { $this->sdkerror($this->lang['sdk_pm_mem_notexist']); return FALSE; } // Permissions Check if ($row['g_use_pm'] != '1') { $this->sdkerror($this->lang['sdk_pm_mem_disallowed']); return FALSE; } // Space Check if ($row['msg_total'] >= $row['g_max_messages'] AND $row['g_max_messages'] > 0) { $this->sdkerror($this->lang['sdk_pm_mem_full']); return FALSE; } // Block Check if ($this->is_pmblocked($GLOBALS['ibforums']->member['id'], intval($to_id))) { $this->sdkerror($this->lang['sdk_pm_mem_blocked']); return FALSE; } // CC Users $ccusers = array(); if ($GLOBALS['ibforums']->member['g_max_mass_pm']) { if (is_array($cc) AND count($cc) > 0) { if (count($cc) > $GLOBALS['ibforums']->member['g_max_mass_pm']) { $this->sdkerror($this->lang['sdk_pm_cclimit']); return FALSE; } foreach ($cc AS $i) { // Check CC user stuff // I really should clean up the code here, it uses alot of queries in some cases, which isn't good. Should really merge this with the main sending message code instead of replicating stuff for CCs. $this->DB->query("SELECT m.name, m.id, m.view_pop, m.mgroup, m.email_pm, m.language, m.email, m.msg_total, g.g_use_pm, g.g_max_messages FROM ibf_groups g, ibf_members m WHERE m.id='" . intval($to_id) . "' AND g.g_id=m.mgroup"); if ($ccrow = $this->DB->fetch_row()) { // Permissions Check if ($ccrow['g_use_pm'] != '1') { $this->sdkerror($this->lang['sdk_pm_rec_disallowed']); return FALSE; } // Space Check if ($ccrow['msg_total'] >= $ccrow['g_max_messages'] AND $ccrow['g_max_messages'] > 0) { $this->sdkerror($this->lang['sdk_pm_rec_full']); return FALSE; } // Block Check if ($this->is_pmblocked($GLOBALS['ibforums']->member['id'], intval($to_id))) { $this->sdkerror($this->lang['sdk_pm_rec_blocked']); return FALSE; } } $ccusers[] = intval($i); } } } // Actually send it $ccusers[] = intval($to_id); foreach ($ccusers as $recipient) { $DBstring = $GLOBALS['std']->compile_db_string(array('member_id' => $recipient, 'msg_date' => time(), 'read_state' => '0', 'title' => $title, 'message' => $GLOBALS['std']->remove_tags($message), 'from_id' => $GLOBALS['ibforums']->member['id'], 'vid' => 'in', 'recipient_id' => $recipient, 'tracking' => '0', )); // Insert $this->DB->query ('INSERT INTO ibf_messages (' . $DBstring['FIELD_NAMES'] . ') VALUES (' . $DBstring['FIELD_VALUES'] . ')'); unset($this->DBstring); $this->DB->query("UPDATE ibf_members SET msg_total = msg_total + 1, new_msg = new_msg + 1, msg_from_id='" . $GLOBALS['ibforums']->member['id'] . "', show_popup='1', msg_msg_id='" . $this->DB->get_insert_id() . "' WHERE id='" . $recipient . "'"); } if ($sentfolder) { $DBstring = $GLOBALS['std']->compile_db_string(array('member_id' => $GLOBALS['ibforums']->member['id'], 'msg_date' => time(), 'read_state' => '0', 'title' => 'Sent: ' . $title, 'message' => $GLOBALS['std']->remove_tags($message), 'from_id' => $GLOBALS['ibforums']->member['id'], 'vid' => 'sent', 'recipient_id' => $recipient, 'tracking' => '0', )); $this->DB->query ('INSERT INTO ibf_messages (' . $DBstring['FIELD_NAMES'] . ') VALUES (' . $DBstring['FIELD_VALUES'] . ')'); } return TRUE; } else { $this->sdkerror($this->lang['sdk_pm_mem_notexist']); return FALSE; } } if u needed that just incase ;p; Everything thing works I just need know how to make a form so people can fill it out and press submit for it to work instead of refreshing page and then it load all the time.. Quote Link to comment https://forums.phpfreaks.com/topic/157326-how-do-i-add-this-into-a-form/ Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 In a PHP file, use xHTML to write out the form with the necessary fields (message, title, etc). Using PHP, check if the form is submitted and if so, send the PM. Quote Link to comment https://forums.phpfreaks.com/topic/157326-how-do-i-add-this-into-a-form/#findComment-829214 Share on other sites More sharing options...
Monkuar Posted May 8, 2009 Author Share Posted May 8, 2009 In a PHP file, use xHTML to write out the form with the necessary fields (message, title, etc). Using PHP, check if the form is submitted and if so, send the PM. I cant use xhtml only html Can u start the form for me, I can finish i hope and i can hope i use html Quote Link to comment https://forums.phpfreaks.com/topic/157326-how-do-i-add-this-into-a-form/#findComment-829216 Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 Well, there isn't a huge difference between xHTML and HTML. So use HTML to write the form. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/157326-how-do-i-add-this-into-a-form/#findComment-829219 Share on other sites More sharing options...
Monkuar Posted May 8, 2009 Author Share Posted May 8, 2009 Can somone start the form out for me im very lost, i could finish it.. Thanks phpfreaks.com.. Quote Link to comment https://forums.phpfreaks.com/topic/157326-how-do-i-add-this-into-a-form/#findComment-829434 Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 This forum doesn't handle requests. Please read #12 of Forum Rules. Follow the link in my signature. But if you can't write a form, it's most likely you will need someone to write this for you. o.o Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/157326-how-do-i-add-this-into-a-form/#findComment-829437 Share on other sites More sharing options...
Monkuar Posted May 8, 2009 Author Share Posted May 8, 2009 This forum doesn't handle requests. Please read #12 of Forum Rules. Follow the link in my signature. But if you can't write a form, it's most likely you will need someone to write this for you. o.o Thank you! im not requesting anything.. this is php help isnt it? looks like no help for me Quote Link to comment https://forums.phpfreaks.com/topic/157326-how-do-i-add-this-into-a-form/#findComment-829854 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.