...

View Full Version : Register Info Not Inserting Into Tables



Antec360
08-02-2008, 05:40 AM
Ok...here is my problem, I am trying to setup this script so that when a user hits the submit button the script will take the info and insert it into the database called "members" and it will send them an activation email. The issues that I am having are:

1. The table is being created but none of the information is being stored into the database except for the ID and a timestamp that is all zeros.

2. The username is not being displayed on the output page saying that your registration has been sent and that an activation email is on it's way.

3. The activation email is not being sent.

I have attached a copy of my script named: register2.txt in hopes that someone may be able to help me solve my issues.

Thank You

JohnDubya
08-02-2008, 06:30 AM
At the top, you have


case "joinb":
addmember($member);
break;

$member is nothing because you haven't set it to anything yet. You need to have this above the block I copied:


<?php
$member = $_POST['member'];
?>

Antec
08-02-2008, 06:34 AM
Basicly what i would like to do with that part is just have it input the word "member"...it really has nothing to do with the script in a whole...it is basicly for the chat system to know who to assign admin or regular member rights too...so I would like it to default input member and for the time being until i code up a script to change the settings in the admin control panel I will just edit it manually in phpmyadmin. If you can think of a reason and possibly a solution as to why none of this information is being entered into the database please let me know...I have been trying to get this to work for the past couple of days and it is driving me insane lol

JohnDubya
08-02-2008, 06:50 AM
Another problem in your code...I see that you've set $status="member"; and then tried to use $status = $_POST['$status']; .

First off, why do this? Why not just put 'member' in there?

And second off, since you're using single quotes inside the POST, PHP does not parse variables. If you want PHP to parse that $status inside the POST, you need to use double quotes. Like so:


$member = $_POST["$status"];

But if I were you, I would just use $_POST['member'] unless you have a special need for it.

JohnDubya
08-02-2008, 06:57 AM
If you can think of a reason and possibly a solution as to why none of this information is being entered into the database please let me know...I have been trying to get this to work for the past couple of days and it is driving me insane lol

Once again, at the top of your page you are calling the function addmember($member), which has an argument that needs to be the $_POST information. The $member you are passing contains nothing, since you haven't set $member to anything above the function.

And when you start using variables later on, you need to surround the array key with single quotes, like so:


if(!$member['name']){

}

Antec
08-02-2008, 08:01 AM
First I would liek to thank you for your insight on this....I have done what you said about changing from single to double quotes but it still will not save the information to the database. Nothing saves at all except for the ID and an empty time stamp. Here is what im tryin to pull from the form and post to the database:



$status = $_POST['member'];
$member[name] = $_POST["$member[name]"];
$ip = $_POST["$ip"];
$enurl = $_POST["$enurl"];
$member[gender] = $_POST["$member[gender]"];
$member[country] = $_POST["$member[country]"];
$member[chatpass] = $_POST["$member[chatpass]"];
$member[email] = $_POST["$member[email]"];
$anumber = $_POST["$anumber"];
$pass2 = $_POST["$pass2"];
$extrasql = $_POST["$extrasql"];

$query="INSERT INTO members (id, status, name, ipaddress, salt, gender, country, password, chatpass, email, joined, act)VALUES ('NULL', '".$status."', '".$member[name]."', '".$ip."', '".$enurl."', '".$member[gender]."', '".$member[country]."', '".$pass2."', '".$member[chatpass]."', '".$member[email]."', 'NULL', '".$anumber."')";

mysql_query($query) or die ('Error Updating The Database...Please Contact Antec@ClanGamez.com');

JohnDubya
08-02-2008, 08:11 AM
<?
/*======================================================================*\
|| #################################################################### ||
|| # Elite Gaming Ladder v2
|| # ---------------------------------------------------------------- # ||
|| # Copyright 2007-2008 Elite Gaming Ladder LLC. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ------------------- EGL IS NOT FREE SOFTWARE ------------------- # ||
|| # http://www.eliteladders.com # ||
|| #################################################################### ||
\*======================================================================*/

session_start();
include("./includes/incglobal.php");

$member = $_POST['member'];

switch($action){

case "joinb":
addmember($member);
break;

case "activate":
activate();
break;

default:
newteam($team);
break;
}

Antec
08-02-2008, 08:55 AM
That still doesn't solve the problem that the information in the form is not being saved to the database. Like i said it creates a new table and gives it a unique ID like it is supposed to but the info: ip, email, passwords, and so on is not being saved...all the fields are blank in the database when i look at it in phpmyadmin

abduraooft
08-02-2008, 09:29 AM
Post/upload your current code/file

Antec
08-02-2008, 07:45 PM
Here is the updated script: register_updated.txt

JohnDubya
08-02-2008, 09:10 PM
There are a lot of inconsistencies and errors in your code. You really need to go back in and look over it more carefully. Here are some:

Don't use single quotes around your HTML tags (don't do this: <table width='90&#37;'> ). Always use double quotes. I'm sure you're doing this because you started $out[body].=" with double quotes, but you don't have to do that. Start with single quotes, and when you come to a variable that needs to be parsed, use concatenation (a period). Concatenation just means linking things...it "glues" stuff together. Like so:



$out['body'] .= '<tr bgcolor="'.$config['altcolora'].'">';


Also, with all of your array values, you need to use single quotes inside of the square brackets.



//Use this:
$member['name'] = '';

//Instead of this:
$member[name] = '';


And in this section, I'll comment my suggestions:



//Why are you setting this? You only use it in the query, but $_POST['member']
//is an array, so nothing will go into the database from this variable.
$status = $_POST['member'];

//You need to just set $member to have the POST info and then call up $member['name'].
//Like this:
$member = $_POST['member'];

//Then, you can simply call $member['name'] and it will have whatever the user
//typed in for his name.

$ip = $_POST["$ip"];
$enurl = $_POST["$enurl"];

//Same thing as above applies for these.
$member[gender] = $_POST["$member[gender]"];
$member[country] = $_POST["$member[country]"];
$member[chatpass] = $_POST["$member[chatpass]"];
$member[email] = $_POST["$member[email]"];
$anumber = $_POST["$anumber"];
$pass2 = $_POST["$pass2"];
$extrasql = $_POST["$extrasql"];

//Then for this, make sure you put single quotes inside each array value, like
//I described above. $member['name'] instead of $member[name]
$query="INSERT INTO members (id, status, name, ipaddress, salt, gender, country, password, chatpass, email, joined, act)VALUES ('NULL', '".$status."', '".$member[name]."', '".$ip."', '".$enurl."', '".$member[gender]."', '".$member[country]."', '".$pass2."', '".$member[chatpass]."', '".$member[email]."', 'NULL', '".$anumber."')";

Antec
08-02-2008, 10:11 PM
Thank you for all your help guys, I am pretty noob so I thank you for your time and effort. Ok so JohnDubya I think I have done what you said but im not too sure so I have uploaded another copy of my script titled: register_updated.txt

JohnDubya
08-02-2008, 10:34 PM
By using these declarations:


$member['name'] = $_POST['$member[name]'];

$member['gender'] = $_POST['$member[gender]'];
$member['country'] = $_POST['$member[country]'];
$member['chatpass'] = $_POST['$member[chatpass]'];
$member['email'] = $_POST['$member[email]'];

you are actually setting $member['name'] and all the rest to nothing, since $_POST['$member[name]'] and the rest mean nothing. You need to remove all of those. You already checked these variables earlier in the code, so why even have these additional declarations?

There are still more array values that need to have single quotes in them...like for $email[toname] and the other $email array values. Are we getting it to work now?

Antec
08-02-2008, 10:37 PM
ok so you are saying that this:


$member['name'] = $_POST['$member[name]'];

$member['gender'] = $_POST['$member[gender]'];
$member['country'] = $_POST['$member[country]'];
$member['chatpass'] = $_POST['$member[chatpass]'];
$member['email'] = $_POST['$member[email]'];

should be like this?


$member[name] = $_POST['$member[name]'];

$member[gender] = $_POST['$member[gender]'];
$member[country] = $_POST['$member[country]'];
$member[chatpass] = $_POST['$member[chatpass]'];
$member[email] = $_POST['$member[email]'];

and what shoudl be in the "name & value" parts of the form itself? because as it is right now it is pulling this error:

"Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /homepages/41/d245653625/htdocs/gaming/register.php on line 56"

JohnDubya
08-02-2008, 10:46 PM
Like I said before, all array values need the single quotes in them. So

$member['name']

should always be used. Now, as for what I said...I mean you need to completely erase those extra declarations, since they are clearing your form data. It needs to be like this:



$ip = $_POST['$ip'];
$enurl = $_POST['$enurl'];

$anumber = $_POST['anumber'];
$pass2 = $_POST['pass2'];
$extrasql = $_POST['extrasql'];

$query="INSERT INTO members (id, status, name, ipaddress, salt, gender, country, password, chatpass, email, joined, act)VALUES ('NULL', '".$status."', '".$member['name']."', '".$ip."', '".$enurl."', '".$member['gender']."', '".$member['country']."', '".$pass2."', '".$member['chatpass']."', '".$member['email']."', 'NULL', '".$anumber."')";

mysql_query($query) or die ('Error Updating The Database...Please Contact Antec@ClanGamez.com');

Antec
08-02-2008, 10:53 PM
I am still getting that parse error on line 56...here is what I have on line 56:



<td width='60&#37;' valign='center' align='center' background='$config[cellbg]'><input type='text' name="'.member['name'].'" value='$member['name']' class='input' size='40' maxlength='15'></td>

JohnDubya
08-02-2008, 10:55 PM
You forgot the $ for the variable at:

"'.member['name'].'"

Antec
08-02-2008, 11:02 PM
I'm still getting:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /homepages/41/d245653625/htdocs/gaming/register.php on line 56

Here is the line:



<td width='60&#37;' valign='center' align='center' background='$config[cellbg]'><input type='text' name="'.$member['name'].'" value='$member['name']' class='input' size='40' maxlength='15'></td>

Antec
08-03-2008, 12:49 AM
Any suggestions as to why I'm getting this error?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum