News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

what's wrong with my register.php integration..?

Started by A2xA, August 31, 2008, 10:12:14 PM

Previous topic - Next topic

A2xA

In register.php I've made it where it inserts my user info along with SMF's into 2 seperate mysql tables..

In register.php under:
// Registration options are always default options...
if (isset($_POST['default_options']))
$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
$regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array();


I added:
//MY ****** THAT WONT WORK!!!!!!!!!!
    $memberID = registerMember($regOptions);
    require_once('/x/x/x/x/x/x/SiteRegister.php');
    newregister("options", "member_id");



the SiteRegister.php file:
<?php
function handle_this($regOptions$memberID) {

$con mysql_connect("x","x","x");
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }
  
  
mysql_select_db("battlewa_smf"$con);

mysql_query("INSERT INTO users (userName, userUser, userPass, UserID, userEmail) 
VALUES (" 
$regOptions['username'] . ", " $regOptions['username'] . ", " $regOptions['password'] . ", " $memberID " " $regOptions['email'] . ");");


mysql_close($con);

}


?>


The Error it gives me:
Unable to send mail to the email address 'Whatever Email I entered'

It's not inserting the new things I want it to and it's giving me that error.  If someone could take a look at this I would appreciate it so much!

This is the last thing I need to do before my sites fully integrated and I've been working on it forever  :-[


Online Video Game Battles Community that Supports Xbox 360, Wii, And PS3

Orstio

QuoteUnable to send mail to the email address 'Whatever Email I entered'

Even if you are just testing, you need to use a valid email address in the email address field.

A2xA



Online Video Game Battles Community that Supports Xbox 360, Wii, And PS3

Orstio


A2xA

Ohh haha wow, my bad.  Nvm now when I enter a valid e-mail it gives me this error:

Warning: mysql_query(): 7 is not a valid MySQL-Link resource in /x/x/x/x/x/Subs.php on line 321
2: mysql_query(): 7 is not a valid MySQL-Link resource
File: /x/x/x/x/x/Subs.php
Line: 321



Online Video Game Battles Community that Supports Xbox 360, Wii, And PS3

Orstio

That's most likely due to your opening and closing of the database connection in the handle_this() function.

You can probably just global $db_prefix and not worry about opening a new connection because SMF is already connected.

A2xA



Online Video Game Battles Community that Supports Xbox 360, Wii, And PS3

A2xA

I used this for SiteRegister.php:

<?php

include_once('SSI.php');

function 
handle_this($regOptions$memberID) {
global 
$db_prefix;



mysql_query("INSERT INTO users (userName, userUser, userPass, UserID, userEmail) 
VALUES (" 
$regOptions['username'] . ", " $regOptions['username'] . ", " $regOptions['password'] . ", " $memberID " " $regOptions['email'] . ");");


}


?>


Now there is no error code, and it links me to the main index. With the regular smf user being registered.  Except it's still not inserting my sql entries? 


Online Video Game Battles Community that Supports Xbox 360, Wii, And PS3

Orstio

Why are you including SSI?

From where are you calling handle_this() ?

A2xA

oh I thought it was needed haha.

It's under register.php I added this:



//MY ****** THAT WONT WORK!!!!!!!!!!!!!!!!!!!!!!!!
    $memberID = registerMember($regOptions);
    require_once('/x/x/x/x/x/SiteRegister.php');
    handle_this("options", "member_id");


right after:
// Registration options are always default options...
   if (isset($_POST['default_options']))
      $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
   $regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array();


Online Video Game Battles Community that Supports Xbox 360, Wii, And PS3

Orstio

Look at what you are passing to the function:

handle_this("options", "member_id");

That means that locally in handle_this(), the value of $regOptions is the text string "options", and $memberID is the text string "member_id".

In code, it would be the same as this:

$regOptions = "options";
$memberID = "member_id";


That's probably not what you are wanting to do.

A2xA

#11
ohh.  So I'd have to put each individual $regOptions['whatever']?

like..

//MY ****** THAT WONT WORK!!!!!!!!!!!!!!!!!!!!!!!!
    $memberID = registerMember($regOptions);
    require_once('/x/x/x/x/x/SiteRegister.php');
    handle_this("$regOptions['username']", "$regOptions['password']"); etc...?


So how would I pass these with the values I'm wanting them to?

Thanks for all of the help by the way I really appreciate it.


Online Video Game Battles Community that Supports Xbox 360, Wii, And PS3

Orstio

No, I'm thinking what you are probably wanting to do is pass the $regOptions array, and the $memberID?

handle_this($regOptions, $memberID);

It really is that simple.

A2xA

#13
Thank you so much I'm making progress.  Now there is no long load time for the register, and everythings working except..

It's still not inserting my user sql entrys.. I'm not sure what's wrong with it.


Online Video Game Battles Community that Supports Xbox 360, Wii, And PS3

Orstio

Check the error log in your SMF admin panel for clues.

A2xA



Online Video Game Battles Community that Supports Xbox 360, Wii, And PS3

Orstio

Oh, I see something.

Your query has a semi-colon on the end.

Try removing the semi-colon from the query:

mysql_query("INSERT INTO users (userName, userUser, userPass, UserID, userEmail)
VALUES (" . $regOptions['username'] . ", " . $regOptions['username'] . ", " . $regOptions['password'] . ", " . $memberID . " " . $regOptions['email'] . ")");

A2xA

Just remove it?

If I just remove it, it gives me a:

Parse error: syntax error, unexpected '}' in /x/x/x/x/x/SiteRegister.php on line 13


Online Video Game Battles Community that Supports Xbox 360, Wii, And PS3

Orstio

I already removed it from the code I posted before I posted it.  You can copy it directly from my post and paste it into your file.  The semi-colon on the end of of the PHP mysql_query statement still needs to be there.  The semi-colon INSIDE your query needs to be removed.

A2xA

#19
I Got it working.   :D

I didn't have ' ' quotes around my strings.


Online Video Game Battles Community that Supports Xbox 360, Wii, And PS3

Advertisement: