/    Sign up×
Community /Pin to ProfileBookmark

PHP Insert Problem

Hello, I’m having an issue with my registration code. for some reason, everything functions properly up until it gets to the actual data insertion portion of the php. It bumps me over to my error code “$errormsg = “An error has occurred. Your account was not created.”;”

Can somebody tell me why this is? I’ve looked it over for a few hours now.

[code=php]
if ($_POST[‘submitbtn’]){
$getuser = $_POST[‘user’];
$getemail = $_POST[’email’];
$getpass = $_POST[‘pass’];
$getverifypass = $_POST[‘verifypass’];
$lastloginip = $_SERVER[‘REMOTE_ADDR’];
$getfirstname = $_POST[‘firstname’];
$getlastname = $_POST[‘lastname’];
$getbirthmonth = $_POST[‘birthmonth’];
$getbirthday = $_POST[‘birthday’];
$getbirthyear = $_POST[‘birthyear’];
$getgender = $_POST[‘gender’];

if ( $getuser){
if ( $getemail){
if ( $getpass){
if ( $getverifypass){
if ( $getpass === $getverifypass){
if ( ( strlen($getemail) >= 7 ) && ( strstr($getemail, ‘@’) ) && ( strstr($getemail, ‘.’) ) ){
require(‘connect.php’);

$query = mysql_query(“SELECT * FROM members415 WHERE username=’$getuser'”);
$numrows = mysql_num_rows($query);

if ($numrows == 0){
$query = mysql_query(“SELECT * FROM members415 WHERE email=’$getemail'”);
$numrows = mysql_num_rows($query);
if ($numrows == 0){

$password = md5(md5(“salt”.$getpass.”salt”));
$date = date(‘M d, Y’);
$code = md5(rand());

mysql_query(“INSERT INTO tc_members415 (‘id’, ‘username’, ‘password’, ’email’, ‘last_logindate’, ‘join_date’, ’emailactivated’, ‘code’, ‘firstname’, ‘lastname’, ‘last_loginip’, ‘birthdate_month’, ‘birthdate_day’, ‘birthdate_year’, ‘gender’, ‘admin_user’, ‘admin_entity’, ‘admin_art’, ‘admin_galaxy’, ‘admin_global’, ‘subscription’, ‘character’, ‘pm_setting’) VALUES (”, ‘$getuser’, ‘$password’, ‘$getemail’, ‘$date’, ‘$date’, ‘0’, ‘$code’, ‘$getfirstname’, ‘$getlastname’, ‘$lastloginip’, ‘$getbirthmonth’, ‘$getbirthday’, ‘$getbirthyear’, ‘$getgender’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ’30’, ‘None’, ‘0’)”);

$query1 = mysql_query(“SELECT * FROM members415 WHERE username=’$getuser'”);
$numrows = mysql_num_rows($query1);
if ($numrows == 1){

$site = ‘http://www.edit.com’;
$headers = ‘From: TC Admin <[email protected]>’;
$subject = ‘edit: Activate your account’;
$message = ‘Thanks for registering your edit account. In order to use your account, you must first activate it with the following details; URL: (http://www.edit.com/activate.php) Code: (‘.$code.’) Click the following link to activate your account. ‘.$site.’/activate.php?user=’.$getuser.’&code=’.$code.”;

if (mail($getemail, $subject, $message, $headers)){

$errormsg = “<font color=’blue’>You have been registered. You must activate your account with the activation link sent to <b>$getemail</b></font>”;
echo “$backcontent $errormsg $content.”;
$getuser = ”;
$getemail = ”;
$_POST[‘submitbtn’] = ”;
mysql_close();

}
else
$errormsg = “An error has occurred. Your activation email was not sent.”;
echo “$backcontent <font color’red’>$errormsg</font> $content”;
mysql_close();

}
else
$errormsg = “An error has occurred. Your account was not created.”;
echo “$backcontent <font color=’red’>$errormsg</font> $content”;
mysql_close();

}
else
$errormsg = “There is already a user with that email address.”;
echo “$backcontent <font color=’red’>$errormsg</font> $content”;
mysql_close();

}
else
$errormsg = “There is already a user with that username.”;
echo “$backcontent <font color=’red’>$errormsg</font> $content”;
mysql_close();
}
else
$errormsg = “You must enter a valid email address to register.”;
echo “$backcontent <font color=’red’>$errormsg</font> $content”;

}
else
$errormsg = “Your passwords did not match.”;
echo “$backcontent <font color=’red’>$errormsg</font> $content”;

}
else
$errormsg = “You must verify your password to register.”;
echo “$backcontent <font color=’red’>$errormsg</font> $content”;

}
else
$errormsg = “You must enter a password to register.”;
echo “$backcontent <font color=’red’>$errormsg</font> $content”;

}
else
$errormsg = “You must enter your email to register.”;
echo “$backcontent <font color=’red’>$errormsg</font> $content”;

}
else
$errormsg = “You must enter your username to register.”;
echo “$backcontent <font color=’red’>$errormsg</font> $content”;
}
else
[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@iahneMay 14.2012 — well, based on your code, I won't be able to know if there's an error on your "INSERT INTO tc_members415...". maybe you could try adding " or die(mysql_error())" so you would know if there's an error and what error you are having on that query. Your code for that insert will be :

[code=php]
mysql_query("INSERT INTO tc_members415 ('id', 'username', 'password', 'email', 'last_logindate', 'join_date', 'emailactivated', 'code', 'firstname', 'lastname', 'last_loginip', 'birthdate_month', 'birthdate_day', 'birthdate_year', 'gender', 'admin_user', 'admin_entity', 'admin_art', 'admin_galaxy', 'admin_global', 'subscription', 'character', 'pm_setting') VALUES ('', '$getuser', '$password', '$getemail', '$date', '$date', '0', '$code', '$getfirstname', '$getlastname', '$lastloginip', '$getbirthmonth', '$getbirthday', '$getbirthyear', '$getgender', '0', '0', '0', '0', '0', '30', 'None', '0')") or die(mysql_error());
[/code]
Copy linkTweet thisAlerts:
@TrancienceauthorMay 14.2012 — I've been looking at the code all night looking over what was correct... the issue was in the database where a unique key was set for a column that also had a default setting of "None" and all new registrants have to pass through that "None" value at first, so I disabled the unique key and will just later add a filter to replace that duty.

Thanks!!! I've learned a lot from this...

"Always make new mistakes." I won't be repeating this one.
Copy linkTweet thisAlerts:
@iahneMay 15.2012 — I thought so it was in the database. That's why you have to include always the mysql_error() to know what exactly is the error in database. Well, that will be charged to your experience as a developer. =)
×

Success!

Help @Trancience spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...