JW09 Posted February 9, 2009 Share Posted February 9, 2009 Hi, I'm messing about with a SMF forum trying to add new stuff. I have made two new sections in Profile section. I managed to submit to a new table in database by adding this to index.php array .. $actionArray = array( 'ventSubmit' => array('ventSubmit.php', 'ventSubmit'), This uses ventSubmit.php in Sources and I use ventSubmit for action in form in profile.template. Works but now I cannot do the same thing for the second section called ventChoose. I make the array use ventChoose and I know for a fact that ventChoose.php is correct cause I checked it in browser directly, it loads all data from musicians database field into jump menu. But when I put this code in profile.template .. function template_ventChoose() { global $context, $settings, $options, $scripturl, $modSettings, $txt; echo ' <form action="', $scripturl, '?action=ventChoose" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator" enctype="multipart/form-data"> <SELECT NAME=id> <OPTION VALUE=0> <?=$options?> </SELECT> </form>'; } It creates a jump menu but with nothing in it at all. Another problem I forsee is that I want to insert the chosen jump menu field into the members table for that member. Is going way over my heard now, got me stumped. Here's the forum http://www.eoaa.org/entvent.info/forum/index.php usename test password 12345678 Go to Profile, there you see two new sections "Submit vent" and "Choose vent". Only the first field Top five musicians works for Submit vent, put text in there and then go to http://www.eoaa.org/entvent.info/forum/Sources/ventChoose.php your text is there but when I use this php file for the ventChoose section it don't work as you can see in Choose vent, it's blank. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/144427-add-new-profile-sections-to-smf-forum/ Share on other sites More sharing options...
JW09 Posted February 9, 2009 Author Share Posted February 9, 2009 Hey, I uploaded bad file then got distracted. Is right now .. I think I've narrowed it down to the profile.template.php. This .. <form action="', $scripturl, '?action=ventChoose" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator" enctype="multipart/form-data"> <SELECT NAME=id> <OPTION VALUE=0> <?=$options?> </SELECT> </form>'; } I thought the action would load the php and apply to <?=$options?> but then I found out that actions are 'applied' after submit and not on load. So I need something in between the <form> and <select> to load the php file so that <?=$options?> knows what to do. Then I can probably use regular profile2 action to submit the fields to a members profile. Quote Link to comment https://forums.phpfreaks.com/topic/144427-add-new-profile-sections-to-smf-forum/#findComment-757989 Share on other sites More sharing options...
Mchl Posted February 9, 2009 Share Posted February 9, 2009 I think there's SMF mod that allows for adding custom fields to profile... or maybe that was Joomla mod... can't recall... Quote Link to comment https://forums.phpfreaks.com/topic/144427-add-new-profile-sections-to-smf-forum/#findComment-758000 Share on other sites More sharing options...
JW09 Posted February 9, 2009 Author Share Posted February 9, 2009 Yea there is, I've used it great addon but not right for my needs. I need to submit to unique table otherwise I can't control it. Right this is the final hurdle .. If you go to Choose vent section now the menu displays data from data submitted in Submit vent section, great. The only problem is I cannot write the chosen jump menu field to the members table. It writes but it's a blank, the first field is blank so I assume it's using the first field. Here's the code .. <SELECT NAME=T5a_musicians> <option value="$mus"', ($context['member']['T5a_musicians']['name'] == 'm' ? ' selected="selected"' : ''), '>', $mus, '</option> </SELECT>'; This is actually copied from the gender jump menu. $mus is from the included ventChoose.php file and that's what draws the data into the jump menu but it won't write to T5a_musicians. The second $mus is language or 'what's displayed' code, if I put '$mus' the first field is $mus and it submits $mus text to members table. When I remove the quotes the menu populates with correct data but is not submitted to database. The 'm' is for male, femail option uses 'f', I've no idea what they are for or what they relate to. For some reason the jump menu fields don't stick when submitted. Quote Link to comment https://forums.phpfreaks.com/topic/144427-add-new-profile-sections-to-smf-forum/#findComment-758135 Share on other sites More sharing options...
JW09 Posted February 10, 2009 Author Share Posted February 10, 2009 Anyone know why it doesn't post the selected field? I thought maybe the php file for $mus might need so adjustments to make the selection stick. Here's the code for included php file .. <?php $dbhost = 'xxx'; $dbuser = 'xxx'; $dbpass = 'xxx'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'xxx'; mysql_select_db($dbname); $sql="SELECT ID, musicians FROM table order by musicians"; $result=mysql_query($sql); $mus=""; while ($row=mysql_fetch_array($result)) { $ID=$row["id"]; $musicians=$row["musicians"]; $mus.="<OPTION VALUE=\"$id\">".$musicians; } ?> Like I said, it is writing to the database but it's sending a blank. Quote Link to comment https://forums.phpfreaks.com/topic/144427-add-new-profile-sections-to-smf-forum/#findComment-758586 Share on other sites More sharing options...
JW09 Posted February 12, 2009 Author Share Posted February 12, 2009 I've been trying something different but can anyone say why the <option> code returns a 0 (zero). function template_ventChoose() { global $context, $settings, $options, $scripturl, $modSettings, $txt, $row_vcmusicians; include 'ventChoose.php'; echo' <form action="', $scripturl, '?action=profile2" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator" enctype="multipart/form-data"> <select name="T5a_musicians"> <option value="', $row_vcmusicians['musicians'], '"', $row_vcmusicians['musicians'] == $row_vcmusicians['musicians'] ? ' selected="selected"' : '', '>', $row_vcmusicians['musicians'], '</option>'; while ($row_vcmusicians = mysql_fetch_assoc($vcmusicians)); $rows = mysql_num_rows($vcmusicians); if($rows > 0) { mysql_data_seek($vcmusicians, 0); $row_vcmusicians = mysql_fetch_assoc($vcmusicians); } echo' </select>'; This is a new method of populating the menu. It works in htm except I had to edit the option a bit because it's within a function. Here's the working code in htm .. <select name="T5a_musicians" id="T5a_musicians"> <?php do { ?> <option value="<?php echo $row_vcmusicians['musicians']?>"><?php echo $row_vcmusicians['musicians']?></option> <?php } while ($row_vcmusicians = mysql_fetch_assoc($vcmusicians)); $rows = mysql_num_rows($vcmusicians); if($rows > 0) { mysql_data_seek($vcmusicians, 0); $row_vcmusicians = mysql_fetch_assoc($vcmusicians); } ?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/144427-add-new-profile-sections-to-smf-forum/#findComment-760234 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.