Customizing SMF > Portals, Bridges, and Integrations

Need help with smf_1-1_api and my other script

(1/1)

staphilus:
Hi guys

I've been trying to integrate my SMF forum with an other script, but I can't get it working!!

I use SMF 1.1.16 with smf_1-1_api.php

The code I use in the signup page of my script is :


--- Code: --- // smf api   
$username = $_POST['uUsername'];
$email = $_POST['uEmail'];   
$passwd = $_POST['uPassword'];
require_once("forum/smf_1-1_api.php");
         smf_registerMember($username, $email, $passwd, $extra_fields = array(), $theme_options = array());   
// api end     
--- End code ---


And for the login page is:


--- Code: ---// smf api               
include_once ("forum/smf_1-1_api.php");
$cookiename = $smf_settings['cookiename'];
$username = $form_user;
$password = $form_pwd;
unset($_COOKIE[$cookiename]);
smf_setLoginCookie(3600, $username, $password, $encrypted = false);
smf_authenticateUser();               
// smf api end         
--- End code ---

I found these codes on other forum, however I just can't make it work !!

The main script is in mysite.com/pages  and the forum in mysite.com/forum
 I don't know where to add those codes on the signup.php and the login.php pages !!

This is the signup.php code:


--- Code: ---<script language="php"> include("setup.php");  plugin("signupcontrol"); </script>
<script language="php"> include("header.php");</script>
<table width="100%" border="0" cellspacing="5" cellpadding="5">
<tr>
<td><p>&nbsp;</p><p><b>To complete the sign up process, you must provide the requested information below.</b></p><br>
<form method="POST">
<input type="hidden" name="user_form" value="signup">
<input type="hidden" name="userform[code]" value="<script language="php"> userform("code");</script>">
<table width="100%" border="0" cellpadding="0" cellspacing="0" name="Errors">
<input type="hidden" name="required" value='username,email,first_name,last_name,address,city,state,zipcode,country,password'>
<script language="php"> form_errors("username","You must place a username in the username field","The username you select is already in use please try another","<tr><td colspan=2 bgcolor=red align=center><font color=ffffff><b>","</b></font></td></tr>");</script>
<script language="php"> form_errors("email","You must place an email address in the email address field","The email address you select is already in use please try another","<tr><td colspan=2 bgcolor=red align=center><font color=ffffff><b>","</b></font></td></tr>");</script>
<script language="php"> form_errors("first_name","You must place your first name in the first name field","N/A","<tr><td colspan=2 bgcolor=red align=center><font color=ffffff><b>","</b></font></td></tr>");</script>
<script language="php"> form_errors("last_name","You must place your last name in the last name field","N/A","<tr><td colspan=2 bgcolor=red align=center><font color=ffffff><b>","</b></font></td></tr>");</script>
<script language="php"> form_errors("address","You must place your street address in the address field","N/A","<tr><td colspan=2 bgcolor=red align=center><font color=ffffff><b>","</b></font></td></tr>");</script>
<script language="php"> form_errors("state","You must place your state in the state field or type N/A if you do not have a state","N/A","<tr><td colspan=2 bgcolor=red align=center><font color=ffffff><b>","</b></font></td></tr>");</script>
<script language="php"> form_errors("city","You must place your city in the city field","N/A","<tr><td colspan=2 bgcolor=red align=center><font color=ffffff><b>","</b></font></td></tr>");</script>
<script language="php"> form_errors("zipcode","You must place your zip or postal code in the zip code field","N/A","<tr><td colspan=2 bgcolor=red align=center><font color=ffffff><b>","</b></font></td></tr>");</script>
<script language="php"> form_errors("country","Please select your country","N/A","<tr><td colspan=2 bgcolor=red align=center><font color=ffffff><b>","</b></font></td></tr>");</script>
<script language="php"> form_errors("refid","The referrer does not exist. Please enter a valid referrer or leave blank","N/A","<tr><td colspan=2 bgcolor=red align=center><font color=ffffff><b>","</b></font></td></tr>");</script>
<script language="php"> form_errors("keyword","You have not selected the correct amount of interests","N/A","<tr><td colspan=2 bgcolor=red align=center><font color=ffffff><b>","</b></font></td></tr>");</script>
<script language="php"> form_errors("password","The password you entered did not match what you put in the confirmation field","N/A","<tr><td colspan=2 bgcolor=red align=center><font color=ffffff><b>","</b></font></td></tr>");</script>
</table>
<table border=0 width=100% cellspacing="5" cellpadding="5" align="center"><tr>
<td colspan=2 align=center>If you only wish to advertise with us and do not wish become an affiliate, check this box <input type=checkbox name="userform[account_type]" value='advertiser' <? userform('account_type')?>><br>Advertiser accounts will not receive paid emails nor will they receive any of the benifits that are given to affiliates</td></tr>
<td>Username:<br><font size=1>Use letters and numbers only</font></td>
<td><input type="text" name="userform[username]" maxlength=16 value="<script language="php">
userform("username");</script>"></td>
</tr><tr>
<td>E-Mail:</td>
<td><input type=hidden name="userform[email]" value="<script language="php"> userform("email");</script>">
<script language="php"> userform("email");</script></td>
</tr><tr>
<td><div align="left">Send emails to:</div></td><td>
<select name=userform[email_setting]>
<script language="php"> new_member_email_setting();</script>
</select>
</td></tr><tr>
<td>First Name:</td>
<td><input type="text" name="userform[first_name]" value="<script language="php">
userform("first_name");</script>"></td>
</tr><tr>
<td>Last Name:</td>
<td> 
<input type="text" name="userform[last_name]" value="<script language="php">
userform("last_name");</script>"> </td>
</tr><tr>
<td>Address:</td>
<td> 
<input type="text" name="userform[address]" value="<script language="php">
userform("address");</script>"> </td>
</tr><tr>
<td>City:</td>
<td> 
<input type="text" name="userform[city]" value="<script language="php">
userform("city");</script>"> </td>
</tr>
<tr>
<td>State:</td>
<td><select name="userform[state]"><option value=''>Please select your state
<script language="php"> new_member_states();</script>
</select>
<br>Other: <br>                                         
<input type="text" name="userform[state_other]" value="<script language="php"> userform("state_other");</script>"></td>
</tr><tr>
<td>Zip Code:</td>
<td><input type="text" name="userform[zipcode]" value="<script language="php">
userform("zipcode");</script>"></td>
</tr>
<tr>
<td>Country:</td>
<td> 
<select name="userform[country]"><option value=''>Please select your country
<script language="php"> new_member_countries();</script>
</select>
</td>
</tr>
<tr>
<td>Referred by:</td>
<td><input type=text name=refid value="<script language="php"> referrer();</script>"> <br>(If no referrer, a GoldAffiliate will be assigned)</td>
</tr>
<tr>
<td colspan=2>
<hr>
</td>
</tr><tr>
<td colspan=2 align=center> Select categories of interests to
you:<br><br>
<table border="0" cellspacing="1" cellpadding="1" width="100%">
<script language="php"> new_member_keywords();</script>
</table></td></tr><tr>
<td colspan=2><hr></td>
</tr><tr>
<td colspan=2 align=center> 
<select name=userform[pay_type]>
<option value='' selected>Select a payment method
<script language="php"> new_member_paytypes();</script>
</select></td>
</tr><tr>
<td colspan=2 align=center>Payment account ID:<br>
<input type=text size=25 value="<script language="php">
userform("pay_account");</script>" name=userform[pay_account]> </td>
</tr><tr>
<td colspan=2><hr></td>
</tr><tr>
<td>Password:</td>
<td><input type=password name=userform[password]></td>
</tr><tr>
<td>Confirm Password:</td>
<td><input type=password name=userform[confirm_password]></td>
</tr>

<tr>
<td>
<?

// smf api   


HERE GOES SMF API CODE !!


// api end     
?>
</td>
</tr>

<tr>
<td colspan=2 align=center><input type="submit" value="Signup"></td>
</tr></table></form><br></td></tr></table>

<script language="php"> include("footer.php");</script>


--- End code ---

I added the signup code for SMF at the end where "HERE GOES SMF API CODE !!"  , but I get this error:


--- Quote ---Warning: require_once(forum/smf_1-1_api.php) [function.require-once]: failed to open stream: No such file or directory in /home/cashav/public_html/pages/signup.php on line 121

Fatal error: require_once() [function.require]: Failed opening required 'forum/smf_1-1_api.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cashav/public_html/pages/signup.php on line 121
--- End quote ---


When I change it to this modified code: 



--- Code: ---// smf api   
$username = userform("username");
$email = userform("email");   
$passwd = userform("password");
require_once("smf_1-1_api.php");

$sql=$Db1->query("INSERT INTO smf_members SET
name='".$username."',
memberName='".$username."',
passwd ='".md5($passwd)."',
                        emailAddress='".$email."'
       
");
         
// api end



--- End code ---

I get this error:


--- Quote ---Fatal error: Call to a member function query() on a non-object in /home/cashav/public_html/pages/signup.php on line 123

--- End quote ---


What am I doing wrong? can you help me solve it?


Thanks

Navigation

[0] Message Index

Go to full version